April 18, 2024, 05:19:21 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Searching for sprites in images

Started by sapero, August 26, 2007, 08:13:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sapero

This class is capable to find all matching sprites in a bitmap. Input parameters are two images (sprite should be smaller) and starting scan position X and Y.
On return, the x and y are set to coordinates of the first found sprite, next search should be initialized from x+1.

I've also used IStream interface as string placeholder (see class CStringStream for details)

CFastImage image;
CFastImage sprite;
int x=0, y=0;

image.FromFile("image.bmp");
sprite.FromFile("sprite.bmp");
if (image.FindSprite(sprite, &x, &y)) found sprite at x,y

x++;
while (image.FindSprite(sprite, &x, &y)) { found next sprite at x,y; x++;}

pistol350

Regards,

Peter B.