Get the pointer to Image Data...

Please discuss general Delphi programming topics here.

Get the pointer to Image Data...

Postby hadipardis » June 22nd, 2006, 10:31 am

Hi. I am looking for a faster way than scanline to access image data. I know it is possible to do so by using pointer operation. For example I need to get a pointer to the fisrt pixel of the image. To do so, I use scanline , but I have some difficulties with it, for instance I tried the following code:
Code: Select all
 var PixelPointer,StartPointer:PByte
     b:byte;

 Bmp.Width:=640;
 Bmp.Height:=640;
 Bmp.PixelFormat:=pf24bit;// Pixel order: RGB RGB RGB ....

 StartPointer:=Bmp.ScanLine[0];
 PixelPointer := pointer(integer(StartPointer)+10*width+5);//pixel[5,10]
 Move(PixelPointer^, b, 1);  <<EAccessViolation!!!


But it raised an EAccessViolation exception. Do you know what is the problem? I want to get the RGB value of each pixel inside the image. Anyway, do you know any other way for obtaining the pointer to the image data? Thanks
hadipardis
Junior Member
Junior Member
 
Posts: 33
Joined: July 17th, 2004, 5:45 am

Postby Kambiz » June 22nd, 2006, 12:47 pm

Bits of some bitmaps are arranged upside down. In this case, the first pixel is the bottom-left pixel.

Code: Select all
FirstPixel := Bitamp.ScanLine[Bitmap.Height - 1];
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2424
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron