gdi

How to find out DC's dimensions?

心已入冬 提交于 2019-12-03 16:13:11
问题 Let's say I have a handle to device context (naturally, in Windows environment): HDC hdc; How can I get the width and height of it? 回答1: A device context (DC) is a structure that defines a set of graphic objects and their associated attributes, and the graphic modes that affect output. By width and height I'm guessing you are referring to the bitmap painted ? If so then i guess you can try the following : BITMAP structBitmapHeader; memset( &structBitmapHeader, 0, sizeof(BITMAP) ); HGDIOBJ

“Exclusive” DirectDraw palette isn't actually exclusive

Deadly 提交于 2019-12-03 13:39:10
问题 We're maintaining an old video game that uses a full-screen 256-color graphics mode with DirectDraw. The problem is, some applications running in the background sometimes try to change the system palette while the game is running, which results in corrupted graphics. We can (sometimes) detect when this happens by processing the WM_PALETTECHANGED message. A few update versions ago we added logging (just log the window title/class/process name), which helped users identify offending

Why does GetObject return an BITMAP with null bmBits?

会有一股神秘感。 提交于 2019-12-03 12:58:33
Context: I'm trying to take a screenshot of another window to feed it into OpenCV. I found some code on the web that should be able to convert a BITMAP to something OpenCV can work with. Unfortunately I ran into some trouble. Question: Why is the bmBits attribute/member always null? (I also tried with PrintWindow instead of BitBlt the result was the same) #include <iostream> #include <string> #include <Windows.h> int main(int argc, char* argv[]) { std::wstring windowName = L"Calculator"; RECT rect; HWND hwnd = FindWindow(NULL, windowName.c_str()); if (hwnd == NULL) { return 0; } GetClientRect

How to get list of GDI handles

别说谁变了你拦得住时间么 提交于 2019-12-03 12:45:42
问题 I'm trying to write, using DLL injection method, application which displays bitmaps used by another program and I want to get for this specific process list of GDI Handles which it is using (list like in GDIView.exe utility). I found article about NtQuerySystemInformation function, but this description only works with handles to Kernel Objects. Can somebody help? 回答1: Here is a console application code that dumps all GDI handles out for a given process identifier. It should compile and work

Is GDI+ just a layer on top of GDI, or something new?

丶灬走出姿态 提交于 2019-12-03 12:22:57
When GDI+ came out, I remember all the brouhaha about how it was the "new, faster, better" way to display stuff in Windows. But everytime I looked at it, it seemed to me that it was really just a COM wrapper around GDI. Is that true? Or is GDI+ really an independent graphical library that simply shares some paradigms with GDI? Personally, I'm not sure how it could be independent, but I never saw a definite statement one way or another. Ian Boyd Many GDI functions are accelerated by the graphics hardware, and some GDI+ routines may use GDI underneath. But most of GDI+ is independant of GDI. An

Why not use GDI to repeatedly fill a window with RGB data from an array?

寵の児 提交于 2019-12-03 11:31:06
问题 This is a follow-up to this question. I'm currently writing a simple game and am looking for the fastest way to (repeatedly) display an array of RGB data in a Win32 window, without flickering or other artifacts. Several different approaches were recommended in the answers to the previous question, but there was no consensus on which would be the fastest. So, I threw together a test program. The code simply displays a framebuffer on the screen repeatedly, as fast as possible. These are the

How to get the exact text margins used by TextRenderer

会有一股神秘感。 提交于 2019-12-03 10:37:22
问题 System.Windows.Forms.TextRenderer.DrawText method renders formatted text with or without left and right padding depending on the value of the flags parameter: TextFormatFlags.NoPadding - fits the text tightly into the bounding box, TextFormatFlags.GlyphOverhangPadding - adds some left and right margins, TextFormatFlags.LeftAndRightPadding - adds even bigger margins. Now, my question is how can I get the exact amount of padding (left and right) added by DrawText to the text for a given device

Windows screenshot with scaling

巧了我就是萌 提交于 2019-12-03 10:11:21
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: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System

A Generic error occurred in GDI+ in Bitmap.Save method

匿名 (未验证) 提交于 2019-12-03 09:05:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on to upload and save a thumbnail copy of that image in a thumbnail folder. I am using following link: http://weblogs.asp.net/markmcdonnell/archive/2008/03/09/resize-image-before-uploading-to-server.aspx but newBMP.Save(directory + "tn_" + filename); is causing exception "A generic error occurred in GDI+." I have tried to give permission on folder, also tried to use a new separate bmp object when saving. Edit: protected void ResizeAndSave(PropBannerImage objPropBannerImage) { // Create a bitmap of the content of the fileUpload

What is the difference between GDI and GDI+?

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Are there any differences between those two libraries? 回答1: According to the wikipedia article on GDI : With the introduction of Windows XP, GDI was deprecated in favor of its successor, the C++ based GDI+ subsystem. GDI+ adds anti-aliased 2D graphics, floating point coordinates, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG and PNG, and support for composition of affine transformations in the 2D view pipeline . 回答2: GDI+ is an improvement on GDI. It contains features