Hello,
In my GDI+ application I create graphics (rectangles, circles and text) on the panel pnl. For graphical object I need to move the origin from top-left to bottom-left corner.
The solution is to apply consequently 2 transforms ScaleTransform and TranslateTransform to the Graphics object.
Graphics dc = pnl.CreateGraphics();
dc.ScaleTransform(1.0f, -1.0f);
dc.TranslateTransform(0.0f, -pnl.Height);
But in this way the text is mirrored !!!
Is there a simple way to resolve a problem?
Thanks in advance.
Pavel.
Loading

Nuno PintoPosted Nov 6, 2017, 9:07 AM
PavelPosted Sep 14, 2012, 2:43 AM
Probably I will decide to reject transforms and replace every y to pnl.Height - y.
It's a pity, that such behaviour wasn't remarked by Microsoft engineers.
Thank you once more for your assistance.
Regards.
Pavel.
VulpesPosted Sep 13, 2012, 2:41 PM
However, if you only have a few strings to draw, I'd suggest you draw them first before you change the origin to draw the shapes.
PavelPosted Sep 13, 2012, 2:35 PM
VulpesPosted Sep 13, 2012, 2:23 PM
For text, you'd need to do what you said and also subtract the height of the font being used.
PavelPosted Sep 13, 2012, 2:07 PM
If I understood in right way, you propose to reject at all the using of transforms.
If it is only solution, Ok ... I will proceed in this way. But I have plenty "geometric" graphics (rectangles, circles, etc.), that are correctly displayed with transforms, and only few "text" graphics.
So, in order to consider bottom-left as origin, I should replace all "y" to "pnl.Height-y" ?
Thanks.
Pavel.
VulpesPosted Sep 13, 2012, 12:10 PM
I don't know of any solution to this except to stick with the origin at the top left corner and then draw the text at the appropriate location. So:
Graphics dc = pnl.CreateGraphics();
// draw string from top left
dc.DrawString("Pavel", drawFont, drawBrush, 0, 0);
// draw string from bottom left
dc.DrawString("Pavel", drawFont, drawBrush, 0, pnl.Height - drawFont.Height);