Use the tbdbitmapdata object to find the differences between the two images

Source: Internet
Author: User

Use the tbdbitmapdata object to find the differences between the two images. From the upper right corner, use the double-layer loop to traverse all the pixel points on the two images and compare them with each other. IncompleteCodeAs follows:

Procedure tform1.button5click (Sender: tobject );
VaR
BMP 1, BMP 2: tbdbitmapdata;
Left, top: integer;
Isexit: Boolean;
Begin
BMP 1: = tbdbitmapdata. Create;
BMP 2: = tbdbitmapdata. Create;

BMP 1.loadfromfile ('file name 1 ');
BMP 2.loadfromfile ('file name 2 ');

// Assume that the two images are the same size.

Isexit: = false;
For top: = 0 to BMP 1.height-1 do
Begin
For left: = 0 to BMP 1.width-1 do
Begin
If BMP 1 [left, top] <> BMP 2 [left, top] Then
Begin
// The two images are different at the (left, top) position.

// Processing...

If {if you do not continue searching for other differences} Then
Begin
Isexit: = true; // used to exit the loop
Break;
End;
End;
End;
If isexit then break;
End;

BMP 1.free;
BMP 2.free;
End;

The above code is incomplete and can be modified as needed. For details about how to use tbdbitmapdata, refer to: full screen quick image color search in Delphi.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.