#1
  1. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0

    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?
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    I assume you are using a GUI library for this as well? What library are you using if so?
  4. #3
  5. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0
    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.
  6. #4
  7. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    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.
  8. #5
  9. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0
    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..
  10. #6
  11. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    hi miagigaim,

    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.

    grim
  12. #7
  13. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0
    cool, i'll have a look! (Python continues to amaze me)
  14. #8
  15. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0
    ok i have

    Code:
    import Image
    im = Image.open("img.bmp")
    f = im.tostring()
    
    print f
    
    raw_input()
    but python crashes! (and yes there is an image there)

    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
  16. #9
  17. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    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.

    grim
  18. #10
  19. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0
    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
  20. #11
  21. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0
    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.

IMN logo majestic logo threadwatch logo seochat tools logo