View Full Version : Searching an entire bitmap for a small segment present on screen?
Xtensity
05-23-2011, 04:50 PM
Most people use bitmaps in such a manner that they try to find a bitmap on the screen.
What I am trying to do is, I have a folder full of bitmaps(some thousand), and I want to see if a specific area on the screen is present in one of my bitmaps.
I have no problem loading each individual bitmap, what I lack is a function that allows me to basically do the reverse of the FindBitmaps.
Say the area on the screen I want to match in a bitmap would be (300,300,500,500). Say I have loaded a specific bitmap. Is there any function I could use that would take that destination area on the screen, and try to find it within the bitmap?
Btw, I am not doing this for runescape, but for cheating none the less haha, so help is much appreciated.
Brandon
05-23-2011, 05:07 PM
Create a bitmap from the file.. and just compare it to the one you already have.. if its found or not, free it..
I was thinking:
open file.
SaveScreenshot(s:string);
then compare the two?
Xtensity
05-23-2011, 05:24 PM
The thousands of bitmaps I have saved are all different. What is being displayed on the screen is also different... and due to this, I have to scan for a portion of the current screen, for that same portion in each bitmap.
I can't manually compare thousands of bitmaps thousands of times... this is the whole reason I am trying to make a script to accomplish the goal :(
Shuttleu
05-23-2011, 05:33 PM
is there a pattern in naming?
is the area you are searching in the same everytime?
~shut
Xtensity
05-23-2011, 05:43 PM
is there a pattern in naming?
is the area you are searching in the same everytime?
~shut
Yes, and Yes.
Why do you ask?
weequ
05-23-2011, 06:16 PM
Interesting. I don't think there is curretly a way.
If the screen area is larger than the bitmap then you would just search the bitmap in your screen but if the bitmap is larger then you would have to search the screen area in the bitmap and I don't think there is currently a way to do it. (There is a way to convert screen area to a bitmap but idk how to search for something in a bitmap)
I'm not sure what SetImageTarget(idx: LongInt); and SetTargetBitmap(Bitmap: LongInt); does. Do you know?
Nava2
05-23-2011, 07:52 PM
There is definitely a way and its fairly simple!
You just need to loop through your images using strings and doing LoadBitmapFromFile or use TMufasaBitmaps and they have a LoadFromFile attribute (they accept many different image types). Use SetTarget onto the new bitmap then search as you normally would, then result it how ever you like, then just repeat the process for each image! I don't have Simba installed right now, I'm sorry.
weequ
05-23-2011, 09:02 PM
There is definitely a way and its fairly simple!
You just need to loop through your images using strings and doing LoadBitmapFromFile or use TMufasaBitmaps and they have a LoadFromFile attribute (they accept many different image types). Use SetTarget onto the new bitmap then search as you normally would, then result it how ever you like, then just repeat the process for each image! I don't have Simba installed right now, I'm sorry.Allright. I wasn't sure how SetTarget worked :P
Xtensity
05-24-2011, 01:17 AM
There is definitely a way and its fairly simple!
You just need to loop through your images using strings and doing LoadBitmapFromFile or use TMufasaBitmaps and they have a LoadFromFile attribute (they accept many different image types). Use SetTarget onto the new bitmap then search as you normally would, then result it how ever you like, then just repeat the process for each image! I don't have Simba installed right now, I'm sorry.
Hmm very insightful.
Perhaps I am overlooking something obvious, but how exactly do I make it search the bitmap for the set area on my screen?
I am aware that it sets the target for the search whatever bitmap I set it to, but how do I get a bitmap(that I am searching FOR) from the set area on the screen(200,200,500,500 for example) without saving an actual file?
Like, how would I take a certain area on the screen, and turn it into a bitmap for use in the program, but not to be saved as a file, etc.
Nava2
05-24-2011, 03:16 AM
Get the Screen copy to new bitmap in the bitmap array. :)
Xtensity
05-24-2011, 05:43 PM
Get the Screen copy to new bitmap in the bitmap array. :)
Hmm, sounds simply enough, but I would definitely appreciate a little guidance because you lost me xD
Edit:
I figured out CopyClientToBitmap, which seems like it should help my issue a great deal, but now I get the error "Bitmap Not Assigned"... and with research i've read I need to create the bitmap first? Though how do I do that persay?
Edit:
Nvm I figured it out. I just loaded an already existing bitmap to the bitmap var I was copying the client to.
-------
One more issue.
For some reason the FindBitmapTolerance functions aren't working at all. I have exact pictures in my folder, and it's not picking up on them... so the tolerance feature isn't even playing a roll, but it can't match a big portion of the picture. If the screen section I am scanning for in the bitmaps is like 5x5 pixels, all of the bitmaps in the folder will show positive... but I can't get any to return true with the FindBitmap function's when I am trying to find something meaningful.
Here's my script if anyone wants to help out.
program New;
var
x,Bit,Screen,p1,p2,w,h:integer;
acc:extended;
T:TStringArray;
Subject:String;
begin
ClearDebug;
T:=GetFiles('C:\Users\Xtensity\Desktop\Schoooolie\ ','png')
writeln(high(t))
Screen:=LoadBitmap('C:\Users\Xtensity\Desktop\Scho ooolie\'+T[1]);
CopyClientToBitmap(Screen,213, 329,420, 356)
GetBitmapSize(Screen,w,h)
For x:=0 to high(T) do
begin
Bit:=LoadBitmap('C:\Users\Xtensity\Desktop\Schoooo lie\'+T[x]) //Folder Filled with photos to search in.
SetTargetBitmap(Bit)
GetBitmapSize(Bit,w,h)
if FindBitmapTolerance(Screen,p1,p2,60) then //This returns false no matter what
writeln(T[x]);
Freebitmap(Bit)
end;
end.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.