Reputation: 1776
I'm using a third party library for drawing graphs. The library requires a HDC (GDI). But my application is using GDI+.
Q1: Is it safe to do this?
void f(Gdiplus::Graphics& graphics)
{
HDC dc = graphics.GetHDC();
// Call 3rd party lib functions using dc
// ...
graphics.ReleaseHDC(dc);
}
Q2: Some of the lib's functions require a bounding RECT struct (WinAPI). How do I calculate the coordinates for that rectangle if I'm using millimeters as page unit?
graphics.SetPageUnit(UnitMillimeter);
Upvotes: 2
Views: 1049
Reputation: 5132
Q1: yes, but you may need to change the coordinate system if the third party library cannot handle your coordinates ==> Q2
Q2: this SO Question has some pointers for this (it is for the opposite direction, though), you will need to set the mapping mode to MM_HIMETRIC, convert your GDI+ coordinates to integers of 0.01 mm and use LPtoDP to get the pixel values.
Upvotes: 2