How to get RGB value for the whole picture using c# code - RealWorld forums

Log-in or register.

How to get RGB value for the whole picture using c# code

santhi
on July 3rd 2006

Hello Everyone,

How do I getr RGB value for the picture using c# code. I am using GetPixel with in a loop but this is very slow. Can anyone please suggest better way of getting RGB value for the whole picture.

Thanks in Advance!

Vlasta
on July 3rd 2006

I am not sure whether there is any better way. If you need to work with large pictures and speed is a problem, then maybe .net is not the right environment.

You may try to resize the image to 1x1 using a method that computes correct pixel coverages, or resize it using a sequence of operations, where you shrink the image to 50% in each step. Hopefully the resizing is optimized.

Another way would be to skip pixels lik taking every 5th pixel in every 5th row. The result won't be precise, but maybe it'll enough for you.

Anonymous
on August 30th 2006

just use the Bitmap object and Lock the bits and use scan0 to get a pointer to the start of the data. use marshal copy commands to transfer around the data, you can move entire images around. i'm sure there are some examples on the msdn site...

Page views: 13345       Posts: 3      
Select background
Vista & Win 7 icons
I wish there were...