使用6位高彩模式
来源:互联网 发布:中国失踪儿童最新数据 编辑:程序博客网 时间:2024/05/21 14:45
16位高彩模式:
Alpha.5.5.5---------用D15位存储一个Alpha分量(透明度),其余15位均匀分配给红色、绿色、蓝色。每种色彩产生的变化数位2^5,每个调色板有32*32*32 = 32768种色彩。
X.5.5.5-----这种模式同Alpha.5.5.5类似,只是没有用到MSB(最高位),共32768种色彩。
5.6.5---------这是16位色彩最常用的模式。分6位给绿色,是因为人的眼睛对绿色最为敏感。
算法表示的宏:
// this builds a 16 bit color value in 5.5.5 format (1-bit alpha mode)
#define _RGB16BIT555(r,g,b) ((b & 31) + ((g & 31) << 5) + ((r & 31) << 10))
// this builds a 16 bit color value in 5.6.5 format (green dominate mode)
#define _RGB16BIT565(r,g,b) ((b & 31) + ((g & 63) << 5) + ((r & 31) << 11))
···警告:在建立一个16位模式的演示程序之前,必须强调一个细节:如何检测视频编码格式是5.5.5还是5.6.5。这很重要,因为它不受你控制。
虽然你可以指示DirectDraw创建一个16位模式,但是具体的编码格式还是由硬件决定。(也就是说我们可以创建16位色彩模式,但是具体是5.5.5还是5.6.5是由硬件决定的)
获取像素格式(是5.5.5还是5.6.5捏?):
使用 IDIRECTDRAWSURFACE7::GetPixelFormat()函数;
原型:
HRESULT GetPixelFormat( LPDDPIXELFORMAT lpDDPixelFormat );
Parameters
lpDDPixelFormat
Points to the DDPIXELFORMAT structure which will be filled in with a detailed description of the current pixel and color space format of the surface.
DDPIXELFORMAT为DDSURFACEDESC2结构中的一个数据项
************************************************************************
DDPIXELFORMAT结构中我们最长关心的数据域是:
DWORD dwSize; //the size of the structure ,must be set by you
DOWRD dwFlags;////flags describing the surface
DWORD dwRGBBitCount;////number of bit for Red,Green ,Blue
目前来说最重要的标志:
DDPF_PALETTEINDEXED8-------说明表面采用8位调色板模式
DDPF_RGB-----说明表面采用RGB模式,其格式可以通过测试dwRGBBitCount值获取。
测试代码:
DDPIXELFORMAT ddpixel; ////used to hold info
LPDIRECTDRAWSURFACE7 lpdds_primary; //////assume this is valid
//////clear our structure
memset(&ddpixel, 0 , sizeof(ddpixel));
////set length
ddpixel.dwSize = sizeof(ddpixel);
///make call off surface
lpdds_primary->GetPixelFormat(&ddpixel);
////now perform tests ,check if this is an RGB mode or palettized
if(ddpixel.dwFlags & DDPF_RGB) ///位与,同1异0
{
///RGB mode
////what's the RGB mode
switch(ddpixel.dwRGBBitCount)
{
case 15:{}break;
case 16:{}break;
case 24:{} break;
case 32 :{}break;
}
}////end if
else if(ddpixel.dwlags & DDPF_PALETTEINDEXED8)
{
///256 color palettized mode
}
else
{
///
}
- 使用6位高彩模式
- 6、android单例模式下使用观察者模式
- 【设计模式 6】单例模式和代理模式的结合使用测试
- 使用Observer模式
- 使用Factory Method模式
- 怎样使用设计模式
- hsqldb的模式使用?
- 模式窗口的使用
- 什么时候使用观察者模式
- superclass使用visitor模式
- bridge模式的使用
- 观察者模式使用心得
- singleton 模式使用问题
- 设计模式使用原则
- log4cxx的使用模式
- 设计模式使用心得
- why使用反应器模式
- log4cxx的使用模式
- window.open参数设置及如何全屏显示
- JFrame中setDefaultCloseOperation的参数含义
- 刷Recovery的方法
- web.xml中load-on-startup标签的含义
- 求n以内(不包括n)同时能被3和7整除的所有自然数之和的平方根s,并作为函数值返回,最后结果s输出到文件out.dat中。例如若n为1000时,函数值应为:s=153.909064。
- 使用6位高彩模式
- 简单的DLL注入及代码详解
- 路径设置方法(不用CFiledialog)
- 10亿美金Fab.com的销售秘诀:卖有故事的产品
- 黑马程序员-递归思想,汉罗塔
- GIT详解
- 华盾服务器管理专家在windows server 2008R2 iis7 上安装的注意事项
- 1500: [NOI2005]维修数列
- vc读写Excel的方法,text,copy,paste,value