I have a problem while drawing with both GDI and GDI+ interchangeably. The page transformation—in particular scaling—seems to be a little bit off between the two. Wh
Short answer: call graphics.SetPageUnit(Gdiplus::UnitPixel)
I had the same problem as https://stackoverflow.com/a/4894969/700027: when printing, the coordinates for GDI+ (Gdiplus::Graphics) did not match the coordinates from GDI (HDC).
graphics.GetPageUnit()
was returning UnitDisplay
. The documentation of UnitDisplay
is:
Specifies display units. For example, if the display device is a monitor, then the unit is 1 pixel.
I had wrongly assumed that for a printer, UnitDisplay
would use printer dots. After much struggle I finally found out that it was actually using 1/100 of inches for an unknown reason. If I use Gdiplus::UnitPixel then GDI+ coordinates are the same as GDI coordinates.