0

I have original image and I can cycle all pixels using @patrick-rutkowski answer here. Also I have this answer seems to create image with pixel data. But I can't understand how to combine these two answers. So the first task is get pixel and second is add it to another CGImage. For example if I want to extract all red pixels from the original image and add these red pixels to another image. I suppose it's way to go.

Community
  • 1
  • 1
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
  • Can you clarify what you are trying to achieve? – nschmidt Feb 04 '15 at 10:11
  • @nschmidt. I have one image with different colors. Let's say it is source image. I want to create new one image but only with pixels that I extracted from the source image e.g. if I need to extract only red pixels or blue pixels and create new images based on this pixels. – Matrosov Oleksandr Feb 04 '15 at 11:15
  • @nschmidt [here is](http://stackoverflow.com/questions/1579631/converting-rgb-data-into-a-bitmap-in-objective-c-cocoa) also answer how to create pixels. – Matrosov Oleksandr Feb 04 '15 at 14:40
  • @nschmidt. So let's say I have image 50 x 100 then I will have Byte r[100][50] and the same for g and b. Then I will use your example to add alpha channel. So I need some cycle where I can track all pixels and compare them with some color for example red. Then I need to save a position of the red pixel and draw it the output image. If pixel is not the red I will add transparent pixel on that place. But this is just idea. I want to know how can I cycle source image pixels and compare it with some color and then create output image based on condition I described. – Matrosov Oleksandr Feb 04 '15 at 14:44

0 Answers0