我如何获得最后一个DC? C ++

编程入门 行业动态 更新时间:2024-10-08 14:45:19
本文介绍了我如何获得最后一个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 ++

本文发布于:2023-11-13 03:04:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583248.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何获得   DC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!