How I can Read the RGB-Pixel by Pixel values from CGImagea also after how to assign it to UIImage
Asked
Active
Viewed 867 times
2 Answers
0
according this link Bitmap is used to work with images defined by pixel data.
yourimage= new Bitmap(@"image address", true);
int x, y;
// Loop through the images
for(x=0; x<yourimage.Width; x++)
{
for(y=0; y<yourimage.Height; y++)
{
//Get Pixel Color
Color pixelColor = image1.GetPixel(x, y);
Color yourColor = Color.FromArgb(pixelColor.R, 0, 0);
//Set Pixel Color
yourimage.SetPixel(x, y, yourColor );

KF2
- 9,887
- 8
- 44
- 77
-
your right but i want solution for monotouch I knw c# support Bitmap class but this class has no support in monotouch – Jun 21 '12 at 12:18
-
Not sure if at the point of the above comment MT didn't support Bitmap class, but this solution now works almost flawlessly. The only thing different is `yourimage = new Bitmap(myUIImage);` – Brad Moore Jan 05 '13 at 04:58
-
Not sure what the deal is with my above comment, but it appears that Bitmap class no longer exists for MT. – Brad Moore Aug 20 '14 at 23:33
0
To read RGB pixel values with MonoTouch you can use the code posted in the answer to the following post (works fine for me):
Retrieving a pixel alpha value for a UIImage (MonoTouch)
You can also find the following post useful:
Transparent PNGs in Monotouch for iOS
And here is a link to a working implementation of mine of a convolution filter, that reads and demultiplies the pixel's rgb values (on iOS all images with alpha channel are stored in a premultiplied-alpha format):
How to Optimize this Image convolution filter Method in MonoTouch?
Remember that reading pixel values is very slow, even if you use the trick to create a bitmap context of only 1x1 pixels.

Community
- 1
- 1

Emanuele Sabetta
- 1,571
- 12
- 34