Archived

This topic is now archived and is closed to further replies.

Scarface5013

counting pixel of one color ??

Recommended Posts

i want to count pixel of one color in a texture. but my code don''t work the value''s in pixel aren''t colors and i don''t know how to go to the next pixel. int CSpriteTexture::CountFoundSprites( void ) { HRESULT Failure; int counter = 0; unsigned int pixel; D3DSURFACE_DESC texDesc; // Höhe und Breite der Texture holen pTexture->GetLevelDesc( 0, &texDesc ); int width = texDesc.Width; int height = texDesc.Height; Failure = pTexture->LockRect( 0, &pLockedRect, NULL, D3DLOCK_READONLY ); for ( int i = 0; i < ( width * height ); i++ ) { memcpy( &pixel, ( BYTE* )pLockedRect.pBits, BYTESPERPIXEL ); if ( pixel == BOARDERCOLOR ) counter++; } Failure = pTexture->UnlockRect( 0 ); return counter; }

Share this post


Link to post
Share on other sites