473,395 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

compare bitmaps

i am trying to see whether one bitmap exists inside another (which is a screen print). i am trying to use memcmp:

Expand|Select|Wrap|Line Numbers
  1. int main() {
  2.  
  3.    HANDLE hBitMap = LoadImage(0, "img.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
  4.  
  5.     BITMAP bitmap;
  6.     GetObject(hBitMap,sizeof(BITMAP),&bitmap);
  7.     int size = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel/8;
  8.  
  9.     BYTE *lpBits = new BYTE[ size ];
  10.  
  11.     GetBitmapBits((HBITMAP)hBitMap,size,lpBits );
  12.  
  13.    HANDLE hBitMap2 = LoadImage(0, "img2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
  14.  
  15.     BITMAP bitmap2;
  16.     GetObject(hBitMap2,sizeof(BITMAP),&bitmap2);
  17.     int size2 = bitmap2.bmHeight*bitmap2.bmWidth*bitmap2.bmBitsPix  el/8;
  18.  
  19.     BYTE *lpBits2 = new BYTE[ size2 ];
  20.  
  21.     GetBitmapBits((HBITMAP)hBitMap2,size2,lpBits2 );
  22.  
  23.     int ScreenWidth = bitmap2.bmWidth;
  24.     int ScreenHeight = bitmap2.bmHeight;
  25.     int numOfCard = 1;
  26.     int cardHeight = bitmap.bmHeight;
  27.     int card_line_length = bitmap.bmWidth;
  28.  
  29.  
  30.     for( int i = 0 ; i < ScreenWidth; i++ ) {
  31.          for( int j = 0 ; j < ScreenHeight; j++ ) {
  32.               for ( int k= 0; k < numOfCard; k++ ) {
  33.                   int tmpY = j;
  34.                   for ( int x = 0; x < cardHeight; x++ ) {
  35.                       if ( memcmp(lpBits2[i][tmpY],lpBits[x],  card_line_length ) != 0 )
  36.                            break; // we didnt find macth of a line
  37.                       tmpY++; // move to next line
  38.                   }
  39.                   if ( x == cardHeight) {
  40.                       cout << "found";     
  41.                   }
  42.               }
  43.          }
  44.     }
  45.  
  46.     system("PAUSE");
  47.     return 0;
  48. }
this is throwing the error at the moment:
invalid types `unsigned char[int]' for array subscript

which corresponds to this line:
memcmp(lpBits2[i][tmpY],lpBits[x], card_line_length )

i don't know what is going on!
Aug 24 '05 #1
3 6230
i have a problems to make a coding to compare 2 images. i am a new person in this subject. so i need help from u to give me the coding. help me
Sep 2 '07 #2
JosAH
11,448 Expert 8TB
i have a problems to make a coding to compare 2 images. i am a new person in this subject. so i need help from u to give me the coding. help me
Please don't hijack this thread. If you want to ask a similar question, better
read the responses posted in this thread or if you really must, start your own
thread but don't just plunge in here.

kind regards,

Jos
Sep 2 '07 #3
JosAH
11,448 Expert 8TB
BYTE *lpBits2 = new BYTE[ size2 ];
...

this is throwing the error at the moment:
invalid types `unsigned char[int]' for array subscript

which corresponds to this line:
memcmp(lpBits2[i][tmpY],lpBits[x], card_line_length )

i don't know what is going on!
the memcmp() function expects two addresses and a length for its parameters.
Have a look at the first parameter: lpBits2 is a pointer to BYTE(s) which is an
address by itself, but lpBits2[i] is a BYTE and lpBits2[i][tmpY] is simply not
a valid indexed expression and most certainly doesn't resolve to an address.

kind regards,

Jos
Sep 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Tamir Khason | last post by:
Assist, I have different images wich I have to compare. Tnx to Bob, did it in unsafe blocks and it even works :) , BUT -> of couse I recieve buffer oveflows often. Checked the code and there is...
1
by: Mark Evans | last post by:
I have a dialog box and on it I want to display a bitmap, which will change at various times during the program. My problem is that the bitmaps will not be the same each time. I want the user to...
3
by: Pete Davis | last post by:
I'm having trouble dealing with bitmaps larger than about 10,000 pixels in either direction. I've tried using DrawImage and DrawImageUnscaled, but both give me out of memory errors. In my...
14
by: Dino M. Buljubasic | last post by:
I would like to be able to compare BackgroundImage Property of two picture boxes on my form. How can I do that? I am using : if (pctOne.BackgroundImage Is pctTwo.BackgroundImage) then //...
0
by: Nikolay Petrov | last post by:
I need to compare to byte values, but one of them may differ from the other by let's say 5%, and they still should count as same. I need a fast method, because i am going to compare a set of about...
2
by: Mike | last post by:
Hello everybody. I am drawing a country map that consists of 149 municipality bitmaps, each around 25 Kb. I draw it onto the in-memory bitmap, then draw it on the picture box. I use C++, but...
3
by: Fir5tSight | last post by:
Hi All, I have two identical PDF files, say file1 and file2. I used an API package to extract the bitmap in each PDF file, say bitmap1 (in file1) and bitmap2 (in file2). Since the bitmaps are...
3
by: grey | last post by:
does anyone suggest me how to write a windows application for comparing two pdf content. The requirement is very easy... i only need to inform user two pdf are differnet, no need to spot where the...
1
by: nkumarin001 | last post by:
Hi, Can anyone help me in this matter:- When i was studying locally managed tablespaces i came across bitmaps that are used in locally managed tablespaces it stated that:- "Locally...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.