gdi

Is there any way to draw Webbrowser content to a specific DC?

依然范特西╮ 提交于 2019-12-01 11:18:29
These days, I tries to create a hiden WebBrowser control in my program, and Using the IViewObject interface draw to my custom DC. The result is fine, I got All the content I want, but the Draw speed is unacceptable, especially some complex web pages which contains Flash objects, Each Draw to DC cost more than 100 ms . So the flash object I drew is not smooth. Is there a fast way to draw the control to my a specific DC? my code sinpet is like this: //hCompDc is a CompatibleDC which select a CompatibleBitmap. RECTL imageRect = {0, 0, nWidth, nHeight}; pHtmlDocument2->QueryInterface(IID

Does TextBox use GDI or GDI+

巧了我就是萌 提交于 2019-12-01 11:09:12
问题 Basically, I want to measure the text size in a TextBox, and I found out that TextRenderer gives me the correct values, while Graphics would give me wrong values. So that seems like TextBox should be using GDI to draw text, right? However, wherever I read, I see that it's supposed to use GDI+. For example: Here http://microsoft.public.dotnet.framework.windowsforms.controls.narkive.com/yoHKjPut/text-rendering-accuracy-problem-in-textbox-richtextbox it says that TextBox and Buttons use GDI+.

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

点点圈 提交于 2019-12-01 10:56:01
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; // desiredWidth is 800 bmi.bmiHeader.biHeight = desiredHeight; // desiredHeight is 202 bmi.bmiHeader

Is there any way to draw Webbrowser content to a specific DC?

馋奶兔 提交于 2019-12-01 09:16:35
问题 These days, I tries to create a hiden WebBrowser control in my program, and Using the IViewObject interface draw to my custom DC. The result is fine, I got All the content I want, but the Draw speed is unacceptable, especially some complex web pages which contains Flash objects, Each Draw to DC cost more than 100 ms . So the flash object I drew is not smooth. Is there a fast way to draw the control to my a specific DC? my code sinpet is like this: //hCompDc is a CompatibleDC which select a

How to draw a selectable line?

青春壹個敷衍的年華 提交于 2019-12-01 08:36:24
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 sender, PaintEventArgs e) { SolidBrush sb = new SolidBrush(Color.Blue); Pen p = new Pen(Color.Blue, 5); e

Set image meta data before save

不想你离开。 提交于 2019-12-01 01:12:27
I'm trying to set the metadata of an image on exit from a resize, the property appears to be set but after the save nothing is there. I'm pretty sure I'm doing something stupid any ideas. var pi = createPropertyItem(); pi.Id = 40091; pi.Len = "SomeText".Length; pi.Type = 2; pi.Value = Encoding.UTF8.GetBytes("SomeText"); SrcImage.SetPropertyItem(pi); SrcImage.Save(@"C:\temp\withTag.jpg"); private PropertyItem createPropertyItem() { var ci = typeof (PropertyItem); var o = ci.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public , null, new Type[] {} , null); return

WPF: Use font installed with 'AddFontMemResourceEx' for process only

被刻印的时光 ゝ 提交于 2019-11-30 21:59:34
In WPF we would like to use ttf fonts as embedded resources without copying or installing these to the system and without actually writing these to disk. Without memory leak issues. None of the solutions detailed in: How to include external font in WPF application without installing it are useable in this scenario due to the WPF memory leak around this: WPF TextBlock memory leak when using Font Installing fonts from memory and process only is possible in GDI via AddFontMemResourceEx . Since this installs the font for the process, it should work for WPF as well, but there seems to be issues

Is StretchBlt HALFTONE == BILINEAR for all scaling?

為{幸葍}努か 提交于 2019-11-30 21:42:51
Can anyone clarify if the GDI StretchBlt function for the workstation Win32 API performs bilinear interpolation for scaling to both larger and smaller images for 24/32-bit color images? And if not, is there a GDI ( not GDI+) function that does this? The SetStretchBltMode fn has a setting HALFTONE which is documented as follows: HALFTONE Maps pixels from the source rectangle into blocks of pixels in the destination rectangle. The average color over the destination block of pixels approximates the color of the source pixels. I've seen references (see follow-up to first answer) that this performs

What is the HDC for in GetDIBits?

让人想犯罪 __ 提交于 2019-11-30 21:13:12
I was using GetDIBits to get bitmap data from a screen compatible device context into a DIB of a certain format. I was under the impression that the DC was necessary only for synthesizing a color table when the source bitmap is 8 bits-per-pixel or less. Since my source bitmap was a full 32-bit color image and this was a one-off program and I didn't have the screen DC handy, I set the HDC parameter to NULL. This didn't work. Once I grabbed the screen DC and passed it in, it did start working. That left me wondering why GetDIBits requires the device context. What is it used for? In: int

How to measure the pixel width of a digit in a given font / size (C#)

青春壹個敷衍的年華 提交于 2019-11-30 19:25:05
I am trying to calculate the pixel width of Excel columns, as described in this post , using the official formula from the OpenXML specification. However, in order to apply this formula, I need to know the Maximum Digit Width of the Normal font, which is the pixel width of the widest numeric digit. The OpenXML specification gives this example as a clarification: Using the Calibri font as an example, the maximum digit width of 11 point font size is 7 pixels (at 96 dpi). I have checked that this is correct by visually examining a Calibri 11-point digit and it is indeed 7 pixels wide. So, I am