gdi

Setting the Line End Styles for Canvas.LineTo

不问归期 提交于 2019-12-19 07:59:24
问题 Is there any way to set the style for the lineends for the TCanvas.LineTo method? It seems to default to rounded ends, which looks very bad for several lines in a row of different colours when Pen.Width is set to a large value (e.g. 9). It looks like this (rounded ends): ********........****** **********........****** **********........****** ********........****** (where * is e.g. blue and . is yellow) It is even worse if the two outer lines are drawn after the middle line: ********........*

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

时光总嘲笑我的痴心妄想 提交于 2019-12-18 21:21:30
问题 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

Draw parallel Line

陌路散爱 提交于 2019-12-18 07:25:39
问题 I have a set of points representing a line. It might be a closed shape or an open one. I need to draw a parallel line that goes besides the original one without any intersection. I have the following code to return the generated line. I have problems in the angles of the shape. Some point goes over the original line. My Code is: PointF[] GetParrarel(PointF[] lst, double width, float distance) { List<PointF> final = new List<PointF>(); width = width + distance; for (int i = 0; i < lst.Length-1

Drawing on 8bpp grayscale bitmap (unmanaged C++)

丶灬走出姿态 提交于 2019-12-18 07:22:47
问题 I've been attempting to draw on an 8bpp grayscale bitmap without success. Here are some of my attempts. Maybe someone can point out what I'm doing wrong. =================================================== Attempt 1: Create, select, and draw: In constructor: CBitmap bm; bm.CreateBitmap (200, 200, 1, 8, NULL); In OnDraw: CDC *mdc=new CDC (); HGDIOBJ tmp = mdc->SelectObject(bm); Result: tmp is NULL, indicating failure. =================================================== Attempt 2:

Draw on screen with GDI+ (or GDI) similar to Inspect

点点圈 提交于 2019-12-18 07:20:39
问题 I'm trying to draw on the screen (the whole screen, on top of every other window) using GDI+. I've passed NULL to GetDC to get a HDC to the screen, and then used that to create a Graphics object, and used DrawRectangle to draw rectangles on the screen. Everything works..except...the inside of the rectangle won't update. Like if I draw it over a command prompt, and move the command prompt, the inside of the rectangle remains black. I expect to see whats under the rectangle. Here's the code

Draw on screen with GDI+ (or GDI) similar to Inspect

独自空忆成欢 提交于 2019-12-18 07:20:35
问题 I'm trying to draw on the screen (the whole screen, on top of every other window) using GDI+. I've passed NULL to GetDC to get a HDC to the screen, and then used that to create a Graphics object, and used DrawRectangle to draw rectangles on the screen. Everything works..except...the inside of the rectangle won't update. Like if I draw it over a command prompt, and move the command prompt, the inside of the rectangle remains black. I expect to see whats under the rectangle. Here's the code

How to Create a Gdiplus::Bitmap from an HBITMAP, retaining the alpha channel information?

久未见 提交于 2019-12-18 06:08:44
问题 When I create a new Gdiplus::Bitmap using the Bitmap::FromHBITMAP function, the resulting Bitmap is opaque - none of the partial transparency from the original HBITMAP is preserved. Is there a way to create a Gdiplus::Bitmap from an HBITMAP which brings across the alpha channel data? 回答1: I think working code is more useful than instructions, so: #include <GdiPlus.h> #include <memory> Gdiplus::Status HBitmapToBitmap( HBITMAP source, Gdiplus::PixelFormat pixel_format, Gdiplus::Bitmap** result

C++/Win32: How to get the alpha channel from an HBITMAP?

痴心易碎 提交于 2019-12-18 04:49:13
问题 I have an HBITMAP containing alpha channel data. I can successfully render this using the ::AlphaBlend GDI function. However, when I call the ::GetPixel GDI function, I never get back values with an alpha component. The documentation does say that it returns the RGB value of the pixel. Is there a way to retrieve the alpha channel values for pixels in an HBITMAP ? I want to be able to detect when to use ::AlphaBlend, and when to use an old-school method for treating a particular colour in the

How to convert bitmap to grayscale by pixel intensity using GDI?

折月煮酒 提交于 2019-12-18 04:13:29
问题 I'm looking for the simple solution of how to convert the 32-bit bitmap to grayscale using GDI (not GDI+). Is there a possibility e.g. by changing the bitmap's pallete or something ? Of course there is plenty of examples in Delphi like this one, but I'm looking for a WinAPI function which would do this without iteration through the lines. 回答1: I haven't found any single GDI function doing this. The easiest way, as David mentioned in his comment, is to scan each line and compute the pixel

Why can't DirectX/DirectWrite/Direct2D text rendering be as sharp as GDI?

随声附和 提交于 2019-12-17 22:43:02
问题 I already know that sub-pixel positioning causes DirectWrite text rendering to be blurry compared to GDI. However, my question is a bit more fundamental: Why can't DirectWrite (and related methods) be made to render text as sharply as GDI? In other words: What prevents DirectWrite from being able to snap text to the nearest pixel, the way GDI can? Is it, for example, a hardware issue? A driver architecture issue? Is it simply not implemented? Or something else? Smaller sample: Larger samples: