16-24 bit fades in DDraw

Started by
13 comments, last by wendieu 22 years ago
If you''re just fading to black.. why not do something like this.. obviously there are more efficient ways of doing this, but at least this will show you exactly what''s going on :o).

you have your pointer to a 16-bit surface, and you''re width/height (unsigned short *Ptr_16Bit,unsigned short width ,height.


  void Fade16(unsigned short *Ptr_16Bit, unsigned short width, unsigned short height){ int x,y; unsigned char r,g,b; for (y=0;y!=height;++y) {  for (x=0;x!=width;++x)  {//Get r,g,b   r = ((*Ptr_16Bit)&31);   g = (((*Ptr_16Bit)>>5)&63);   b = (((*Ptr_16Bit)>>11)&31);   if (r) --r; //Subrtact 1 if not 0!   if (g) --g; //Subrtact 1 if not 0!   if (b) --b; //Subrtact 1 if not 0!   *Ptr_16Bit=(b<<11) + (g<<5) + r; //Set our new value!   ++Ptr_16Bit; //Increment to next value!  } }}  


Billy - BillyB@mrsnj.com
Advertisement
Is there a way to do something like this in 8bpp?
No, Canadians DON'T all live in igloos. They live in one BIG igloo!
Generally fading to black in 8bpp is done by just changing the palette.
I can mail you the code for eight bit if you want me to.
And how can I use gamedev''s search engine?
Forum search:
Click "search" (above and to the right)

Article search:
Go to "Articles & Resources"
Use the Google thingy

This topic is closed to new replies.

Advertisement