Advertisement Jump to content


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


counting pixel of one color ??

This topic is 6178 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!