coordinate system & font

L

Lloyd Dupont

I'm porting an aplpication to windows.
This application's data files contains shape draw to the screen.
Their coordinate system has the 0,0 location at the bottom and y goes up as
you go up the screen (the opposite on what happens on windows control)

if I setup a coordinate transformation my strings, when drawn, are upside
down.

Is there any simple way to draw them correctly?


so far I though of 2 method:
1. create a new graphic container just before drawing string and changing
coordinate system
(but because the shape drawing string could be intermixed with other shape,
it's a shamble!)
2. manually transform all the coordinate of my shaped with a matrix before
using them, I'm afarid it would be inneficient...

Any thoughts?
 
L

Lloyd Dupont

I did that (below), could it be optimised?
what's the difference between Graphics.Save() & Graphics.BeginContainer() ?

--
public virtual void DrawString(PaintEventArgs e, string s, Font f, Brush b, float x, float y)
{
int h = f.Height;
GraphicsState gstate = e.Graphics.Save();
try
{
e.Graphics.TranslateTransform(x, y + f.Height);
e.Graphics.ScaleTransform(1, -1);
e.Graphics.DrawString(s, f, b, 0, 0);
}
finally { e.Graphics.Restore(gstate); }
}
 
L

Lloyd Dupont

I have the same problem with picture as well now..
it's akward...

any suggestion?
 

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