Delphi SetMapMode Inverts Text

261 Views Asked by At

I am working on a graphics application and have a number of objects with captions. To put the captions, I calculate an X, Y coordinate and call:

Canvas.TextOut(XText, YText, FCaption);

I decided to use a different mapping mode to make conversions from world space to device space simpler:

SetGraphicsMode(cnv.Handle, GM_ADVANCED);
SetMapMode(pbxMain.Canvas.Handle, MM_HIENGLISH);

and now my captions are printing upside down, but still left to right.

Any thoughts on how to remedy that?

One approach I had considered was setting the map mode back to the default for outputting text, which would require some conversions to get X, Y in the different mode. Is that a reasonable tactic? Is it "correct" to change map mode during paint routines...?

1

There are 1 best solutions below

0
On BEST ANSWER

Although the y axis reversed when you set MM_HIENGLISH map mode, assuming a default previous value of MM_TEXT, it doesn't cause text to be output upside-down - it just effects where it's output.

You might want to check if you're calling SetWorldTransform which is a probable cause for the problem you observe - a faulty transformation. A negative value in eM22 of the transformation structure parameter causes a reflection in the y axis.

Regarding the last part, I don't see any problem switching map modes during a single drawing task, apart from it might complicate maintaining the code.