我如何获得最后一个DC? C ++ [英] How do I get the last DC? C++

查看:52
本文介绍了我如何获得最后一个DC? C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用以下代码来获取DC的快照并将其转换为位图,但是我的DC上的某些对象会不显示或是黑盒而不是对象。我觉得这里有层次感,有些物品由于某种原因没有被拾取,无论如何要得到最后一个可能包含所有物体的DC?





Hi,

I am using the following piece of code to get a snapshot of the DC and convert it to a bitmap, however some objects on my DC do not show up or are black boxes instead of the objects. I think there is layering going on here and some objects are not getting picked up for some reason, anyway to get the last DC that would have all objects in it?


  HDC hdcScreen;
CDC * dcWindow;

dcWindow = this->GetDC();
CClientDC dc7(this);
CDC         memDC;
//memDC.CreateCompatibleDC(&dc7);
memDC.CreateCompatibleDC(dcWindow);

memDC.SetMapMode(MM_ANISOTROPIC);
memDC.SetViewportExt(2,2);
memDC.SetWindowExt(3,3);

CPreview p;
p.m_Bmp.DeleteObject();
p.m_Bmp.CreateCompatibleBitmap(&memDC,m_lWidth*2/3,m_iHight*2/3);

BITMAP bmpinfo;
p.m_Bmp.GetBitmap(&bmpinfo);
int xb=bmpinfo.bmWidthBytes;

byte *buffer=new byte[xb*m_iHight];
p.m_Bmp.GetBitmapBits(xb*m_iHight,buffer);
for (long i=0;i<xb*m_iHight;i++)
    buffer[i]=0xff;
p.m_Bmp.SetBitmapBits(xb*m_iHight,buffer);


CBitmap* d=memDC.SelectObject(&p.m_Bmp);







谢谢,

Shirzad




Thanks,
Shirzad

推荐答案

确定屏幕坐标中窗口的边界矩形,检索屏幕DC和边界矩形内的像素。这将是创建bitpmap的最顶层DC /像素。
Determine the window's bounding rectangle in screen coordinates, retrieve the screen DC and extra the pixels within the bounding rectangle. This will be the "top most" DC / pixels to create your bitpmap.


这篇关于我如何获得最后一个DC? C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆