April 5th, 2012, 04:48 PM
GDI+ question Im kindda stuck
I have a task of sending a graphics object to a printer, but I am facing some challenges.
It has to be Device independant and I hav reached quite far in my development.
However i am facing some issues.. I know that text and graphics works totally independant in my solution, and I am managing to scale and resize my graphics correct as long i am using devices(printers) over 300 dpi. using below 300 dpi my graphics is cut accordingly eg 150 will give me the right dimensions but the graphics is cut down to 50%.
Second challenge i am facing is when i am uising odd device dpi, meaning a dpi that will give a decimal when devided by 300. When using a dpi where the result is a full figure when deviding by 300 i can align my text perfect, but when the odd figure is the result my text starts floading on page 2,3 ect.
Below is the code that i have added to the solution. (plz dont laugh im new to c++)
Setting the graphics object (vector)
mp_oControl->iPrintXOrig = XOrigin;
mp_oControl->iPrintYOrig = YOrigin;
CDC *pDC = CDC::FromHandle ((HDC)hdc);
oGraphics.ScaleTransform((REAL)DestScale / (REAL)100, (REAL)DestScale / (REAL)100);
//moving my text according to dpi on the device
ScaleFactorDPI = 1;
ScaleFactorDPI = mp_oControl->globalDPIScale;
// global dpi scale is LOGPIXELSY/300
if (ScaleFactorDPI !=1)
double lMulfactor = (float)(mp_oControl->iGlobalPixelsY/300)-1;
double iXorg = mp_oControl->GetMathLib()->RoundDouble((mp_oControl->iPrintXOrig*lMulfactor));
double iYorg = mp_oControl->GetMathLib()->RoundDouble((mp_oControl->iPrintYOrig*lMulfactor));
v_lLeft = (v_lLeft*ScaleFactorDPI)-iXorg;
v_lTop = (v_lTop*ScaleFactorDPI)-iYorg;
v_lRight = (v_lRight*ScaleFactorDPI)-iXorg;
v_lBottom = (v_lBottom*ScaleFactorDPI)-iYorg;
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!