It works BUT works slow. I can't find why it works slow. It only has to draw image to black and it takes 2 or 3 seconds to color whole image. And there are 2 more things about this. Method getPixel:atX:y:. In getPixel: should be passed NSInteger but I can't find anywhere nothing about this. As well as bitmapData. I can't find how to use this methods and when I try to use them I always get an error.

Then I tried to use CoreGraphics to redraw image from one NSImageView to second:

There are at least 2 method calls per pixel there, and probably a lot more. That is almost certainly dwarfing the cost of setting an individual pixel by an order of magnitude. Your best bet is probably to copy the bitmap out of the bitmap rep, modify it using a pure C for loop, then copy it back into the bitmap rep.

Also, if you are just setting the whole thing to a solid color, why not just use a fill rect?

getPixel:atX:y: and bitmapData. But in first I don't know what to pass as getPixel: (NSInteger)p. And second is not clear enough as well. On some pages people write something like this:

unsigned char *data = [bitmapImageRep bitmapData];

what is strange for me...

(Jul 28, 2010 06:09 AM)Skorche Wrote: That is almost certainly dwarfing the cost of setting an individual pixel by an order of magnitude. Your best bet is probably to copy the bitmap out of the bitmap rep, modify it using a pure C for loop, then copy it back into the bitmap rep.

Hmmm that is why I wrote my post here - I don't really know how to do that. I mean - when creating a bitmap context there is a buffer. But whole issue is to get into this buffer. As I wrote in my last post - I am new to image processing and maybe some problems are easy to solve, but for me everything is strange and unfriendly...

(Jul 28, 2010 06:09 AM)Skorche Wrote: Also, if you are just setting the whole thing to a solid color, why not just use a fill rect?

It was only to check the code. Finally it should check color of pixel and decide - change color or go to next pixel.

(Jul 28, 2010 06:09 AM)Skorche Wrote: That is almost certainly dwarfing the cost of setting an individual pixel by an order of magnitude. Your best bet is probably to copy the bitmap out of the bitmap rep, modify it using a pure C for loop, then copy it back into the bitmap rep.

Hmmm that is why I wrote my post here - I don't really know how to do that. I mean - when creating a bitmap context there is a buffer. But whole issue is to get into this buffer. As I wrote in my last post - I am new to image processing and maybe some problems are easy to solve, but for me everything is strange and unfriendly...

NSImage definitely doesn't make it obvious how this can be done. Here's my method: