bitblt 可以从一个mfc 内存dcc考贝到另一个mfc 内存dcc吗

ASM或C或C++(207)
//create memory dc
m_memDC.CreateCompatibleDC(pDC);
//如果调用CreateCompatibleBitmap方法用了&m_memDC参数,那就只有两种颜色了(黑跟白)
m_memBitmap.CreateCompatibleBitmap(pDC,paperWidth,paperHeight);
m_memDC.SelectObject(&m_memBitmap);
m_memDC.FillSolidRect(0,0,paperWidth,paperHeight,RGB(255,255,255));
使用上面的代码段建立m_memDC后,就可以对它当作正常CDC实例进行操作了。
使用下面的代码可以把图像从内存映射到设备。
pDestDC-&BitBlt(pDestRect-&left, pDestRect-&top,pDestRect-&Width(),pDestRect-&Height(),
&m_memDC, 0, m_offsetY, SRCCOPY);
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:932809次
积分:12266
积分:12266
排名:第1102名
原创:317篇
转载:35篇
评论:182条
(1)(5)(1)(2)(1)(3)(1)(5)(3)(1)(11)(5)(1)(2)(1)(2)(9)(3)(5)(3)(3)(8)(6)(3)(5)(8)(5)(12)(6)(3)(5)(13)(11)(12)(8)(10)(6)(4)(3)(2)(3)(1)(3)(3)(3)(2)(1)(1)(2)(2)(1)(3)(3)(4)(1)(1)(1)(5)(2)(2)(5)(5)(6)(3)(3)(4)(1)(2)(2)(5)(2)(1)(2)(2)(2)(1)(2)(3)(2)(7)(2)(3)(1)(1)(3)(2)(1)(8)(1)(3)(3)(3)(1)(1)(3)(1)(3)(1)(6)(4)(2)vc中如何用bitblt函数将内存位图分块-VC 内存拷贝函数bitblt问题 _心理观察网
《vc中如何用bitblt函数将内存位图分块 》
vc中如何用bitblt函数将内存位图分块
百度了很久,还是搞不懂。csdn某个人的方法如下:把位图读进内存DC中,然后创建兼容DC和兼容内存位图 用BitBlt函数把你的原位图按分割要求复制到其他内存位图中 取出内存位图的HBITMAP即可以了我也是想这么做的,但是具体不知道要怎么写。完整的位图已经在Cbitmap的对象中了。但是“用BitBlt函数把你的原位图按分割要求复制到其他内存位图中 ”这一句不知道怎么做。关于bitblt函数,我都是从内存中拷贝到屏幕上的,没做过从内存中拷贝的内存中。而且这里的目标内存兼容DC如何创建,传入的HDC hdc应该是哪一个?谢谢。我主要是想将位图分割,然后将数据保存到byte数组中
关于Bitblt函数,从内存中拷贝到内存中,下面的代码可以给你参考:
// 取得窗口客户区域大小
CRect WndR
this-&GetWindowRect ( &WndRect ) ;
this-&ScreenToClient ( &WndRect ) ;
CClientDC cdc(this) ;
mdc, TempD
// 内存DC
BITMAP BmpI
CBitmap ClientBmp, *pOldB
// 创建与设备DC兼容的内存DC
mdc.CreateCompatibleDC ( &cdc ) ;
TempDc.CreateCompatibleDC ( &cdc ) ;
// 创建与设备DC兼容的位图对象
ClientBmp.CreateCompatibleBitmap ( &cdc, WndRect.right, WndRect.bottom ) ;
mdc.SelectObject ( &ClientBmp ) ;
// 依次把位图贴到内存DC
for ( int i = 0; i &= 8; i++ )
TempDc.SelectObject ( &this-&MyBmp[i].bmp ) ;
this-&MyBmp[i].bmp.GetBitmap ( &Bm涪功帝嘉郜黄佃萎顶联pInfo ) ;
if ( i == 0 )
mdc.BitBlt (0, 0, WndRect.Width(), WndRect.Height(), &TempDc, 0, 0, SRCCOPY ) ;
mdc.TransparentBlt ( this-&MyBmp[i].rect.left, \
this-&MyBmp[i].rect.top, BmpInfo.bmWidth, BmpInfo.bmHeight, \
&TempDc, 0, 0, BmpInfo.bmWidth, BmpInfo.bmHeight, RGB(255,255,255) ) ;
// 把内存DC贴到设备DC上
cdc.BitBlt ( 0, 0, WndRect.right, WndRect.bottom, &mdc, 0, 0, SRCCOPY ) ;
// 环境清理
ClientBmp.DeleteObject () ;
mdc.DeleteDC () ;
映射模式:MM_ANISOTROPIC横坐标:往右递增纵坐标:往下递减当原点坐标为(0,0)时,Y坐标如果为正,就跑到窗口上边去了,画的任何东西都是在窗口外面。 -------------------------------------------------------------------------------------内存DC设置了映射模式,设备DC没有设置映射模式。当BitBlt时,需要使用内存DC的每一个点画到设备DC的对应点中,由于两个DC的映射模式不同,所以无法正确对应每一个点。例如坐标为100,50的点,对于内存DC和设备DC而言,不是同一个坐标点。正确的逻辑和序列是:设置设备DC的映射模式,创建内存DC,画图,把内存DC中的图片COPY到设备DC中:尽量使用BitBlt,不要使用StretchBlt进行COPY。原因是:1)StretchBlt进行拉伸需要使用算法,执行速度肯定没BitBlt快2)StretchBlt的拉伸会使图形失真,仔细看下一幅800*600的图片,用StretchBlt拉伸至全屏后,和用Windows自带的图片查看器进行拉伸后比对,就会发现StretchBlt很傻的。3)图片拉伸算法有几个需要考量的指标:第一是尽可能使图片不失真第二是尽可能提高算法的执行速度。一和二之间是此消彼长的关系。要保真就失速度!StretchBlt不如一些专业图像软件做的拉伸效果就是因为StretchBlt并不是专业的图像处理函数,主要为了提高该函数的执行速度,因此会失真。要想不失真,自己写图像算法。因此,基本上没有什么理由使用StretchBlt。附上源代码://以下为设置坐标映射pDC-&SetMapMode(MM_ANISOTROPIC); //X、Y单位长度都自定义的映射模式pDC-&SetWindowOrg(0,0);//设置窗口左上角的坐标为pDC-&SetWindowExt(500,50);//设置窗口度量pDC-&SetViewportOrg(0,0);pDC-&SetViewportExt(rect.right,rect.bottom); mDC.CreateCompatibleDC(pDC);//创建一副关于屏幕DC的图画CBitmap MemB
MemBitmap.CreateCompatibleBitmap(pDC,500, 50); //注意内存位图的大小尺寸设置//保留以前内存,并将这幅图选入到内存DC中CBitmap *pOldBitmap=mDC.SelectObject(&MemBitmap); //以下为画直线CPen PenWave(PS_SOLID,5,RGB(255,0,255));//创建紫色的画笔PenWavemDC.SelectObject(PenWave);mDC.MoveTo(0,0);mDC.LineTo(50,50);//下面将内存DC上所绘内容一次性拷贝到当前DC
pDC-&BitBlt(0,0,500, 50,&mDC,0,0,SRCCOPY);//资源回收mDC.SelectObjec涪功帝嘉郜黄佃萎顶联t(pOldBitmap);/......
请问网速中的b是bit还是Byte?如果是bit,为什么b是大写的? ……
当然是bit了,你从哪里看的Byte这样的写法的,都是byte,为了便于区分,B表示bit,这是规定...
关于VC中的转义字符 ……
所有的ASCII码都可以用“\”加数字(一般是8进制数字)来表示。而C中定义了一些字母前加&\&来表...
字节、位、bit、byte、KB、B、字符之间有什么关系? ……
bit就是位,也叫比特位,是计算机表示数据最小的单位。 byte就是字节,1byte=8bit,1b...
1bit 在计算机里是怎么存储的?怎样的原理? 来高手~! ……
计算机的存储单位:计算机系统数据只用0和1这种表现形式,(这里只表示一个数据点,不是数字),一个0或...
1KB=多少B=多少byte=多少bit ……
1KB=byte=8192bit bit是电脑记忆体中最小的单位,在二进位电脑系...
谁能告诉我1B=多少bit ……
在信息学以及计算机通用的标准中,1B(字节,byte)=8bit(二进制位)。但是有些特殊情况下需要...
请问 byte 与 bit 有什么区别? ……
bit,位 :二进制数系统中,每个0或1就是一个位(bit),是存储信息的最小单位。 Byte,字节...
在vc中怎样截取一部分位图再放大 ……
把StretchBlt的第6、7、8、9参数指定为你需要截取的区域即可。
网速中的1Mb/s中的b是bit还是Byte 而所说的1MB大小的文件的B是Byte还是bit ……
网速中的1Mb/s中的b是bit,而所说的1MB大小的文件的B是Byte。一般说来,小写b是位,而大...
你可能感兴趣的内容?拒绝访问 |
| 百度云加速
请打开cookies.
此网站 () 的管理员禁止了您的访问。原因是您的访问包含了非浏览器特征(37cce208a5016610-ua98).
重新安装浏览器,或使用别的浏览器今天在学习用内存DC画图,终于有了初步了解。现将收集的关于内存DC介绍及其相关操作的资料贴出来共享一下。
我的图书馆
今天在学习用内存DC画图,终于有了初步了解。现将收集的关于内存DC介绍及其相关操作的资料贴出来共享一下。
DC&即Device&Context,是GDI内部的一个资料结构,一个DC会和某个特定的显示设备(如打印机、屏幕等)产生关联。我们如果能取得该DC的handle&那我们便可以在这显示设备上写字、画图。
在Form&或Picturebox中都有一个hdc的属性,指的便是这东西,但是,怎么又会有一个Memory&DC呢?这是一个存在记忆体内的&dc&,它除了不像form&picturebox能将图形、文字显示出来之外,其他的几乎都相同,它也可以用在所有的&GDI&API&呼叫之上,其实我们在VB中早就有使用上这&Memory&DC&了,只是没有自觉。当我们设&form&picturebox的AutoRedraw&=&True时,&hdc所指的便是Momoory&DC,这时我们在其上作绘图动作,都没有显示在form上,这便是先前说的,它只是在记忆体中,不会真的画出图。而我们下&refresh指令时,便是将这MemoryDC上的图,copy到&form/PictureBox上。
  另外我们也可以使用CreateCompatibleDC()&API&它传入一个&hDc&,代表产生的&Memory&DC和&hdc相容,若传0则是与屏幕相容的&Memory&DC&hMemDC&=&CreateCompatibleDC(0)
  这时候,该hMemDC所指的绘图区有多大呢?其实只有一个单色Pixel,直到我们使用SelectObject(&hMemDC,&hBitmap)
  那hMemDC显示区就会有和hBitmap一样的宽度、高度、颜色选择等。&而且我们在hMemDC上的任何绘图,也都会反映在&hBitMap上,也就是说,原本hBitMap所指的图,在SelectObject(hMemDC,&hBitMap)后,我们使用gdi函式在hMemDC上画一条线,那么该hBitmap所指的图也会有一条线了。
那么Memory&DC又有什么作用呢?
我们知道,&在使用VC开发图形相关的应用程序时,常常需要使用MFC的CDC类直接把图形画在窗口上。这通常是通过响应Windows的WM_PAINT消息实现的。如果要画的图形比较复杂,或者比较大,那么画图过程可能会造成窗口的闪烁。当窗口调整大小时,这种闪烁由为明显。
解决窗口闪烁问题的有效办法就是使用内存DC,也称为缓冲DC。在内存中准备一个和窗口DC相同属性的DC,在这个内存DC上执行画图操作。完成画图以后,把画图输出的内容整体复制到目标窗口DC上。因为画图操作不在窗口DC上进行,所以在画图的过程中窗口可以保持原来的内容。当画好的内容被复制到窗口DC时,因为复制操作执行的非常快,所以用户感觉窗口仿佛被立刻被画好,从而消除了从旧画面到白板再到新画面的闪烁现象。
生成内存DC主要用到以下四个函数:
CreateCompatibleDC(CDC*&pDC&)。CDC类的成员函数,用于创建一个和pDC指向的DC兼容的内存DC。
CreateDiscardableBitmap(&CDC*&pDC,&int&nWidth,&int&nHeight)。CBitmap类的成员函数,用于按指定尺寸创建一个和pDC指向的DC兼容的位图。&&&&
SelectObject(CBitmap&*&pBitmap)。CDC类的成员函数,执行以后,所有在该DC上的图像输出都将被画到pBitmap指向的位图上。
BOOL&BitBlt&(int&x,&int&y,&int&nWidth,&int&nHeight,&CDC*&pSrcDC,&int&xSrc,&int&ySrc,&DWORD&dwRop&)。CDC类的成员函数,用于从源DC(pSrcDC)复制一个矩形的图象到当前DC中。
&好了,目前我所能理解到的原理就是上面的样子,下面来看看具体应该怎样操作吧。
对于一个窗口,我们可以用下面的代码来创建内存DC,在内存DC上输出,并最终复制到窗口DC上。
C/C++ code12345678910111213141516171819202122void&PaintWnd(CWnd&*&pWnd){&&&&&CDC&*&pWndDC&=&pWnd-&GetWindowDC();&&&&&CRect&WndRect&=&pWnd-&GetWindowRect();&&&&&CDC&MemDC;&&&&&CBitMap&MemB&&&&&&MemDC.CreateCompatibleDC(pWndDC);&&//&创建内存DC&&&&&MemBitmap.CreateCompatibleBitmap(&&//&创建兼容的位图&&&&&&&&&pWndDC,&&&&&&&&&WndRect.Width(),&&&&&&&&&WndRect.Height());&&MemDC.SelectObject(MemBitmap);&&//&让内存DC输出到位图(我的理解就是选择画布)&&&&&//&使用MemDC画图&&&&&……&&&&pWndDC-&BitBlt(//&从内存DC复制到窗口DC&&&&&&&&&0,0,&&&&&&&&&WndRect.Width(),&&&&&&&&&WndRect.Height(),&&&&&&&&&&MemDC,&&&&&&&&&&0,0,&&&&&&&&&SRCCOPY);}
当然,实际的情况下,我们需要考虑的更多,因为内存DC、位图的创建都可能会失败。为了简化代码,此处定义了一个类CMemoryDC,包装了内存DC创建过程中的出错处理,内存DC的事后清理等操作,并自动复制内存DC的内容到目标DC上。
声明CMemoryDC类的头文件MemoryDC.h如下:
C/C++ code1234567891011121314151617181920#pragma&once&#include&"Afxwin.h"&&&&class&CMemoryDC&{&public:&&&&&&CMemoryDC(CDC&*dc,&RECT&*&rect,bool&autoRender&=&false);&&&&&&~CMemoryDC(void);&&&&&&&&&bool&IsOK();&&&&&&void&Render(CDC&*&p_objectDC&=&NULL);&&&&&&CDC*&GetMemoryDC();&&&&&&operator&CDC&*&();&private:&&&&&bool&m_bAutoR&&CRect&m_DCR&&&CDC*&m_pOriginalDC;&&&&&CDC&m_MemoryDC;&&&&&CBitmap&m_MemoryB};
类的实现文件CMemoryDC.cpp如下:
C/C++ code12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455&#include&".MemoryDC.h"&&&&CMemoryDC::CMemoryDC(CDC&*dc,&RECT&*&rect,&bool&autoRender)&&{&&&&&&&&&&m_bAutoRender&=&autoR&&&&&&m_pOriginalDC&=&&&&&&&if&(dc==NULL&||&rect==NULL)&&&&&&&&&&return;&&&&&&if&(!m_MemoryDC.CreateCompatibleDC(dc))&&&&&&&&&&return;&&&&&&m_DCRect.SetRect(rect-&left,&rect-&top,&rect-&right,&rect-&bottom);&&&&&&&&&if&(!m_MemoryBmp.CreateCompatibleBitmap(dc,&m_DCRect.Width(),&m_DCRect.Height()))&&&&&&&&&&return;&&&&&&m_MemoryDC.SelectObject(m_MemoryBmp);&}&&&&CMemoryDC::~CMemoryDC(void)&&{&&&&&&if&(m_bAutoRender)&&&&&&&&&&Render();&&&&&&if&(m_MemoryDC.m_hDC!=NULL)&&&&&&&&&&m_MemoryDC.DeleteDC();&&&&&&if&(m_MemoryBmp.m_hObject!=NULL)&&&&&&&&&&m_MemoryBmp.DeleteObject();&}&&&&bool&CMemoryDC::IsOK()&&{&&&&&&return&m_MemoryDC.m_hDC!=NULL&&&&m_MemoryBmp.m_hObject&!=&NULL;&&&&}&void&CMemoryDC::Render(CDC&*&p_objectDC)&&{&&&&&&if&(!IsOK())&&&&&&&&&&return;&&&&&&&&&CDC&*&pDC&=&(p_objectDC==NULL&?&m_pOriginalDC&:&p_objectDC);&&&&&&CSize&Size&=&m_MemoryDC.GetViewportExt()&;&&&&&&pDC-&BitBlt(&&&&&&&&&&m_DCRect.left,&&&&&&&&&&&m_DCRect.top,&&&&&&&&&&m_DCRect.Width(),&&&&&&&&&&m_DCRect.Height(),&&&&&&&&&&&m_MemoryDC,&&&&&&&&&&&0,0,&&&&&&&&&&SRCCOPY);&}&CDC*&CMemoryDC::GetMemoryDC()&&{&&&&&&return&&&m_MemoryDC;&}&CMemoryDC::operator&CDC&*&()&&{&&&&&&return&&&m_MemoryDC;}
使用这个类可以大大简化内存DC的创建操作。如果我们在窗口消息WM_PAINT的响应函数中使用内存DC,只要用如下这样简便的代码便可实现:
&C/C++ code123456789CRect&R&GetClientRect(Rect);&CPaintDC&dc(this);&//&device&context&for&painting&&&&&&CMemoryDC&MemDC(&dc,&Rect,&true);&&&&&&if&(MemDC.IsOK())&&&&&&&{&&&&&&&&&&//&使用MemDC画窗口&&&&&&&}&&&&&//&MemDC析构时会自动把图像复制到dc,无需其它操作使用CMemoryDC创建内存DC防止窗口闪烁,编程的代码和不使用内存DC时相比,数量和复杂性几乎没有增加。
另外,关于此文章的word文档我也上传了,需要的朋友可去下载。http://download.csdn.net/source/1381542
相关主题推荐:
相关帖子推荐:
TA的最新馆藏简单学习了下SDK截图显示到DC和存为文件
简单学习了下SDK截图显示到DC和存为文件
编辑:www.fx114.net
本篇文章主要介绍了"简单学习了下SDK截图显示到DC和存为文件",主要涉及到简单学习了下SDK截图显示到DC和存为文件方面的内容,对于简单学习了下SDK截图显示到DC和存为文件感兴趣的同学可以参考一下。
http://p.blog.csdn.net/images/p_blog_csdn_net/vincent_1011/EntryImages//TestBitBlt.jpg下载改为rar格式
截图存为文件那个是直接拿别人的代码
///////////////////////////////////////////
笔记。。。。。。。。。。
&&& HDC hdcScreen = CreateDC(&DISPLAY&, NULL, NULL, NULL);
&&& HDC dctest&&& =&&& ::GetDC(tt.m_hWnd);&&& //GetDC()如果传NULL的话就是取整个显示器的
&&& BitBlt(dctest,
&&& &&& 0,0,
&&& &&& 100, 100,
&&& &&& hdcScreen,
&&& &&& 0,0,
&&&&&&&&&&&&&& SRCCOPY);
上面步骤就可以把显示器的的图显示在tt这个窗口的左上100*100的区域。(MFC测试程序)
有个地方要注意,如果显示器的那部分区域给其它程序窗口覆盖的话,也会一并显示在tt这个窗口上,
可以看得出下面的3-4步是为5步的hdcCompatible能装得下1步创建的DC做准备
截图的话,就是以下步骤:
1,创建一个显示器的DC&&& &&& &&& 使用CreateDC(&DISPLAY&, NULL, NULL, NULL);
2,创建一个兼容显示器的内存DC&&& &&& 使用CreateCompatibleDC(hdcScreen);
3,创建一个兼容显示器的位图对像&&& &&& 使用CreateCompatibleBitmap(1返回值,GetDeviceCaps(hdc, HORZRES),GetDeviceCaps(hdc,
VERTRES));
4,由于2创建的DC还没有GDI对像&&& &&& 使用SelectObject(CompatibleHDC, BmpScreen);把3创建的位图对像选进去,有点像设置
CompatibleHDC这个结构字段的意思
5,这时候就可以把显示器的DC复制到内存的
DC&&& BitBlt(hdcCompatible,
&&&&&&&&&&&&&& 0,0,
&&&&&&&&&&&&&& bmp.bmWidth, bmp.bmHeight,
&&&&&&&&&&&&&& hdcScreen,
&&&&&&&&&&&&&& 0,0,
&&&&&&&&&&&&&& SRCCOPY))
6,这时候图像数据只在内存DC中。用内存DC或者3中返回的位图对像句柄都可以关系到图像信息。要显示的话,可再调用BitBlt把内存DC作为
源复制到需要显示的地方的DC。如果要保存成文件的话,就用3中返回的位图对像
这个只是创建一个位图
HBITMAP CreateCompatibleBitmap(
& HDC hdc,&&&&&&& // handle to DC
& int nWidth,&&&& // width of bitmap, in pixels
& int nHeight&&&& // height of bitmap, in pixels
The color format of the bitmap created by the CreateCompatibleBitmap function matches the color format of the device
identified by the hdc parameter. This bitmap can be selected into any memory device context that is compatible with the
original device.
Note: When a memory device context is created, it initially has a 1-by-1 monochrome bitmap selected into it. If this memory
device context is used in CreateCompatibleBitmap, the bitmap that is created is a monochrome bitmap. To create a color
bitmap, use the hDC that was used to create the memory device context, as shown in the following code:
&&& HDC memDC = CreateCompatibleDC ( hDC );
&&& HBITMAP memBM = CreateCompatibleBitmap ( hDC );
&&& SelectObject ( memDC, memBM );
////////////////////////////////////////////////////////////////
Memory Device Contexts
A memory DC stores images in memory before sending them to an output device. This allows you to treat a portion of memory as
a virtual device. Create a memory DC for a device by calling the CreateCompatibleDC function and supplying a handle to the DC
of the device. When you call CreateCompatibleDC, Windows CE creates a temporary monochrome bitmap that is 1 pixel by 1 pixel.
Then it selects the bitmap into the DC. Before you begin drawing with this DC, use SelectObject to select a bitmap with the
appropriate width and height into the DC. Then you can use the DC to store images.
Windows CE does not support writable memory DCs. The functionality described here is for use in loading bitmaps and
transferring them to surfaces in DirectDraw.
==========================================================================================================
Capturing an Image
You can use a bitmap to capture an image, and you can store the captured image in memory, display it at a different location
in your application's window, or display it in another window.
In some cases, you may want your application to capture images and store them only temporarily. For example, when you scale
or zoom a picture created in a drawing application, the application must temporarily save the normal view of the image and
display the zoomed view. Later, when the user selects the normal view, the application must replace the zoomed image with a
copy of the normal view that it temporarily saved.
To store an image temporarily, your application must call CreateCompatibleDC to create a DC that is compatible with the
current window DC. After you create a compatible DC, you create a bitmap with the appropriate dimensions by calling the
CreateCompatibleBitmap function and then select it into this device context by calling the SelectObject function.
After the compatible device context is created and the appropriate bitmap has been selected into it, you can capture the
image. The BitBlt function captures images. This function performs a bit block transfer & that is, it copies data from a
source bitmap into a destination bitmap. However, the two arguments to this function are not bitmap handles. Instead, BitBlt
receives handles that identify two device contexts and copies the bitmap data from a bitmap selected into the source DC into
a bitmap selected into the target DC. In this case, the target DC is the compatible DC, so when BitBlt completes the
transfer, the image has been stored in memory. To redisplay the image, call BitBlt a second time, specifying the compatible
DC as the source DC and a window (or printer) DC as the target DC.
The following example code, from an application that captures an image of the entire desktop, creates a compatible device
context and a bitmap with the appropriate dimensions, selects the bitmap into the compatible DC, and then copies the image
using the BitBlt function.
// Create a normal DC and a memory DC for the entire screen. The
// normal DC provides a &snapshot& of the screen contents. The
// memory DC keeps a copy of this &snapshot& in the associated
// bitmap.
hdcScreen = CreateDC(&DISPLAY&, NULL, NULL, NULL);
//个人理解:为显示器创建一个内存DC
hdcCompatible = CreateCompatibleDC(hdcScreen);
// Create a compatible bitmap for hdcScreen.
//个人理解:创建一个兼容hdcScreen的位图,注意:返回值是位图类型的
hbmScreen = CreateCompatibleBitmap(hdcScreen,
&&&&&&&&&&&&&&&&&&&& GetDeviceCaps(hdcScreen, HORZRES), //Width, in millimeters, of the physical screen.
&&&&&&&&&&&&&&&&&&&& GetDeviceCaps(hdcScreen, VERTRES));
if (hbmScreen == 0)
&&& errhandler(&hbmScreen&, hwnd);
// Select the bitmaps into the compatible DC.
//个人理解:给这个内存DC设置像素,这个像素在上面创建hbmScreen的时候指定了,(因为CreateCompatibleDC创建出来的内存DC貌似是默认
//的1 pixel by 1 pixel
//这个SelectObject的作用:specifying the height, width, and color organization required.
//前面也说过DC只是一个数据结构,可以把这个函数想像成给DC结构的各个成员赋值
if (!SelectObject(hdcCompatible, hbmScreen))
&&& errhandler(&Compatible Bitmap Selection&, hwnd);
&&&&&&& // Hide the application window.
&&&&&&& ShowWindow(hwnd, SW_HIDE);
&&&&&&&& //Copy color data for the entire display into a
&&&&&&&& //bitmap that is selected into a compatible DC.
&&&&&&& if (!BitBlt(hdcCompatible,
&&&&&&&&&&&&&& 0,0,
&&&&&&&&&&&&&& bmp.bmWidth, bmp.bmHeight,
&&&&&&&&&&&&&& hdcScreen,
&&&&&&&&&&&&&& 0,0,
&&&&&&&&&&&&&& SRCCOPY))
&&&&&&& errhandler(&Screen to Compat Blt Failed&, hwnd);
&&&&&&& // Redraw the application window.
&&&&&&& ShowWindow(hwnd, SW_SHOW);
=========================================================================================
本站评论功能暂时取消,后续此功能例行通知。
本文标题:
本页链接:

我要回帖

更多关于 内存双通道dc模式 的文章

 

随机推荐