Questions tagged [system.drawing.graphics]

33 questions
1
vote
1 answer

System.Drawing.Graphics trim end of string?

While working on a text render algorithm, I stumbled across a strange behavior of the Graphics.MeasureString() method. It seems like it internally trims the end of a string. g.MeasureString("d", font).Width //is 13.289278 g.MeasureString("d ",…
Florian Gl
  • 5,984
  • 2
  • 17
  • 30
0
votes
1 answer

DPI of screenshot taken using Graphics changes to 3700 after use in TesseractOCR

I am using c# winforms and I am taking a screenshot using Graphics.copyfromscreen private Bitmap CaptureImage() { // Create a bitmap with the specified dimensions Bitmap capturedImage = new Bitmap(captureArea.Width,…
0
votes
1 answer

On vb.net error on system.drawing.fontFamily.GetName 'Parameter is not valid'

My application fails while trying to paint a dataGridView object. There are a dataTable object that collect the information from a MySQL database and that object inserts to a dataGridView object with dgvTable.source = dataTable method That…
0
votes
1 answer

Create 5 Point Star with e.graphics but set the x and y start position to 110,110 in VB.NET

I need to create a small 5 point star that is 15 points wide by 15 points high, where the x starting position is 110 and the y starting position is 110 on my print document. the code I found online so far creates a star, but in the top left corner…
0
votes
1 answer

Drawing spotted circle

I am trying to draw a spotted circle like google pay spot code using System.Drawing.Graphics here is example on google pay spot code. I tried with this C# code: private void DrawSpot(Graphics graphics) { var lineWidth = ImageSize *…
0
votes
1 answer

Font Kerning > Change Inter character spacing in DrawString System.Drawing

How to increase/decrease inter-character spacing while drawing the string with System.Drawing in C#? In other words, I want to implement Font Kerning while printing labels. I have tried winapi SetTextCharacterExtra but It is not working at all. One…
0
votes
1 answer

VSTO Outlook Plugin: MeasureString calculates wrong width

I want to display a button with an internationalized label. In English the label perfectly fits the width of the button. In german it does not fit. To calculate dynamically the width I use [...] using (Graphics cg = this.CreateGraphics()) …
HHeckner
  • 4,722
  • 4
  • 23
  • 33
0
votes
1 answer

How can I rotate a bitmap, keeping its scale

I'm trying to rotate a bitmap where I retain all the pixels, and the destination bitmap size is set so that I get it at the same scale. In other words, every pixel in the source is a distinct pixel in the output, and the output bitmap size adjusts…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
0
votes
0 answers

Graphics.CopyFromScreen() is capturing blank for particular application

I am developing a .NET winforms application which has to capture a snapshot. For this I have used System.Drawing.Graphics.CopyFromScreen method which works fine but when I tries to capture screenshot of particular application (Oracle EBS) then it…
0
votes
0 answers

Execution order of System.Drawing.Graphics based List

It's my first time posting here so apologies in advance if I get the code formatting wrong. I'm coding a simple GDI+ renderer class in C#. Here's a simplified version of my code: public interface IRenderer { void Begin(); void…
0
votes
0 answers

Setting 'System.Drawing.Graphics.Transform' in Form.OnPaint yields ArgumentException

System.ArgumentException: 'Parameter is not valid.' This is the first time I have tried to toy with a Matrix and transformations. Anywho... protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; …
0
votes
2 answers

Painting with System.Drawing.Graphics on form load

I'm trying to draw a rectangle using System.Drawing.Graphics in C# Windows Forms, but I cannot seem to get it to work without using a button click event. Searching online uncovered that I must use either the Paint or the Shown event within the form…
Ivan Spajić
  • 159
  • 3
  • 5
  • 14
0
votes
0 answers

multi threading for plotting two different graphics in C#

If I create two different threads for each plot so is it possible to combine both the plots and display in a one picture box? I have tried it using single thread but I couldn't get the desired result. here is the code which I have tried: The output…
SN25
  • 69
  • 1
  • 12
0
votes
0 answers

How to print human readable documents in C#?

I'm working on a few tools that require printed output for the user, and I have had some good results with the System.Drawing and System.Graphics classes to layout the document to be printed, but I'm needing more page layout features. The code I've…
Chris Rutherford
  • 1,592
  • 3
  • 22
  • 58
0
votes
2 answers

C# save System.Drawing.Graphics to .png

I tried with the graphics.Save(); Graphics newImage = Graphics.FromImage(bmp2); newImage.DrawImage(bmp, 87, 37, 0, 0); newImage.Save(); but when i try to set the file name like in the Image.Save(@"HereGoesName.PNG"); method i get an error saying…
Chona Pardo
  • 25
  • 2
  • 9