给个调用StretchDIBits函数 绘制24位位图的代码

bastenf 2006-02-23 07:16:02
最近在练习图像的东西,望各位大虾指点
E-mail bastenf@hotmail.com
...全文
94 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bastenf 2006-02-24
  • 打赏
  • 举报
回复
大虾,那是MSDN上的例子啊,有没有其他的啊
minideveloper 2006-02-24
  • 打赏
  • 举报
回复
For example:

// pvJpgImage points to a buffer containing the JPEG image
// nJpgImageSize is the size of the buffer
// ulJpgWidth is the width of the JPEG image
// ulJpgHeight is the height of the JPEG image
//

//
// Check if CHECKJPEGFORMAT is supported (device has JPEG support)
// and use it to verify that device can handle the JPEG image.
//

ul = CHECKJPEGFORMAT;

if (
// Check if CHECKJPEGFORMAT exists:

(ExtEscape(hdc, QUERYESCSUPPORT,
sizeof(ul), &ul, 0, 0) > 0) &&

// Check if CHECKJPEGFORMAT executed without error:

(ExtEscape(hdc, CHECKJPEGFORMAT,
pvJpgImage, nJpgImageSize, sizeof(ul), &ul) > 0) &&

// Check status code returned by CHECKJPEGFORMAT:

(ul == 1)
)
{
//
// Initialize the BITMAPINFO.
//

memset(&bmi, 0, sizeof(bmi));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = ulJpgWidth;
bmi.bmiHeader.biHeight = -ulJpgHeight; // top-down image
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 0;
bmi.bmiHeader.biCompression = BI_JPEG;
bmi.bmiHeader.biSizeImage = nJpgImageSize;

//
// Do the StretchDIBits.
//

iRet = StretchDIBits(hdc,
// destination rectangle
ulDstX, ulDstY, ulDstWidth, ulDstHeight,
// source rectangle
0, 0, ulJpgWidth, ulJpgHeight,
pvJpgImage,
&bmi,
DIB_RGB_COLORS,
SRCCOPY);

if (iRet == GDI_ERROR)
return FALSE;
}
else
{
//
// Decompress image into a DIB and call StretchDIBits
// with the DIB instead.
//
}

4,445

社区成员

发帖
与我相关
我的任务
社区描述
图形图像/机器视觉
社区管理员
  • 机器视觉
  • 迪菲赫尔曼
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧