Image processing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I'm working with images in Visual C++ and I need a fast method to access to individual pixels of an image. Actually I'm using the GetPixelAddress method of the Image class, but it's too slow.
Thanks for all.
 
Hi,

Look at LockBits - it allows you to get a BitmapData object which has a
property called Scan0, which refers to the address of the first pixel in the
section of the image you've specified. Then you can happily iterate through
the data.

HTH,

Steve

Antonio Gómez said:
Hi,
I'm working with images in Visual C++ and I need a fast method to access
to individual pixels of an image. Actually I'm using the GetPixelAddress
method of the Image class, but it's too slow.
 
This is indeed true. You can work this out by looking at the PixelFormat,
though if you cast the pointer when you get it it isn't an issue, e.g.

// case when it's 8 bit
uint8 *data = (uint8 *)bitmapData->Scan0;

// 16 bit
uint16 *data = (uint16 *)bitmapData->Scan0;

Then data++ iterates properly whatever you do. As another note,
BitmapData::Stride returns a number in bytes, not in pixels, so watch for
that.
 
Back
Top