I made up this code, but it still isn't working. Can anyone
try to fix
it plase?
private Point findBitmap(Bitmap lt, Bitmap big)
{
BitmapData ltData = lt.LockBits(new Rectangle(0,
0,
lt.Width, lt.Height),
ImageLockMode.ReadWrite,
lt.PixelFormat);
//Format24bppRgb
BitmapData bgData = big.LockBits(new
Rectangle(0, 0,
big.Width, big.Height),
ImageLockMode.ReadWrite,
big.PixelFormat);
System.IntPtr ltScan0 = ltData.Scan0;
System.IntPtr bgScan0 = bgData.Scan0;
int ltStride = ltData.Stride;
int bgStride = bgData.Stride;
int ltWidth = lt.Width * 3;
int bgWidth = big.Width * 3;
unsafe
{
byte* bgp = (byte*)(void*)bgScan0;
byte* ltp = (byte*)(void*)ltScan0;
bool good;
for (int y = 0; y < big.Height -
lt.Height; y++)
{
for (int x = 0; x < bgWidth -
ltWidth; x++)
{
good = true;
for (int yy = 0; yy < lt.Height
&& good; yy++)
{
for (int xx = 0; xx < ltWidth
&& good;
xx++)
{
if (ltp[yy * ltWidth + xx]
!= bgp[(y +
yy) * bgWidth + x + xx])
good = false;
}
}
if (good)
{
big.UnlockBits(bgData);
lt.UnlockBits(ltData);
return new Point((x / 3), (y /
3));
}
}
}
}
big.UnlockBits(bgData);
lt.UnlockBits(ltData);
return new Point();
}
|