|
bitmap comparison |
Neil Walker
Member #210
April 2000
|
Hello,
Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Tobias Dammers
Member #2,604
August 2002
|
For a single comparison of arbitrary bitmaps, no. --- |
Evert
Member #794
November 2000
|
Quote: In many cases, you can use direct access through the line pointers of the BITMAP struct. For lower color depths, this means that you can compare 2 or 4 pixels at once. Best to use libc's memcmp in that case; that will probably compare memory areas in the most optimal way already. |
Tobias Dammers
Member #2,604
August 2002
|
Good point. --- |
Johan Halmén
Member #1,550
September 2001
|
But bitmaps might have some undefined bytes, like padding bytes in the end of a row, which might be different, even if the bitmaps are equal. memcmp() might make you believe they are different. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
Evert
Member #794
November 2000
|
Quote: But bitmaps might have some undefined bytes, like padding bytes in the end of a row, which might be different, even if the bitmaps are equal. memcmp() might make you believe they are different. Not if you tell it to only compare to the end of the line... |
Neil Walker
Member #210
April 2000
|
I've wrote a program - don't know if there's one already, but mine's better that takes in a bitmap file (e.g. a map of a game/screen/etc), extracts all the tiles, saves the unique ones out (resizing if you want it to) and generates a simple map file/array of the tile map. I'll post it to the depot later if anyone's interested. I just wanted to get it to go a bit faster, so I'll try the memcpy. At the minute a 16x16 tiled bitmap of a bitmap of 3000x400 pixels takes about 20 seconds, which isn't that bad considering it's not a real-time game or anything. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Indeterminatus
Member #737
November 2000
|
If you don't want to compare two bitmaps for their exact identity, but say find out how similar they are, there are better approaches. Not intending to sound vague, I don't want to force the information on you, and I also don't want to write long posts risking noone's even interested. edit: And I did well not to spit out all the drivel. After re-reading your last post I can see now it would have been pointless. Leaving the original post for archiving purposes, even though it isn't helpful in any way. _______________________________ |
Richard Phipps
Member #1,632
November 2001
|
Neil: I did this once as well. But the code is now lost in the mists of time.. |
Maikol
Member #4,997
September 2004
|
Maybe this? Comparing byte by byte, p1 and p2 will go over their memory starting at [0,0], the begining; if the memory pointed to is different 0 is returned. If all matches, while loop ends and 1 is returned. The while condition means: while p1 points into a zone of memory in b1 (of course b1 and b2 must have equal h and w, so no matter what bitmap you use), go on. The &b1->line[b1->w * b1->h * 24] is the latest position of the bitmap isn't it?
El sabio no dice todo lo que piensa, pero siempre piensa todo lo que dice |
Richard Phipps
Member #1,632
November 2001
|
Shouldn't that be != ? |
Neil Walker
Member #210
April 2000
|
Quote: Neil: I did this once as well. But the code is now lost in the mists of time.. Yeah, but mine works I'll try that sample out and see if it's any faster. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Richard Phipps
Member #1,632
November 2001
|
Neil Walker
Member #210
April 2000
|
Quote: Maybe this? It doesn't work and it's no faster. I'll just leave it using the getpixel code thanks anyway. It's not finished yet and just a windows binary, but There are two maps in the zip, the config out of the box is for the last 10 or so rows of Marauder. Just change the offsets if you want to do the whole map. If you do Rex (it's just two screens), change the tile size to 8 pixels and offsets to 0. All outputs go to the 'extract' directory. I plan on making it save to map/fmp format for Mappy as well. Delete the 'extract' directory before you run each as it won't do it for you. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
|