PixelData Struct
Code: Select all
struct PixelData {
int x;
int y;
D3DCOLOR color;
};
Code: Select all
surface = new PixelData[height * width];
if(colorkey) {
unsigned int index = 0;
for( unsigned int y = 0; y < bitmap.GetHeight(); y++ )
{
for( unsigned int x = 0; x < bitmap.GetWidth(); x++ )
{
bitmap.GetPixel( x,y,&pixel );
if(D3DCOLOR_ARGB( pixel.GetA(),pixel.GetR(),pixel.GetG(),pixel.GetB() ) != colorkey) {
PixelData c;
c.x = x;
c.y = y;
c.color = D3DCOLOR_ARGB( pixel.GetA(),pixel.GetR(),pixel.GetG(),pixel.GetB() );
surface[index] = c;
}
}
}
}
My only idea is that i can do another loop first to check how many pixels there will be but i think that there is probably a much better solution, so any ideas would be appreciated