Jump to content

Two-part question, how to take a "chunk" of pixels on the screen and compare to a "chunk" of pixels from a file


Recommended Posts

Posted

So basically I have a png file with tiles (32x32 icons) and I want to be able to take a 32x32 section of the screen and determine which tile in the file it corresponds to.

Are there built in functions that would let me do this or do I have to write a lot of this from scratch? I suppose what I am after is:

-Read in pixels from (x1, y1) to (x2, y2) from screen
-Read pixels (x1, y1) to (x1, y1) from a file and associate this with some label in a hashtable or something
-Be able to take what I read on screen and look up the corresponding label if one exists

Thanks

Posted

I can't seem to edit my post but what I've done so far is modify it so I've saved off each file as its own .png.

So now I am just looking to compare a section of pixels on-screen to see which file it corresponds to.

Posted

Looks like maybe PixelCheckSum() could be useful here, comparing checksum of a region of pixels, so then it's just a matter of loading in these files and seeing what their checksums are

Posted

Okay so now this problem has boiled down to "get PixelCheckSum of an image file" and while this question has been asked numerous files, nobody seems to have actually come up with a good solution over the years, which doesn't inspire much confidence.

Posted

Why do you need to checksum your files/tiles since you already have checksumed them before ?  I first thought you had a brilliant idea.

I first though you meant that all tiles you want to search for are coming from a screen, right ?  So register the tiles into checksum, save it to a file somewhere and compare checksum from screen with a list of saved numbers (checksums) into a file.

I must admit I thought it was a nice idea.

Or maybe I do not understand what you want to achieve :ermm:

 

Posted
34 minutes ago, Nine said:

Why do you need to checksum your files/tiles since you already have checksumed them before ?  I first thought you had a brilliant idea.

I first though you meant that all tiles you want to search for are coming from a screen, right ?  So register the tiles into checksum, save it to a file somewhere and compare checksum from screen with a list of saved numbers (checksums) into a file.

I must admit I thought it was a nice idea.

Or maybe I do not understand what you want to achieve :ermm:

 

No, what you describe is indeed what I am doing - I just split the tiles off into files because they were a little easier to process individually instead of needing to move things around within one giant image.

Posted

Check out: https://www.autoitscript.com/forum/topic/66545-find-bmp-in-another-bmp-imagesearch

Basically converts your image into a string and uses built-in string matching. Would probably be even easier in your case since you know exactly where the image would be located.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...