7_2,24位真彩模式(2013-2-27)
来源:互联网 发布:蜂窝移动网络走流量吗 编辑:程序博客网 时间:2024/06/06 20:36
同理,24位为3通道,3字节,但是经过测试,有问题,不支持24位
7_3,32位真彩模式
32位与16位不同之处,32位分为ARGB和XRGB,各8位,ARGB中前8位为透明色,XRGB前8位为了对齐,一般清为0。
#define _RGB32BIT( a, r, g, b ) ( (b ) + ( ( g) << 8 ) + ( (r) << 16) + ( ( a) << 24 ))
inline voidPlot_Pixel_32(intx, int y, int alpha,
intred, 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 (intindex=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(intx, 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 (intindex=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;
- 7_2,24位真彩模式(2013-2-27)
- 保护模式_2
- vi学习_2模式
- Boolan 设计模式_2
- 设计模式_2:策略模式
- 设计模式——策略模式_2
- SEH示例2_2
- 16_2(2)
- 7_2静态数据成员
- 2_2 序列和选择
- jQuery(2_2)层次标签
- 2_2用点集绘制函数
- hadoop进阶2_2.x
- Android_1.5_1.6_2.0_2.1_2.2区别
- 面向模式的软件架构 卷1_2(MVC+PAC)
- 设计模式知识连载(3)---封装_2:闭包
- MAXScript 101_2.7 Naming Scene objects
- LoadRunner学习笔记(脚本开发_2)2
- Android 自定义组合控件View
- Android之MVC模式
- 重定向输出遇到的缓冲问题 .
- ubuntu网络配置
- 6、使用SAX解析xml文档
- 7_2,24位真彩模式(2013-2-27)
- 值得做的北大ACM题
- 在VS2010中引用静态库(以Openssl为例)
- POJ-1144-Network
- vm虚拟机中鼠标点击不起作用
- 【struts2】赵雅智_Struts2中结果集类型
- JS语法
- 第一篇,动机
- 一道简单有趣的C语言面试题