Get Current Pixel value using Scanline in Delphi
I am trying to get the current pixel in an image by a "OnMouseMove event" Using Scanline.
something equivalent to this:
Label1.Capt开发者_运维知识库ion := IntToStr(Image1.Picture.Bitmap.Canvas.Pixels[X,Y]);
Any ideas ?
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]);
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.
精彩评论