How can I compare a bitmap to another bitmap?
How can I compare a bitmap to another bitmap?
Compare as in this?
^ will measure the change from 1 bitmap to another.Simba Code:function CalculatePixelShift(Bmp1, Bmp2: Integer; CompareBox: TBox): Integer;
If no, more information as to what you wish to do with the bitmaps would help to aide in finding something to compare the bitmaps.
thanks for help. +rep
Last edited by Toby1; 08-18-2012 at 10:02 PM.
Last edited by Zyt3x; 08-19-2012 at 03:01 PM. Reason: no need to bump a 1 day old thread
Respect your elders.
What are these bitmaps you are trying to compare? It may be possible that there is an easier way to do this using functions/other features of the include. Without us knowing what you are trying to do it is difficult to make a suggestion.
My suggestion:
Set the larger bitmap as a target, use FindBitmapDeformedToleranceIn with the smaller bitmap in a part to see how much they match.
http://docs.villavu.com/simba/script...maptolerancein
The best way to contact me is by email, which you can find on my website: http://wizzup.org
I also get email notifications of private messages, though.
Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
Documentation | Source | Simba Bug Tracker on Github and Villavu )
My (Blog | Website)
Now there's a good idea. I see loading the big bitmap and setting it as the target (then finding the small bitmap within the large) is really straight forward, but how would we set our original target back after comparing the two bitmaps? Getting the original target ID and setting that ID back, that I don't know how to do.
I can see where this would lead to a similar SPS.
Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
I can't get the goto to work. If you do though, this should work.
Simba Code:Function FindBitmapInBitmap(BMP, BitmapToFind: Integer; var P: TPoint; Area: TBox; Tolerance: Integer): Boolean;
var
BmpW, BmpH, DX, DY, I, J, X, Y, W, H: Integer;
FindColours, SearchColours: T2DIntegerArray;
Label Skip;
begin
GetBitmapSize(BMP, W, H);
GetBitmapSize(BitmapToFind, BmpW, BmpH);
SearchColours := GetBitmapAreaColors(BMP, 0, 0, W, H);
FindColours := GetBitmapAreaColors(BitmapToFind, 0, 0, BmpW, BmpH);
BmpW := BmpW - 1;
BmpH := BmpH - 1;
dX := (Area.X2 - Area.X1) - BmpW;
dY := (Area.Y2 - Area.Y1) - BmpH;
For I := 0 To DY Do
For J := 0 To DX Do
begin
For Y := 0 To BmpH Do
For X := 0 To BmpW Do
begin
if (FindColours[Y][X] <> 0) then
if (Not SimilarColors(FindColours[Y][X], SearchColours[Y + I][X + J], Tolerance)) then
GoTo Skip;
end;
P := Point(J + Area.X1, I + Area.Y1);
Resul:= True;
Exit;
Skip:
continue;
end;
P(-1, -1);
Result := False;
end;
I am Ggzz..
Hackintosher
There are currently 1 users browsing this thread. (0 members and 1 guests)