memcmp & bitmaps
-
i am trying to find an instance of a small bitmap in a screen grab of a window. so far i have managed to load both bitmaps into two BYTE arrays. I found some code which searches through the bitmaps and uses memcmp to see if the smaller one is present in the larger. the trouble is, i am having trouble with the memcmp function: memcmp(ScreenBmp[i][tmpY],CardBmp[x], card_line_length ) What should ScreenBmp and CardBmp represent. I have the two bitmaps in BYTE buffer arrays, so how can i get them into the format above. The code i used to get them into these arrays is below: HANDLE hBitMap = LoadImage(0, "img.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); BITMAP bitmap; GetObject(hBitMap,sizeof(BITMAP),&bitmap); int size = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel/8; /// cout << bitmap.bmHeight << endl; BYTE *lpBits = new BYTE[ size ]; GetBitmapBits((HBITMAP)hBitMap,size,lpBits ); //delete []lpBits; HANDLE hBitMap2 = LoadImage(0, "img2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); BITMAP bitmap2; GetObject(hBitMap2,sizeof(BITMAP),&bitmap2); int size2 = bitmap2.bmHeight*bitmap2.bmWidth*bitmap2.bmBitsPixel/8; /// cout << bitmap.bmHeight << endl; BYTE *lpBits2 = new BYTE[ size2 ]; GetBitmapBits((HBITMAP)hBitMap2,size2,lpBits2 ); cheers!
-
i am trying to find an instance of a small bitmap in a screen grab of a window. so far i have managed to load both bitmaps into two BYTE arrays. I found some code which searches through the bitmaps and uses memcmp to see if the smaller one is present in the larger. the trouble is, i am having trouble with the memcmp function: memcmp(ScreenBmp[i][tmpY],CardBmp[x], card_line_length ) What should ScreenBmp and CardBmp represent. I have the two bitmaps in BYTE buffer arrays, so how can i get them into the format above. The code i used to get them into these arrays is below: HANDLE hBitMap = LoadImage(0, "img.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); BITMAP bitmap; GetObject(hBitMap,sizeof(BITMAP),&bitmap); int size = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel/8; /// cout << bitmap.bmHeight << endl; BYTE *lpBits = new BYTE[ size ]; GetBitmapBits((HBITMAP)hBitMap,size,lpBits ); //delete []lpBits; HANDLE hBitMap2 = LoadImage(0, "img2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); BITMAP bitmap2; GetObject(hBitMap2,sizeof(BITMAP),&bitmap2); int size2 = bitmap2.bmHeight*bitmap2.bmWidth*bitmap2.bmBitsPixel/8; /// cout << bitmap.bmHeight << endl; BYTE *lpBits2 = new BYTE[ size2 ]; GetBitmapBits((HBITMAP)hBitMap2,size2,lpBits2 ); cheers!