Drawstring on image at differnet DPI's

M

Mark B

I have code to Drawstring onto a static PNG image at certain point: new
PointF(12, 11)

This was all coded when I was running at 120 DPI and the text was placed in
the correct position over the background image.

When I change my resolution to 96 DPI however, the text appears too far
across and too far down.

How can I get it to place it in the correct position regardless of the
user's DPI setting?
 
P

Peter Duniho

I have code to Drawstring onto a static PNG image at certain point: new
PointF(12, 11)

This was all coded when I was running at 120 DPI and the text was placed
in the correct position over the background image.

Over what background image?
When I change my resolution to 96 DPI however, the text appears too far
across and too far down.

How can I get it to place it in the correct position regardless of the
user's DPI setting?

Impossible to say without a concise-but-complete code example that
reliably demonstrates what you're doing and why it's not working for you.

The current screen DPI selected in Windows should not affect in-memory
rendering, except to be used as the default DPI for a new Bitmap
instance. I would expect that you could normalize all your drawing simply
by providing an appropriate scaling factor when drawing to the Graphics
instance obtained from the Bitmap instance, but note that this will also
scale your drawing position which, assuming you haven't changed the units
used during drawing, should not have been affected by the DPI setting in
the first place (i.e. the text should have been in the right place, just
the wrong size).

If the above isn't sufficiently helpful, you need to provide a proper code
example as I described above.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top