|
Displaying a jpeg image |
Posted by neil on Jan-02-2011 23:38 |
|
Hi Peter,
I am using Chartdirector with VC6++ and would like to simply display a jpeg picture on the screen. I would like to have the ability to enlarge it by 2 (or keep it as a ration of 1), what is the easiest way of doing this? I will be displaying it in a CView window.
Thanks
Neil |
Re: Displaying a jpeg image |
Posted by neil on Jan-02-2011 23:40 |
|
I forgot to mention, that I will be either loading from a file, or the jpeg will be in a buffer.
Thanks
Neil |
Re: Displaying a jpeg image |
Posted by Peter Kwan on Jan-04-2011 01:32 |
|
Hi neil,
If you would like to use ChartDirector as a JPEG viewer, you may trying something like:
(a) Create a chart and use your JPEG file as the background image. The chart does not need to contain any other thing. You may see the sample code "Background and Wallpaper" on how to set a background image for a chart.
(b) Use DrawArea.resize to resize the chart, like:
DrawArea *d = c->makeChart();
d->resize(d->getWidth() * 2, d->getHeight() * 2);
Then you can display the chart as usual.
Hope this can help.
Regards
Peter Kwan |
Re: Displaying a jpeg image |
Posted by neil on Jan-04-2011 01:53 |
|
Hi peter,
Thats great, thanks.
My application has the jpeg in memory, is it possible to use this instead of reading from the drive?
Thanks
Neil |
Re: Displaying a jpeg image |
Posted by Peter Kwan on Jan-04-2011 23:45 |
|
Hi neil,
Unluckily, ChartDirector for C++ can only use a raw image (an array of pixels) in memory. It cannot use an encoded image (such as a JPEG encoded image) in memory.
Yoiu may try one of the following alternatives:
(a) Save the image from memory to a temporary file on the hard disk. ChartDirector can then load the file.
(b) Write your own code, or use another library (there are plenty of them around) to decode your in-memory JPEG image into an array of pixels (an array of integers, in which each integer represents the color of a pixel). Then you can create a "patternColor" (see BaseChart.patternColor) with the array, and use it to paint the background.
Hope this can help.
Regards
Peter Kwan |
Re: Displaying a jpeg image |
Posted by neil on Jan-05-2011 04:26 |
|
Hi Peter,
In the "background and wallpaper" example, the line:
PlotArea *plotarea = c->setPlotArea(40, 32, 200, 200);
sets the dimensions of the plot area. If the picture to load is a different size, is the plot area reduced/enlarged automatically?
Thanks
Neil |
Re: Displaying a jpeg image |
Posted by Peter Kwan on Jan-05-2011 16:21 |
|
Hi neil,
ChartDirector will obey exactly the size set by your code (the numbers in setPlotArea). The size will not be affected by a background image.
For example, a lot of our customers put a company logo at the background of the plot area. The logo is usually smaller than the plot area. In this case, the plot area size will not suddenly shrink to fit the logo, and the logo will not be stretch to fit the plot area. The plot area will stay at the size that is specified in setPlotArea, and the logo will be in its natural size.
Hope this can help.
Regards
Peter Kwan |
|