Find scanline in scanline

Please discuss general Delphi programming topics here.

Find scanline in scanline

Postby HPW » July 5th, 2007, 7:29 am

I want to compare/find the scanline from a smaller bitmap which each position of a scanline of a widhter image. I thought that I could offset the pointer to BitMap2.ScanLine[i] by a numeric offset.

But I get an error that the operand is not valid.

Code: Select all
          BitMap1.PixelFormat := pf24bit;
          BitMap2.PixelFormat := pf24bit;
          L := BitMap1.Width * 3;

          For i := 0 to BitMap2.Height - 1 do
            begin
              for x := 0 to BitMap2.width - BitMap1.width -1 do
                If CompareMem(BitMap1.ScanLine[0], BitMap2.ScanLine[i] + x * 3, L) Then
                  Inc(W);
            end;


Any better idea?
Hans-Peter
HPW
Moderator
Moderator
 
Posts: 238
Joined: February 25th, 2006, 10:19 am
Location: Germany

Postby HPW » July 5th, 2007, 8:15 am

After finding this:

viewtopic.php?t=794&highlight=scanline

It compiles, but I am not yet sure if it work.

Code: Select all
          BitMap1.PixelFormat := pf24bit;
          BitMap2.PixelFormat := pf24bit;
          L := BitMap1.Width * 3;


          For i := 0 to BitMap2.Height - 1 do
            begin
              StartPointer:=BitMap2.ScanLine[i];
              for x := 0 to BitMap2.width - BitMap1.width -1 do
                begin
                PixelPointer := pointer(integer(StartPointer)+x*3);
                If CompareMem(BitMap1.ScanLine[0], PixelPointer , L) Then
                  Inc(W);
                end;
            end;


Have to test further.

Edit: After some test it seems to work. ;-)
Hans-Peter
HPW
Moderator
Moderator
 
Posts: 238
Joined: February 25th, 2006, 10:19 am
Location: Germany


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 10 guests

cron