1

I have 2 same images. When I try to add rectangle and text (using graphics) to this images, the rectangle is the same BUT the text on image is different size..

the code is:

g.DrawRectangle(new Pen(Color.Blue, 5), new Rectangle(10, 10, 200, 100));
g.DrawString("GONgon", new System.Drawing.Font("Arial", 20), new SolidBrush(Color.Black), 20, 20);

originals of images here:

first

second

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
  • Check to see if they really have the same `DPI` setting!! – TaW Feb 14 '15 at 12:36
  • The 1st image has an odd-ball 72 dpi resolution, the 2nd is 96 dpi. Be specific about the unit of measurement for the Font. Right now it is *points* and that's a dpi dependent unit. Fixing the image wouldn't hurt either. – Hans Passant Feb 14 '15 at 13:46

1 Answers1

0

Set GraphicsUnit = Pixel in the System.Drawing.Font(). Like System.Drawing.Font(fontName,fontSize,fontStyle,GraphicsUnit.Pixel).

DhavalR
  • 1,409
  • 3
  • 29
  • 57