7_2,24位真彩模式(2013-2-27)

同理,24位为3通道,3字节,但是经过测试,有问题,不支持24

 

7_3,32位真彩模式

32位与16位不同之处,32位分为ARGBXRGB,各8位,ARGB中前8位为透明色,XRGB8位为了对齐,一般清为0

 

#define _RGB32BIT( a, r, g, b )   ( ( b ) + ( ( g) << 8 ) + ( ( r) << 16) + ( ( a) << 24 ))

 

inline void Plot_Pixel_32(int x, int y, int alpha,

                                     int red, int green, int blue,

                                     UINT  *video_buffer, int lpitch32 )

{

    

     UINT pixel = _RGB32BIT( alpha,red,green,blue);

     video_buffer[x + y*lpitch32] = pixel;

 

}

 

绘制时

     int lpitch32 = (int)(ddsd.lPitch >> 2);

     UINT *video_buffer = ( UINT *)ddsd.lpSurface;

 

     // plot 1000 random pixels with random colors on the

     // primary surface, they will be instantly visible

     for (int index=0; index < 1000; index++)

     {

         // select random position and color for 640x480x16

         int red   = rand()%256;

         int green = rand()%256;

         int blue  = rand()%256;

         int x = rand()%640;

         int y = rand()%480;

 

         // plot the pixel

         Plot_Pixel_32(x,y,0,red,green,blue,video_buffer,lpitch32);      

 

     } // end for index

 

这些都不用多讲,三处更改即可。如下图所示。

下一步封装引擎,加上

#define  SCREEN_BPP                                32

 

#define _RGB32BIT(a,r,g,b) ((b) + ((g) << 8) + ((r) << 16) + ((a) << 24))

 

void DDRAW_Interface::Plot_Pixel_32(int x, int y,

                      int alpha,int red, int green, int blue,

                      UINT *video_buffer, int lpitch32)

{

    

     UINT pixel = _RGB32BIT(alpha,red,green,blue);

 

     video_buffer[x + y*lpitch32] = pixel;

 

}即可。

在绘制时,再调用即可

 

     case 32:

         {

              int lpitch32 = (int)(ddsd.lPitch >> 2);

              UINT *video_buffer = (UINT *)ddsd.lpSurface;

 

              // plot 1000 random pixels with random colors on the

              // primary surface, they will be instantly visible

              for (int index=0; index < 1000; index++)

              {

                   // select random position and color for 640x480x16

                   int red   = rand()%256;

                   int green = rand()%256;

                   int blue  = rand()%256;

                   int x = rand()%640;

                   int y = rand()%480;

 

                   // plot the pixel

                   ddraw->Plot_Pixel_32(x,y,0,red,green,blue,video_buffer,lpitch32);      

 

              } // end for index

 

         }

         break;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值