help with this code - drawpicture

I have this code…

[code] Dim g As Graphics
Dim ps As PrinterSetup
ps = New PrinterSetup
g = OpenPrinterDialog(ps)

dim p as new picture(g.Width, g.Height)
p.Graphics.DrawString(“Hello World 2”, 50, 80)

g.DrawString(“Hello World 1”, 50, 50)
g.DRAWPICTURE(p,0,0) --> 'WHY LOW DEFINITION?[/code]

why that text is low definition and how could i solve it?

Have you tried setting the DPI within the PrinterSetup object to the max DPI of your printer?

ps.MaxHorizontalResolution = 300 ps.MaxVerticalResolution = 300

It might be defaulting to a lower resolution.

a/ Dont use Xojo 2017 on Windows.
b/…etc

So, the graphics you got is a page sized lump of 96dpi
8 inches across has 8 x 96 = 768 dots total.
Very low resolution for printing.

Your code does this:

g.DrawString(“Hello World 1”, 50, 50) //draws on the printer graphics
g.DRAWPICTURE(p,0,0) //wipes out what you drew by covering it with your picture, and possibly goes anti-aliased in the process.

Try this quick workaround:

dim p as new picture(g.Width * 4, g.Height *4) p.Graphics.fontsize = 12 * 4 p.Graphics.DrawString("Hello World 2", 50 *4, 80 *4) g.DRAWPICTURE p,0,0,g.width,g.height,0,0, p.width, p.height

[quote=336018:@nicolscanessa]I have this code…

[code] Dim g As Graphics
Dim ps As PrinterSetup
ps = New PrinterSetup
g = OpenPrinterDialog(ps)

dim p as new picture(g.Width, g.Height)
p.Graphics.DrawString(“Hello World 2”, 50, 80)

g.DrawString(“Hello World 1”, 50, 50)
g.DRAWPICTURE(p,0,0) --> 'WHY LOW DEFINITION?[/code]

why that text is low definition and how could i solve it?[/quote]
To answer your question, pictures are by default 72 DPI, whereas printer contexts are whatever the printer supports. Lets say for a moment that your printer supports 300DPI. when that picture gets drawn, every 1 pixel in the picture takes up 4.1667 pixels on the printer, making it look blurry.

If you want higher rez pictures, multiply the width & height by the horizontal and vertical resolution that you get from the printer context (respectively) and divide each by 72. Set Graphics.ScaleX and Graphics.ScaleY to 4.16667 and draw onto that picture. You’ll also need to set the HorizontalResolutio and VerticalResolution of the picture to 300. Then when you draw onto the printer context, everything should be nice and smooth.

thanks @Greg O’Lone ! works great that way!