首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

怎么用VC++将640*480像素的BMP图像转换成256*256的BMP图像

2012-04-06 
如何用VC++将640*480像素的BMP图像转换成256*256的BMP图像如何用VC++将640*480像素的BMP图像转换成256*256

如何用VC++将640*480像素的BMP图像转换成256*256的BMP图像
如何用VC++将640*480像素的BMP图像转换成256*256的BMP图像
用USB摄像头采集的图像是640*480像素的,是否都需要转换成2的N次幂*2的N次幂的图像呢?如果是将如何转换,最好提供源码,有相关资料网址也可以,谢谢了

[解决办法]
http://www.codeguru.com/cpp/g-m/bitmap/specialeffects/article.php/c4897
Accelerated Smooth Bitmap Resizing
[解决办法]
不需要是2的N次幂, 如果是的话速度快, StretchBlt可以改变图像大小
[解决办法]
在这里http://www.google.com/codesearch搜"StretchBlt"
 或者
参考GDI+的例子

C/C++ code
Image image(L"Apple.gif");UINT width = image.GetWidth();UINT height = image.GetHeight();// Make the destination rectangle 30 percent wider and// 30 percent taller than the original image.// Put the upper-left corner of the destination// rectangle at (150, 20).Rect destinationRect(150, 20, 1.3 * width, 1.3 * height);// Draw the image unaltered with its upper-left corner at (0, 0).graphics.DrawImage(&image, 0, 0);// Draw a portion of the image. Scale that portion of the image// so that it fills the destination rectangle.graphics.DrawImage(   &image,   destinationRect,   0, 0,              // upper-left corner of source rectangle   0.75 * width,      // width of source rectangle   0.75 * height,     // height of source rectangle   UnitPixel);
[解决办法]
楼上的这个graphics.DrawImage(
&image,
destinationRect,
0, 0, // upper-left corner of source rectangle
0.75 * width, // width of source rectangle
0.75 * height, // height of source rectangle
UnitPixel);
相当不错,省了很多事


[解决办法]
可以自己写个双线性插值算法,进行图片的缩放,这样,就能达到楼主的要求了。
[解决办法]
你可以从上个Device Context上面用StretchBlt()或者其他的函数将图像绽放到另一个Device Context上面,这样就成了!试试看!(最好用内在DC).
[解决办法]
进行2的N次幂操作可以进行数据的截断或是在数据的末尾添加0……

热点排行