7_2,24位真彩模式(2013-2-27)
2013-02-27 10:43
190 查看
同理,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 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;
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 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;
相关文章推荐
- 颜色模式中8位,16位,24位,32位色彩是什么意思?会有什么区别?计算机颜色格式( 8位 16位 24位 32位色)
- 24位真彩位图转4位(16色)灰度图(BMP) .
- GuiLib1.5 中使用24位真彩图标
- 【数字图像】C++8位和24位BMP位图的平滑、锐化、二值化处理,以及24位真彩图的灰度化
- C++实现24位真彩BMP图平移,镜像,旋转90、180度
- C# 图像处理:将图像(24位真彩)转为 8位灰度图像 采用了内存法,大大提高了效率
- 颜色模式中8位,16位,24位,32位色彩是什么意思?会有什么区别?计算机颜色格式( 8位 16位 24位 32位色)<转>
- 颜色模式中8位,16位,24位,32位色彩是什么意思?会有什么区别?计算机颜色格式( 8位 16位 24位 32位色)【转】
- 32BPP窗口模式下24位位图的像素操作(1)
- 特效天地——淡入淡出(真彩模式)
- bmp位图文件:读取、写入、24位真彩转8位灰度、灰度图的二值化
- 24位真彩位图转4位(16色)灰度图(BMP)
- 24位真彩图转8位灰度图并分解位平面 c-c++实现
- 特效天地——淡入淡出(真彩模式)
- DIB(设备无关位图)编程系列(二)―24位真彩图转256阶(8位)灰度图
- 特效天地——淡入淡出(真彩模式)
- 三分钟解析24位真彩BMP格式文件
- c++图像处理:24位真彩图颜色变换
- 24位真彩图分离三通道以及分解位平面 c-c++实现
- DIB(设备无关位图)编程系列(二)——24位真彩图转256阶(8位)灰度图