Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Poor graph print quality

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);
 
0 Kudos
Message 1 of 11
(4,769 Views)
Please see the following knowledge base entry that will be useful to you.
 
 
I hope this helps
 
Thank you
 
Nandini
NI
0 Kudos
Message 2 of 11
(4,755 Views)
The link provided suggests to use the same method of painting (ControlImageEx) that I am using in the code snippet above:
 
ph.SetPictureDispatch((LPPICTUREDISP)m_Graph.ControlImageEx(logicalPixelsPerInchX, logicalPixelsPerInchY).m_lpDispatch);
 
The problem is that the data in the graph is not rendered using the printers resolution, instead it seems to be rendered using the screen resolution. The attached pdf printout shows that the ramp, which is made up of 1000 points, is not rendered using 1000 points. Zooming in on the trace will show that the line is "jagged" as is the data has been decimated.
 
Regards,
Per
 
 
 
0 Kudos
Message 3 of 11
(4,739 Views)
Hi Per:

Are you setting the history length of your graph?

Thanks
Nandini
NI

http://digital.ni.com/public.nsf/websearch/335F7FA034F643B586256CD0007833F4?OpenDocument
0 Kudos
Message 4 of 11
(4,724 Views)
Hello,
I've tried setting the chart length and it does not affect the print quality output. The graph knows about all the data points since they are rendered in the print out. If chart length would the a factor we would not see the range 0-1000 in the output. Attached is a screen shot from Acrobat showing the jagged effect from the renderer.

Per

0 Kudos
Message 5 of 11
(4,710 Views)
Per,

Do you see this behavior when you save the CNiPicture object out to a .bmp? My thought is that because Adobe uses compression when saving images into a acrobat file, that may be where we are running into the problem.

Try opening just a .bmp of the control in another image viewer and see if you can replicate that behavior.

Thanks!

Dan Weiland
Applications Engineer
National Instruments

Dan Weiland
0 Kudos
Message 6 of 11
(4,687 Views)
Dan,
I get the same result if I send it to a printer instead of Acrobat. The jagged line seems to come from the control, not from the print routines/ driver.
 
/Per
0 Kudos
Message 7 of 11
(4,680 Views)
Can you attach just the bmp of the control to the forum? I'll have to do a little more research into this to determine the exact cause, but having the straight bmp instead of an Adobe image would be extremely helpful.

Thanks so much for your patience Per, I appreciate it.

Dan Weiland
Applications Engineer
National Instruments
Dan Weiland
0 Kudos
Message 8 of 11
(4,659 Views)
Hi Dan,
I'm not sure how to create a bitmap file from the control. Can you please provide sample code for this and I'll post the resulting bitmap as soon as possible.

Thanks,

Per

0 Kudos
Message 9 of 11
(4,642 Views)
Refer to the following forum on saving a control image to a bitmap:

http://forums.ni.com/ni/board/message?board.id=231&message.id=3582&a#M3582

Once you've acquired the bitmap, just post it here. Also, try printing this acquired image and seeing if your data looks better.


Dan Weiland
0 Kudos
Message 10 of 11
(4,628 Views)