MFC中显示一张位图
1、用类CBitmap加载位图
2、创建内存DC, 将位图选进此内存DC
3、调用BitBlt将内存DC的内容拷贝到其它DC(通知是显示DC)
例子(来自MSDN):
// This OnDraw() handler loads a bitmap from system resources,
// centers it in the view, and uses BitBlt() to paint the bitmap
// bits. void CBlat2View::OnDraw(CDC* pDC)
{
CBlat2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc); // load IDB_BITMAP1 from our resources
CBitmap bmp;
if (bmp.LoadBitmap(IDB_BITMAP1))
{
// Get the size of the bitmap
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo); // Create an in-memory DC compatible with the
// display DC we're using to paint
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC); // Select the bitmap into the in-memory DC
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp); // Find a centerpoint for the bitmap in the client area
CRect rect;
GetClientRect(&rect);
int nX = rect.left + (rect.Width() - bmpInfo.bmWidth) / ;
int nY = rect.top + (rect.Height() - bmpInfo.bmHeight) / ; // Copy the bits from the in-memory DC into the on-
// screen DC to actually do the painting. Use the centerpoint
// we computed for the target offset.
pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,
, , SRCCOPY); dcMemory.SelectObject(pOldBitmap);
}
else
TRACE0("ERROR: Where's IDB_BITMAP1?\n");
}
MFC中显示一张位图的更多相关文章
- MFC中显示 .bmp格式的位图
最近在看VisualC++ 图像处理的书籍,表示一直在从基础做起,今天就记录一个简单功能的实现,显示.bmp格式的位图. 首先需要理解的是窗口创建的过程包括两个步骤:首先擦除窗口的背景,然后在对窗口进 ...
- [OpenCV笔记]0.OpenCV中显示多张图像
摘要 本文主要介绍OpenCV中同时显示多张IplImage图像的方法(C++形式的多图显示需要修改,用vector<Mat>可能比较方便),有点类似MATLAB中的subplot,只是暂 ...
- Android WebView中显示一张或多张图片
最近需要在平板中显示多张图片,调查了下,决定用WebView(说实话,我还不清楚有没有其他android控件能够显示多张图片的.....), 主要是用HTML的img来显示多张图片. google百度 ...
- 在MFC中显示图片(opencv Mat类型)
1,在MFC窗体中添加picture control控件,并添加对应的变量名 2,在窗体的初始化窗口中添加: namedWindow(); HWND hWnd = (HWND)cvGetWindowH ...
- 在MFC中显示cmd命令行
添加函数 void InitConsoleWindow1() { ; FILE* fp; AllocConsole(); nCrt = _open_osfhandle((long)GetStdHand ...
- 如何在VC中显示透明背景位图
简单的调用系统API. Windows NT/2000/XP: Included in Windows 2000 and later.Windows 95/98/Me: Included in Win ...
- java与MFC中的一些常识
一个.java文件中可以有很多类.不过注意以下几点:1.public 权限的类只能有一个(也可以一个都没有,但最多只有1个)2.这个.java文件的文件名必须是public类的类名(一般的情况下,这里 ...
- duilib进阶教程 -- 在MFC中使用duilib (1)
由于入门教程的反响还不错,因此Alberl就以直播的形式来写<进阶教程>啦,本教程的前提: 1.请先阅读<仿迅雷播放器教程> 2.要有一定的duilib基础,如果还没,请先阅读 ...
- MFC对话框中显示BMP,JPG图片
//************************************ // 方法说明: 显示JPG和GIF.BMP图片 // 参数说明: CDC * pDC 设 ...
随机推荐
- 【springcloud】使用@FEIGNCLIENT时,报JAVA.LANG.NOCLASSDEFFOUNDERROR: FEIGN/FEIGN$BUILDER错
引用地址:http://www.cnblogs.com/ellacan/p/8822374.html 错误信息: Caused by: java.lang.ClassNotFoundException ...
- talkingdata比赛分析
1.kaggle数据分析经验: https://medium.com/unstructured/how-feature-engineering-can-help-you-do-well-in-a-ka ...
- 记一次CDH修改IP
因机房服务器搬迁,需要修改CDH ip ,集群中有6台服务器. 其中配置了ldap,其中卡在了ldap中的坑太深,所以记录一下. 一.服务器IP等地址修改 1.首先在安装cloudera-manage ...
- 百科知识 .e,.ec文件如何打开
1 .e是易语言源文件,你可以从以下网址下载e语言编程环境: http://www.xiazaiba.com/html/409.html 2 安装之后会自动关联.e文件. 3 打开一个e语言文 ...
- byte 单位换算
1G就1GB啦,平时人们说1G只是简洁来说而已. bit(位).B(字节).K(千).M(兆).G(吉咖).T(太拉) B(Byte).KB(KiloByte).MB(MegaByte).GB(Gig ...
- update tableView contenSize
NSIndexPath *messageIndexPath = [NSIndexPath indexPathForRow:afterRowCount-1 inSection:0]; [self. ...
- hdu 5316 Magician 线段树
链接:http://acm.hdu.edu.cn/showproblem.php? pid=5316 Magician Time Limit: 18000/9000 MS (Java/Others) ...
- muduo::Connector、TcpClient分析
Connector TcpClient Connector Connector用来发起连接. 在非堵塞网络中,主动发起连接比被动接收连接更为复杂,由于要考虑错误处理,还要考虑重试. 主要难点在于 1. ...
- kubernetes调度之污点(taint)和容忍(toleration)
系列目录 节点亲和性(affinity),是节点的一种属性,让符合条件的pod亲附于它(倾向于或者硬性要求).污点是一种相反的行为,它会使pod抗拒此节点(即pod调度的时候不被调度到此节点) 污点和 ...
- angular 绑定数据时添加HTML标签被识别的问题
由于安全性,angular本身会对绑定的HTML标签属性进行转义,所以有些情况下我们需要用到绑定的数据里面传入html标签的时候, 需要用到一个服务:$sce $sce 服务下面的一个 $sce.tr ...