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
I found a workaround for the issues when printing. Note that the graphics object in the example doesn't set any world space transformations, so drawing is done directly in page space.
Setting the page units to inches, then converting coordinates to inches seems to fix the drawing issues without much additional work. Tested with display and printer DCs at different DPIs (ranging from 72 to 4000.)
Gdiplus::Graphics graphics(..);
Gdiplus::RectF rect(0.0f, 0.0f, 1.0f, 1.0f);
Gdiplus::REAL dpiX = graphics.getDpiX();
Gdiplus::REAL dpiY = graphics.getDpiY();
/* Logical coordinates to inches. In this example, the window extents are
equal to the DC's DPI. You will have to convert to inches based on your
specific configuration. */
rect.X /= dpiX;
rect.Y /= dpiY;
rect.Width /= dpiX;
rect.Height /= dpiY;
graphics.SetPageUnit(Gdiplus::UnitInch);
graphics.FillRectangle(.., rect);