Bizarre size problem using DrawString

xoggoth

Member
Joined
Mar 6, 2008
Messages
6
Programming Experience
10+
Have a program that was all tested out and I have not changed the code, just the images displayed. I can copy the executable/code back to the directory with the old content and it works.

I am marking some images with an "X" in one corner but for some reason this is drawing at a huge fontsize although the debugger tells me the fontsize is exactly as expected. With a test copy to clipboard added (just to ensure I am not doing something daft later) the relevant code is:

Private scratch As New PictureBox
Private gr1 As Graphics
...
gr1 = Graphics.FromImage(scratch.Image)
gr1.DrawString("X", MainBox1.Font, Brushes.Red, pr.PicTX, pr.PicTY)
My.Computer.Clipboard.Clear()
My.Computer.Clipboard.SetImage(scratch.Image)

Debug tells me that MainBox1.Font = {Name = "Arial" Size=12.0} but when I open the clipboard my "X" is more like fontsize 180, although it is in the right position.

I have checked that sizemode of scratch is normal and have also created scratch/gr1 by dim immediately before just in case it was some previous use that caused problem and get the same result.

I can't think of any reason, grateful for any suggestions on this.
 
Does the image have a higher resolution than default 96*96 dpi? (machine configuration based)
 
Thanks for reply. PSP reports it has 508 pixels/inch, ie 832x690 pixels, 1.638x1.358 inches, although not sure where it gets those latter figures as not how it looks on monitor.

PS Just checked previous images that work ok and those are only 71 pixels/inch, ie 832x690 pixels, 11.702x9.705 inches, so looks like you may well be on the right track. Why they would be different I have no idea, they look the same and the person who sent them would have scanned them in and resized them to 832x690 in exactly same way.
 
Last edited:
Ok, if its bigger than default you get bigger fonts too. (when viewing in some applications, print resolution aware ones)
 
Copied image, pasted into paint and resaved and it's fine, so yes is just image res. Thanks very much JohnH, don't think that would have occured to me.
 
Last edited:
Back
Top