双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

如何在控件上绘制已经定义好的BITMAP结构数据

unsounder unsounder 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
希望实现的程序功能主要是读取一个tga文件并转换文件信息到BITMAP结构中。现在我已经把TGA格式数据转换到BITMAP结构中了,但是在空间上看不到绘制结果。绘制方法:
void CPreViewDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CPoint pt;
CSize size;

CRect rect;
GetClientRect(rect);

bitmap.CreateBitmapIndirect(&m_bmpColor);
pt.x = 0;
pt.y = 0;
size.cx = rect.Width();
size.cy = rect.Height();
dc.DrawState(pt,size,&bitmap,DST_BITMAP);
// Do not call CDialog::OnPaint() for painting messages
}
其中m_bmpColor是已经定义过了的BITMAP结构。

如果调用资源里的Bitmap位图就可以显示。
void CPreViewDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here

CPoint pt;
CSize size;
BITMAP Color;
CBitmap bitmap;
CRect rect;
GetClientRect(rect);
bitmap.LoadBitmap(IDB_BITMAP2);

bitmap.GetBitmap(&Color);

pt.x = 0;
pt.y = 0;
size.cx = rect.Width();
size.cy = rect.Height();
dc.DrawState(pt,size,&bitmap,DST_BITMAP);
// Do not call CDialog::OnPaint() for painting messages
}

希望能得到解答
...全文

相关推荐

评论 9
收藏 已收藏
分享
返回顶部
unsounder
图形处理/算法 19,463 成员 50,678 内容