-2

i have the following error message in Delphi 7:

Undeclared identifier: 'scanline'

my uses: uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, Buttons, StdCtrls, ExtCtrls,math, ComCtrls;

my part of code:

screenshot(0,0,screen.Width,screen.Height,bmp);
for a:=1 to screen.Height do begin
pxl:=scanline[a-1];
end;

where pxl is PByteArray;

screenshot is a procedure that catching the selected area into a bitmap...

AFAIK scanline function using Graphics library, but it does not works..

What I am doing wrong?

Thanks

Fero
  • 35
  • 1
  • 1
  • 8
  • `ScanLine` is a method of `TBitmap`, not a stand-alone function. See the documentation for [TBitmap,ScanLine.](http://docwiki.embarcadero.com/Libraries/Seattle/en/Vcl.Graphics.TBitmap.ScanLine) - the link is for Delphi 10 Seattle, but it's still relevant to Delphi 7. What exactly do you expect `scanline[a-1]` to be accessing? Psychic pixels? – Ken White Apr 14 '16 at 19:05
  • i need to "see" what is in the desktop and when i find the wanted color combination of pixels, it will fire a procedure – Fero Apr 14 '16 at 19:12
  • As I said, `ScanLine` is a method of `TBitmap`. I've shown you the documentation. Your use is a simple lack of reading of the documentation; you can't use `ScanLine` by itself, because it doesn't exist by itself. Your code accesses `scanline` of nothing, meaning there is nothing to retrieve a scanline from except imaginary pixels. I presume that the `bmp` you're passing to `screenshot` is a `TBitmap`, so use it: `bmp.ScanLine`. – Ken White Apr 14 '16 at 19:16
  • yeah sorry, bmp.scanline worked fine... I need to take a rest :) Thanks, it solved my problem... – Fero Apr 14 '16 at 19:20

1 Answers1

1

[ScanLine][1] is not a standalone function. It's a method of some graphics classes such as TBitmap. You need an instance of one of those classes in order to call ScanLine. ScanLine also does not return a single pixel, but an entire line of pixels at once.

Presuming that the bmp in your call to screenshot is a TBitmap, you can use bmp.ScanLine[a - 1];, which would return a pointer to an entire line (row) of pixels.

Ken White
  • 123,280
  • 14
  • 225
  • 444