gdi

Windows screenshot with scaling

北城余情 提交于 2020-01-01 01:25:19
问题 I am trying to take screenshots of every screen on my windows 10 machine. My system has 2 monitors which are of multiple DPIs. My primary monitor has "scale and layout" set to 200%. My secondary has "scale and layout" set to 100%. I am trying to use C# to take a screenshot of every single monitor. However my scaled monitor is reporting the wrong coordinates: Everything is halved. As a result, the primary monitor's screenshot is only 1/4th of the screen area (width/2,height/2). Here is my code

GDI 总结三: CImage类使用

我只是一个虾纸丫 提交于 2020-01-01 01:23:53
前言 CImage类是基于GDI+的。可是这里为什么要讲归于GDI? 主要是基于这种考虑: 在GDI+环境中,我们能够直接使用GDI+ ,没多少必要再使用CImage类 可是,假设再GDI环境中,我们要想使用GDI+,有点麻烦。还得增加头文件。增加启动GDI+的代码和关闭GDI+的代码,显得太罗嗦了。GDI 的CBitmap 处理功能又有局限,仅仅能处理BMP格式的图片。 怎么办?这时。我们便可使用CImage类,由于这个类本身封装了GDI+得使用环境,所以无需我们手动设置,简化了我们的操作。 同一时候。又能够利用GDI+中强大的图片处理功能,及能够简便的与CBitmap对象进行转换 ,大慷慨便了在GDI环境下。进行各种图片处理工作 。 事实上,将其称作 GDI/ GDI+ 混合编程,这样才更确切些。 为什么引入CImage类? CBitmap 类仅仅能处理BMP格式的图片,很受限。 而CImage能够处理JPGE GIF BMP PNG多种格式图片,扩展了图片处理功能 且能与CBitmap 进行转换( 由于所加载的位图句柄都是HBITMAP,所以可相互转换),因此引入CImage类进行图像处理 CImage provides enhanced bitmap support, including the ability to load and save images in JPEG

Is it possible to BitBlt directly from a GDI+ bitmap?

試著忘記壹切 提交于 2019-12-31 23:10:32
问题 Is it possible to use BitBlt to copy directly out of a GDI+ bitmap without using GetHBitmap? GetHBitmap is slow because it makes a new copy of the whole image, in addition to and slower than the BitBlt copy, and the given HBITMAP must be disposed. The image is large. Is there a way to point BitBlt to use the pixel data of the original GDI+ image? EDIT: I can get a pointer to where the GDI+ bitmap pixel data is in the memory. Can I create an HBITMAP that points to the GDI+ bitmap pixel data to

Is it possible to BitBlt directly from a GDI+ bitmap?

混江龙づ霸主 提交于 2019-12-31 23:10:06
问题 Is it possible to use BitBlt to copy directly out of a GDI+ bitmap without using GetHBitmap? GetHBitmap is slow because it makes a new copy of the whole image, in addition to and slower than the BitBlt copy, and the given HBITMAP must be disposed. The image is large. Is there a way to point BitBlt to use the pixel data of the original GDI+ image? EDIT: I can get a pointer to where the GDI+ bitmap pixel data is in the memory. Can I create an HBITMAP that points to the GDI+ bitmap pixel data to

Drawing polygon with more than one hole?

女生的网名这么多〃 提交于 2019-12-31 03:07:06
问题 I'm trying to draw a polygon with more than one holes. I tried the following code and it does not work correctly. Please advise. PointF[] mypoly = new PointF[6 + 5 + 5]; mypoly[0] = new PointF(0, 0); mypoly[1] = new PointF(100, 0); mypoly[2] = new PointF(100, 100); mypoly[3] = new PointF(0, 100); mypoly[4] = new PointF(10, 80); mypoly[5] = new PointF(0, 0); mypoly[6] = new PointF(10, 10); mypoly[7] = new PointF(10, 20); mypoly[8] = new PointF(20, 20); mypoly[9] = new PointF(20, 10); mypoly[10

Creating 8bpp bitmap with GDI and saving it as a file

孤人 提交于 2019-12-30 11:28:27
问题 I have a perfectly working code that creates 32bpp bitmap and I need to change it so that 8bpp bitmap is created. Here's the piece of code that creates 32bpp bitmap, draws into it, then it creates a bitmap file and store it into the vector of bytes: // prepare bitmap: BYTE* bitmap_data = NULL; HDC hDC = GetDC(NULL); HDC memHDC = CreateCompatibleDC(hDC); BITMAPINFO bmi; memset(&bmi, 0, sizeof(BITMAPINFO)); bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth = desiredWidth; /

How to draw a selectable line?

不打扰是莪最后的温柔 提交于 2019-12-30 10:53:08
问题 I want to create an application which the user is able to manipulate the line he draw. Something like Deleting the line or Selecting it. How should I do that? Thanks in advance I managed to do it using a hard coded rectangle. But I don't still have an idea how to do it using the drawLine() Can I use drawPath to do the hit test? Here is the code: private bool selectGraph = false; private Rectangle myrec = new Rectangle(50, 50, 100, 100); private Graphics g; private void panel1_Paint(object

How to detect what window/control is at a specific point onscreen?

 ̄綄美尐妖づ 提交于 2019-12-30 10:04:12
问题 Is there a Win32 API call to determine what window and/or control is visible at a certain coordinates and/or under the mouse? 回答1: You can use GetWindowFromPoint. It will return the window handle so you can than use GetClassName function to see which control it is. here is an example: http://support.microsoft.com/kb/112649 回答2: Use the WindowFromPoint , ChildWindowFromPoint or ChildWindowFromPointEx Win32 functions. 来源: https://stackoverflow.com/questions/1236412/how-to-detect-what-window

How to detect what window/control is at a specific point onscreen?

故事扮演 提交于 2019-12-30 10:04:06
问题 Is there a Win32 API call to determine what window and/or control is visible at a certain coordinates and/or under the mouse? 回答1: You can use GetWindowFromPoint. It will return the window handle so you can than use GetClassName function to see which control it is. here is an example: http://support.microsoft.com/kb/112649 回答2: Use the WindowFromPoint , ChildWindowFromPoint or ChildWindowFromPointEx Win32 functions. 来源: https://stackoverflow.com/questions/1236412/how-to-detect-what-window

Drawing video with text on top

拥有回忆 提交于 2019-12-30 08:54:28
问题 I am working on an application and I have a problem I just cant seem to find a solution for. The application is written in vc++. What I need to do is display a YUV video feed with text on top of it. Right now it works correctly by drawing the text in the OnPaint method using GDI and the video on a DirectDraw overlay. I need to get rid of the overlay because it causes to many problems. It wont work on some video cards, vista, 7, etc. I cant figure out a way to complete the same thing in a more