07-25-2006, 10:21 AM
I'm using drawpath to draw some path's..That's why they implented it :D
Buth my problem is the following. Whenever I draw a path with the addstring method, the text looks not what u should expect of it. On further testing i've noticed that when I used SetResolution and puth the resolution much higher than the standard 96 dpi (around 300 and up) I got much better result..Only problem is that the bitmap on wich it paints get's smaller.. Does anyone have a good idea?
07-25-2006, 02:31 PM
The graphics object has several properties which can improve various aspects of drawing quality. The ones which come to mind are CompositingQuality, TextRenderingHint (look into this one)... and I forget the rest. Take a look at the Graphics object's members and see what catches your eye.
07-25-2006, 03:31 PM
I already use them...
.CompositingQuality = CompositingQuality.HighQuality
.TextRenderingHint = TextRenderingHint.AntiAlias
.SmoothingMode = SmoothingMode.AntiAlias
.InterpolationMode = InterpolationMode.HighQualityBicubic
Buth still it's open to improvement...Like I said before a higer dpi seems to do the trick...only when I load it back into a picturebox its smaller..
07-25-2006, 04:04 PM
You might want to use the higher DPI then; just scale the dimensions and drawing coordinates up proportionately.
07-25-2006, 07:05 PM
Ok..and lets say i have in 96 dpi a bitmap of a 100 width and 100 height...
What will the size be in lets say 300 dpi?
07-26-2006, 09:50 AM
Unfortunately the graphicsPath.AddString method is not good for quality text, as the TextRenderingHint and other properties are not applied. The graphicsPath just stores a bunch of points. By increasing the resolution you are able to cram in more points -but you end up using alot more memory and slowing everything down. I would use graphics.DrawString instead. Or maybe the 2005 TextRenderer if suitable.
resolution = dots / inch
=> inch = dots/resolution
100dots @ 96dpi:
inches=100/96 = a bit over an inch
100dots @ 300dpi:
inches = 100/300 = 1/3 of an inch.
note: it is only going to be an inch with the right monitor (physical dimension), and the right desktop resolution - so think of inch as "unit length" instead.
To maintain inches you need to maintain the ratio bitmap.width/resolution
100/96 = new width/300 => new width = 100 * 300 / 96 = 312.5
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim bm1 As New Bitmap(100, 100)
Dim g As Graphics = Graphics.FromImage(bm1)
e.Graphics.DrawImage(bm1, New Point(0, 0))
Dim newRes As Integer = 300
Dim newWidth As Integer = bm1.Width * newRes / bm1.HorizontalResolution
Dim bm2 As New Bitmap(newWidth, newWidth)
g = Graphics.FromImage(bm2)
e.Graphics.DrawImage(bm2, New Point(bm1.Width, 0))