tags:

views:

321

answers:

2

Hey,

I am trying to get the current pixel in an image by a "OnMouseMove event" Using Scanline.

something equivalent to this:

Label1.Caption := IntToStr(Image1.Picture.Bitmap.Canvas.Pixels[X,Y]);

Any ideas ?

+1  A: 

Scanlines are useful for quickly scanning the entire line, like in your other post. But if you want to get an arbitrary single pixel, the best way to do it is to use the code you've already got.

Mason Wheeler
This post (in some way) connect to the other post :), so the canvas.pixel is not useful to me.
Goblin
+2  A: 

ScanLine returns a pointer to a packed array of pixels that constitutes one line of a bitmap. Using this pointer you can access these pixels fast.

ScanLine can't help if you need only one pixel.

Still you can use ScanLine here; assuming bitmap pixel format pf32bit:

Label1.Caption:= IntToStr(PIntegerArray(Image1.Picture.Bitmap.ScanLine[Y])^[X]);
Serg
ScanLine can still be useful for accessing individual pixels, if you have to access them often. You just have to make sure you take the bitmap's PixelFormat into account so you access the correct bits of a ScanLine's data.
Remy Lebeau - TeamB