Hi all,
I am trying to write an application in which I will have several png images I load in. They are all essentially masks, but based on user input, I want to change the color of them. I determined that the easiest way would probably be to test if the pixel was transparent, and if it was ignore it, but if the pixel was opaque, change the color of it.
The only problem is that I have know idea of how to do this. Thanks in advance!
Hi all,
I am trying to write an application in which I will have several png images I load in. They are all essentially masks, but based on user input, I want to change the color of them. I determined that the easiest way would probably be to test if the pixel was transparent, and if it was ignore it, but if the pixel was opaque, change the color of it.
The only problem is that I have know idea of how to do this. Thanks in advance!
There is a way to use a BitmapContext to get a data array in which the image pixels are laid out uncompressed and depending on the chosen color value layout as e.g. RGBA RGBA RGBA etc. Look into the Core Graphics Programming Guide next to bitmaps.
In theory you can calculate the appropriate address in this memory chunk and then check the alpha value there.
I did not find a direct method to get the RGBA values of a pixel.
Yesterday with the help of 2 people I managed to create a bitmap directly in memory. Your need would probably just be the reverse. If nobody can help you then I might create a UIImage addendum to give me direct drawing and pixel checking because this is a major nuissance in SDK that such methods are missing.
__________________
regards
Oliver Drobnik Cocoanetics - Our DNA is programmed in Objective-C.
Cocoanetics Parts Store – easy to use yet professionally looking components that you can use to spruce up your own apps. Augmented Reality, Calendar Control, Pin Lock or Purchase Button are only some examples. You get full source code, no static library crap, and lifetime support. Check it out today!
Is it hard to convert images to bitmap? And once I have images as bitmap, is it hard to get the pixel value? Because if it is hard to get the image to bitmap, I can just save them all as bitmap from Photoshop and bypass that whole step. Thanks!
Is it hard to convert images to bitmap? And once I have images as bitmap, is it hard to get the pixel value? Because if it is hard to get the image to bitmap, I can just save them all as bitmap from Photoshop and bypass that whole step. Thanks!
No that's both the same effiort. The SDK uncompresses both for you.
__________________
regards
Oliver Drobnik Cocoanetics - Our DNA is programmed in Objective-C.
Cocoanetics Parts Store – easy to use yet professionally looking components that you can use to spruce up your own apps. Augmented Reality, Calendar Control, Pin Lock or Purchase Button are only some examples. You get full source code, no static library crap, and lifetime support. Check it out today!