August 24th, 2005, 10:46 AM
bitmap in bitmap
i want to load to bitmaps into memory, one represents a poker game window and the other a card
i want to see if the card is present in the larger screen, so how could i go about doing this. is it a case of going through the main picture pixel by pixel and for each check if the line contains a line of the card?
August 24th, 2005, 11:57 AM
I assume you are using a GUI library for this as well? What library are you using if so?
August 24th, 2005, 01:38 PM
i will probly use the win32 functions to get a snapshot of the other programs window at runtime, and then i have my other bitmap in a folder.
August 24th, 2005, 03:51 PM
Hmm. This process could be very difficult. In Python that is. I've never done such a task nor have I needed to. Someone else may be able to help you further.
August 25th, 2005, 03:29 AM
what part of the process are you refering to? getting the window and stuff is easy thanks to the great work from hammond and co. I cannot believe you can call all the win32 api functions! i guess the difficult bit will be going throught the bitmap pixel by pixel, not to mention slow for python. maybe this is a C job..
August 25th, 2005, 04:14 AM
I guess this is an application separate from the poker game?
I would suggest you look at the image manipulation package PIL
A quick look shows it can do all the image manipulation you want. As far as searching for an image within an image how about using the PIL tostring function then doing a search row by row for the sub-bitmap (assuming no other method is available in the PIL library). This would be at C library speed.
August 25th, 2005, 04:49 AM
cool, i'll have a look! (Python continues to amaze me)
August 25th, 2005, 04:59 AM
ok i have
but python crashes! (and yes there is an image there)
im = Image.open("img.bmp")
f = im.tostring()
edit: ok it doesn't crash, just takes ages to load all thoose characters. there are loads of these: ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
isn't python gonna think there the same??
edit2: ok works fine sorry for blabbering
August 25th, 2005, 05:16 AM
It was the print f that took a long time.
You are not interested in what characters are displayed since they the image is binary data not text.
Yes your images will have lots of white and black areas. I don't know how the bitmap is stored in the string but it could be a tuple of three bytes (R,G,B) So I guess each three characters represents one pixel.
This is something you will have to investigate.
August 25th, 2005, 05:17 AM
ok, i now need to get one line from the bitmap. how can i do this? i have had a look at the PIL docs, but cannot find any suitable functions
August 25th, 2005, 05:21 AM
I think i can use im.crop() to get a new image for each line of the sub-bitmap and do it that way, but i can see that doing it this way is gonna take a long time. i wonder if there is a way to extract data for one line from im..
i'll let you know how i get on.