解决VC中图像缩小失真的问题:利用CDC::SetStretchBltMode
来源:互联网 发布:java怎么定义数组 编辑:程序博客网 时间:2024/05/17 08:43
最近在处理图像放大缩小时,发现使用StretchBlt和StretchDIBitsStretchDIBits函数都有很大的失真问题存在。搜索MSDN(http://msdn.microsoft.com/zh-cn/library/s5a0ksxd(v=VS.80)),发现可以利用
CDC::SetStretchBltMode
函数解决。一般COLORONCOLOR模式典型地用于保留彩色位图中的颜色。int SetStretchBltMode( int nStretchMode );
nStrechMode可以选择下表中的值之一(HALFTONE):
使用消除和现在的像素颜色值进行逻辑与(and)操作运算。如果该位图是单色位图,那么该模式以牺牲白色像素为代价,保 留黑色像素点。
使用消除和现在的像素颜色值进行逻辑或(or)操作运算。
COLORONCOLOR: 删除像素。该模式删除所有消除的像素行,不保留其信息。HALFTONE: 将源矩形区中的像素映射到目标矩形区的像素块中,覆盖目标像素块的一般颜色与源像素的颜色接近。在设置完 HALFTONE拉伸模之后,应用程序必须调用SetBrushOrgEx函数来设置刷子的起始点。如果没有成功,那么会出现刷子没对准的情况。
Parameters
- nStretchMode
Specifies the stretching mode. It can be any of the following values:
Value Description BLACKONWHITE
Performs a Boolean AND operation using the color values for the eliminated and existing pixels. If the bitmap is a monochrome bitmap, this mode preserves black pixels at the expense of white pixels.
COLORONCOLOR
Deletes the pixels. This mode deletes all eliminated lines of pixels without trying to preserve their information.
HALFTONE
Maps pixels from the source rectangle into blocks of pixels in the destination rectangle. The average color over the destination block of pixels approximates the color of the source pixels.
After setting the HALFTONE stretching mode, an application must call the Win32 function SetBrushOrgEx to set the brush origin. If it fails to do so, brush misalignment occurs.
STRETCH_ANDSCANS
Windows 95/98: Same as BLACKONWHITE
STRETCH_DELETESCANS
Windows 95/98: Same as COLORONCOLOR
STRETCH_HALFTONE
Windows 95/98: Same as HALFTONE.
STRETCH_ORSCANS
Windows 95/98: Same as WHITEONBLACK
WHITEONBLACK
Performs a Boolean OR operation using the color values for the eliminated and existing pixels. If the bitmap is a monochrome bitmap, this mode preserves white pixels at the expense of black pixels.
The previous stretching mode. It can be STRETCH_ANDSCANS, STRETCH_DELETESCANS, or STRETCH_ORSCANS.
The bitmap-stretching mode defines how information is removed from bitmaps that are compressed by using the function.
The BLACKONWHITE (STRETCH_ANDSCANS) and WHITEONBLACK (STRETCH_ORSCANS) modes are typically used to preserve foreground pixels in monochrome bitmaps. The COLORONCOLOR (STRETCH_DELETESCANS) mode is typically used to preserve color in color bitmaps.
The HALFTONE mode requires more processing of the source image than the other three modes; it is slower than the others, but produces higher quality images. Also note that SetBrushOrgEx must be called after setting the HALFTONE mode to avoid brush misalignment.
Additional stretching modes might also be available depending on the capabilities of the device driver.
- 解决VC中图像缩小失真的问题:利用CDC::SetStretchBltMode
- SetSTretchBltMode解决图像失真问题
- VC++中StretchBlt图像失真问题的解决办法
- VC++中StretchBlt图像失真问题的解决办法
- 解决位图失真-SetStretchBltMode
- 解决位图失真-SetStretchBltMode
- 关于GDI图像放大缩小StretchBlt显示,图像失真的解决
- 解决StretchBlt()图像失真问题
- VC 解决图片失真问题
- VC解决stretchblt 失真问题
- vc代码显示图像的质量问题,SetStretchBltMode的作用
- SetStretchBltMode函数的问题
- SetStretchBltMode() 防止图片失真
- 关于matlab中图像太大只能缩小显示问题的解决
- mfc中StretchBlt缩放图像失真问题
- mfc中StretchBlt缩放图像失真问题
- 解决使用CImage类的Draw函数在显示图片时引起的图像失真问题
- 图片失真问题的解决方式
- xcode 编译静态库
- linux多线程
- 排序算法的稳定性
- cookie
- DIV覆盖DIV
- 解决VC中图像缩小失真的问题:利用CDC::SetStretchBltMode
- 查找
- Linux的Netfilter框架深度思考-对比Cisco的ACL-
- 今晚计划
- 【转】2011年最佳的 Linux 发行版
- 36.VC(custom)-SetWindowRgn注意点
- J2EE-RBAC权限管理
- 孩子,我首先希望你自始至终都是一个理想主义者
- Linux平台VPN技术概论