I am trying to print a CNIGraph in a CView. The graph is dynamically
created in the OnCreate function and rendered on the screen in the
OnDraw function. Everything seems to work well for screen output, it
renders the graph properly with a resolution suitable for the screen.
When the device context changes to the printer, the graph is rendered
in the correct size and the text is printed with high resolution.
However, the data in the graph seems to be rendered in the screen
resolution instead of the print resolution. The attached pdf shows an
example print output. Zooming in on the trace (or ramp in this case)
will reveal a jagged line instead of the desired straight line. The
OnDraw code snippet can be found below and the corresponding
Visual C++ project is attached.
How can the print output be improved to render the data accurately since quality printing is necessary for our application?
Regards,
Per Bergman
pDC->SetMapMode(MM_LOENGLISH);
long logicalPixelsPerInchX = pDC->GetDeviceCaps(LOGPIXELSX);
long logicalPixelsPerInchY = pDC->GetDeviceCaps(LOGPIXELSY);
TRACE ("logicalPixelsPerInch X Y %d\t%d\n", logicalPixelsPerInchX, logicalPixelsPerInchY);
// plot data - generate ramp to plot
CNiReal64Vector niVector;
int iNumPoints = 1000;
niVector.SetSize(iNumPoints);
for (unsigned point=0; point < (unsigned) iNumPoints; point++)
niVector[point] = point;
m_Graph.PlotY(niVector);
// ControlImage returns a metafile of the control
CPictureHolder ph;
ph.SetPictureDispatch((LPPICTUREDISP)m_Graph.ControlImageEx(logicalPixelsPerInchX,
logicalPixelsPerInchY).m_lpDispatch); // use controlimageEx
to get the right rendering resolution
// render graph using mapping modes
TRACE("Rect\ttop=%d\tleft=%d\tbottom=%d\tright=%d\n", m_Rect.top, m_Rect.left, m_Rect.bottom, m_Rect.right);
ph.Render(pDC, m_Rect , m_Rect);