1

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...?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Robatron
  • 83
  • 9
  • Y axis is reversed with MM_HIENGLISH in contrast to MM_TEXT but you shouldn't get upside down text. Is it possible that you're calling SetWorldTransform at some point? – Sertac Akyuz Mar 03 '21 at 01:14
  • I do call SetWorldTransform for a "zoom" function. – Robatron Mar 03 '21 at 03:59
  • Ok, make sure you don't have a negative eM22 of the XFORM. Otherwise please try to produce a minimal reproduction case. – Sertac Akyuz Mar 03 '21 at 17:37
  • I have that value set to Cos(Angle) where Angle is in radians. For an angle of 0, Cos returns +1, so that isn't it. Hmmmmmm......I'll work up a test case. – Robatron Mar 05 '21 at 04:20
  • OK! Problem solved. The issue was that I had a function for setting zoom, rotation and translation. In that function it set the mode MM_ANISOTROPIC. However, my paint handler had already set it to MM_HIENGLISH. I suspect the subsequent call to SetMapMode was somehow involved. Your pointers led to the solution. Please post an answer of some kind here so I can check it. :) – Robatron Mar 05 '21 at 05:01
  • Glad you've resolved your issue. I posted my recommendations as an answer. – Sertac Akyuz Mar 05 '21 at 15:30

1 Answers1

1

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.

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169