per pixel image manipulation (for iphone)
hi, i'm somewhat new to objective-c and mac programming- i've worked mostly with flash in the past, and have some questions. Basically, I want to be able to set the color of each pixel in an image manually, and was wondering if it's possible with objc. if anyones familiar with actionscript, it'd look something like this in AS3:
var image:BitmapData=new BitmapData(500,500);
var imagebm:Bitmap=new Bitmap(image);
addChild(imagebm);
for(i=0;i<500;i++)
{
for(j=0;j<500;j++)
{
image.setPixel(i,j,int((i+j)/1000*0xFF))*0x010000);
}
}
(this would yield a box, with a black to red gradient going diagonally. this is just an example btw, what i actually want drawn is more complicated than this sort of gradient)
if anyone knows how to go about doing this and can point me in the right direction, i'd really appreciate it, thanks!
var image:BitmapData=new BitmapData(500,500);
var imagebm:Bitmap=new Bitmap(image);
addChild(imagebm);
for(i=0;i<500;i++)
{
for(j=0;j<500;j++)
{
image.setPixel(i,j,int((i+j)/1000*0xFF))*0x010000);
}
}
(this would yield a box, with a black to red gradient going diagonally. this is just an example btw, what i actually want drawn is more complicated than this sort of gradient)
if anyone knows how to go about doing this and can point me in the right direction, i'd really appreciate it, thanks!
Do you mean an NSImage, OpenGL or something else?
If you use Cocoa, then you can create an NSImage from an NSBitmapImageRep, the NSBitmapImageRep is similar to your AS code.
If you use Cocoa, then you can create an NSImage from an NSBitmapImageRep, the NSBitmapImageRep is similar to your AS code.
Sir, e^iπ + 1 = 0, hence God exists; reply!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| [CoreGraphics] Image manipulation - pixel by pixel | g00se | 5 | 7,274 |
Jul 28, 2010 08:27 AM Last Post: ThemsAllTook |
|

