gdi+

How to make drawLine smoother?

倾然丶 夕夏残阳落幕 提交于 2019-12-19 20:28:47
问题 I use the following code to draw line: Graphics g = this.CreateGraphics(); Pen p = new Pen(Color.Black,3); g.DrawLine(p,...); // ... Why the straight line is zigzag kind of, not straight and smooth at all. How could I make it straight and smoother? 回答1: You need to enable anti-aliasing. Set Graphics.SmoothingMode to AntiAlias as described here: http://msdn.microsoft.com/en-us/library/system.drawing.graphics.smoothingmode.aspx 回答2: Override the OnPaint() method of your form or implement the

Generic text-only printer driver doesn't work

时光怂恿深爱的人放手 提交于 2019-12-19 10:33:20
问题 I am using Generic text-only printer driver, provided as a sample in WDK(Windows driver toolkit). But it works with some applications and doesn't work with others. Like it works with Notepad and Microsoft word, but doesn't work with chrome browser or FloreantPOS. I tried using this driver to print to a file or a thermal printer with following 4 applications:- 1)Simple text on Notepad: Works successfully. 2)Text + graphics(word art) on Microsoft Word: Works successfully i.e. prints text and

GDI+: how do you render a Graphics object to a bitmap on a background thread?

送分小仙女□ 提交于 2019-12-19 10:04:34
问题 I'd like to use GDI+ to render an image on a background thread. I found this example on how to rotate an image using GDI+, which is the operation I'd like to do. private void RotationMenu_Click(object sender, System.EventArgs e) { Graphics g = this.CreateGraphics(); g.Clear(this.BackColor); Bitmap curBitmap = new Bitmap(@"roses.jpg"); g.DrawImage(curBitmap, 0, 0, 200, 200); // Create a Matrix object, call its Rotate method, // and set it as Graphics.Transform Matrix X = new Matrix(); X.Rotate

GDI+: how do you render a Graphics object to a bitmap on a background thread?

三世轮回 提交于 2019-12-19 10:03:13
问题 I'd like to use GDI+ to render an image on a background thread. I found this example on how to rotate an image using GDI+, which is the operation I'd like to do. private void RotationMenu_Click(object sender, System.EventArgs e) { Graphics g = this.CreateGraphics(); g.Clear(this.BackColor); Bitmap curBitmap = new Bitmap(@"roses.jpg"); g.DrawImage(curBitmap, 0, 0, 200, 200); // Create a Matrix object, call its Rotate method, // and set it as Graphics.Transform Matrix X = new Matrix(); X.Rotate

How to draw a circular progressbar pie using GraphicsPath in WinForm?

此生再无相见时 提交于 2019-12-19 09:41:15
问题 I want my custom circular progress bar in WinForm. But the result doesnt fit to what I think. How can I draw the shape as the same in this picture?. I uploaded two image to be clear in my problem. My code to do this: void Form1_Paint(object sender, PaintEventArgs e) { int angle = 120; e.Graphics.SmoothingMode = SmoothingMode.HighQuality; Rectangle outerRect = new Rectangle(50, 50, 100, 100); Rectangle innerRect = new Rectangle(70, 70, 60, 60); int innerRadius = innerRect.Width / 2; int

.NET Library for drawing tables with GDI+

元气小坏坏 提交于 2019-12-19 09:38:49
问题 I need to print the contents of a datagridview, simple text in rows and columns, with GDI+ in .NET to paper. To do this, I need to iterate over the rows, draw lines, iterate over the columns, calculate width, height, wrap the contents if contents do not fit on one line, etc. This is all possible, but is there a library that simplifies the drawing of tables in GDI+ and abstracts some of the difficulties away? 回答1: This is a very common request. Easy keywords, google "print datagridview". Here

Centering an individual character with DrawString

柔情痞子 提交于 2019-12-19 08:02:16
问题 I have tried all of the suggested ways to center text, but I can't seem to get the results I want while centering an individual character. I have a rectangle. In that rectangle I'm drawing a circle with DrawEllipse. Now I want to draw a single character inside the circle using the same rectangle and DrawString, to have it perfectly centered. Here is my basic code: StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment =

Centering an individual character with DrawString

帅比萌擦擦* 提交于 2019-12-19 08:02:10
问题 I have tried all of the suggested ways to center text, but I can't seem to get the results I want while centering an individual character. I have a rectangle. In that rectangle I'm drawing a circle with DrawEllipse. Now I want to draw a single character inside the circle using the same rectangle and DrawString, to have it perfectly centered. Here is my basic code: StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment =

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

MeasureString() pads the text on the left and the right

99封情书 提交于 2019-12-18 18:51:17
问题 I'm using GDI+ in C++. (This issue might exist in C# too). I notice that whenever I call Graphics::MeasureString() or Graphics::DrawString(), the string is padded with blank space on the left and right. For example, if I am using a Courier font, (not italic!) and I measure "P" I get 90, but "PP" gives me 150. I would expect a monospace font to give exactly double the width for "PP". My question is: is this intended or documented behaviour, and how do I disable this? RectF Rect(0,0,32767,32767