ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Scaling chart images
Posted by David Wilson on Nov-08-2011 08:21
As always, thank you for your prompt and courteous responses to past inquiries.

I am currently trying to implement hardcopy printing of ChartDirector graphs from an MFC application. In the ChartDirector documentation, in section "Using ChartDirector with MFC", subsection "Printing Charts on Paper", you give sample code for printing a ChartDirector chart by converting it to an in-memory Windows bitmap and printing the bitmap. I have been able to successfully integrate this code sample into our application, and can now print some of the charts in our application.

The problem now is that I can only generate bitmaps at the ChartDirector default of 96 DPI. This is OK for screen display, but is rather low-resolution for hardcopy printing. The charts print at the correct size, but they are not sharp enough. The StretchDIBits() function from the code sample does a modicum of antialiasing, but the result is still not print quality.

By experiment, I found I could obtain sharper print images by creating a larger bitmap, at the cost of longer print time. I have found that 3x scaling gives an acceptable print quality. Unfortunately, when printing a larger bitmap, some chart features, such as font sizes, line weights, axis placements, etc, do not scale, so that these features are too small and incorrectly placed in the resulting bitmap.

Is there a way to tell ChartDirector to scale the chart when creating a bitmap image? Optimally, we would like to tell ChartDirector that we are creating our bitmap at, say, 600 DPI as opposed to the default 96 DPI, and have it scale fonts, line widths, axis dimensions and locations, etc., accordingly, so that the larger image is proportional to the defualt 96 DPI image?

I checked the ChartDirector documentation and didn't immediately find any support for image scaling, but if it exists, it would be a real help to me.

Sincerely,
Dave Wilson

  Re: Scaling chart images
Posted by Peter Kwan on Nov-09-2011 02:48
Hi David,

Unluckily, ChartDirector can only draw the chart image at the size your code specified. It cannot render to a bitmap image of a larger pixel size.

The issue is not really related to resolution (= number_of_pixles per inch). You can always print at any resolution you like by changing the physical size (the number of inches) of the image on paper. This is like printing a digital photo. You can always print it at any size you like. The key issue is the number_of_pixles in your case, which in case of ChartDirector is always the number of pixels specified in your code.

Although ChartDirector can output in a resolution independent format called SVG, which can be scaled to any pixel size without losing details, this format is not printable on Windows without using third party software. I know some of our customers are using this method.

Another method is to simply resize everything with your own code (resizing the canvas, font size and line width). Unluckily, it only exactly works for some charts, because some borders (eg. slice borders in pie charts) in ChartDirector are always 1 pixel in width. Anyway, it works good enough that a number of our customers are using this method.

Regards
Peter Kwan