Jump to content
  • Advertisement

Archived

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

DragonRider

Need help with alphablending

This topic is 6914 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

Hi, I have tried everything (that I tought could work) but I always get the bad colors (but the general shape of the sprite is OK) with this 5-5-5 16 bit alphablending funtion. Anybody could help? // Initialize the pointers to the first pixel in the rectangle lpSprite += (srcRect.top * SpritePitch) + (srcRect.left * 2); lpDest += (lDestY * dPitch) + (lDestX * 2); // Set the horizontal padding sbuf = (WORD)(SpritePitch - (2 * width)); dbuf = (WORD)(dPitch - (2 * width)); y = height; do { x = width; do { SourcePixel = *((WORD*)lpSprite); if ( SourcePixel != ColorKey ) { DestPixel = *((WORD*)lpDest); sr = (SourcePixel >> 10) & 31; dr = (DestPixel >> 10) & 31; sg = (SourcePixel >> 5) & 31; dg = (DestPixel >> 5) & 31; sb = SourcePixel & 31; db = DestPixel & 31; RED = (((sr - dr) * ALPHA) >> 8) + dr; GREEN = (((sg - dg) * ALPHA) >> 8) + dg; BLUE = (((sb - db) * ALPHA) >> 8) + db; Result = (RED<<10) / (GREEN<<5) / BLUE; *(WORD*)lpDest = Result; } lpDest += 2; lpSprite += 2; }while (--x > 0); lpDest += dbuf; lpSprite += sbuf; }while (--y > 0); (all variables are WORDs, sould I use DWORDs?) Thank you very much if you can tell me what''s wrong with this!! Have a good day

Share this post


Link to post
Share on other sites
Advertisement
What type are your sr, dr, sg .... If they are an unsigned type then you will have issues if the destination color channels are larger then the source. Also, are you totaly sure that your video card is 5-5-5 when is runs in 16bpp mode? You might have a 5-6-5 16bpp card.

... I just read the end of your post! try using signed variables or take a look at my article:

http://www.gamedev.net/reference/programming/features/mmxblend/


hebertjo

Share this post


Link to post
Share on other sites
In fact, I am tring to fix the 5-5-5 branch of code in your non-MMX alphablending function but I can''t get it to work, even processing one pixel at a time. i have tried with long variables, but it still does not work...

Do you think you can fix the function for me? I should not be a big thing!

Thank you for your help

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!