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

Message ListMessage List     Post MessagePost Message

  Image formats and output options
Posted by Ulrich Telle on May-08-2018 21:45
Inspecting the demo code coming with ChartDirector I stumbled over a few subtleties for which I didn't find information in the ChartDirector documentation.

1) QChartViewer uses an image type Chart::QTIMG. This type is not mentioned in the documentation. I assume this is a special format to allow QT to directly load the resulting bitmap.

2) Looking for the supported image formats in the ChartDirector header file, I found another image type for which the documentation is missing: AGF. Could you explain the purpose of this format?

3) The ChartViewer of the mfcdemo uses method setOutputOptions to tweak the BMP output format. The method sets the "alpha" property. However, this option is not described in the documentation. What effect has setting "alpha" alone compared to "alpha=3"?

Thanks in advance.

Regards,

Ulrich

  Re: Image formats and output options
Posted by Peter Kwan on May-09-2018 00:27
Hi Ulrich,

ChartDirector can output the chart image in PNG, JPG, BMP, GIF, SVG and PDF.

Apart from the above, it can also output several undocumented formats. These formats are are proprietary for specific frameworks. For example, in Java, we have the java.awt.Image format. This format only useful for Java. In .NET, we have System.Drawing.Image.

For C++/QT, we have the QTIMG that works only for Qt. For C++/MFC, we have a special format implemented as an "alpha" option to BMP. For AGF, it is a format for our internal testing. (AGF is the short form of "Advanced Software Engineering Graphics Format".)

From your other post, it seems you are interested in porting to wxWidgets. You should not need any of the above formats as they are specific to QT, MFC and for our internal testing.

Regards
Peter Kwan

  Re: Image formats and output options
Posted by Ulrich Telle on May-09-2018 03:13
Hi Peter,

thanks a lot for the detailed explanation.

Indeed I intend to implement a wxChartViewer class (similar to QChartViewer or CChartViewer) for my wxWidgets-based applications. Still a bit unclear for me is how to handle transparency. AFAIK the BMP format does not support alpha transparency - probably the reason why you introduced a special format variant for MFC. However, the bitmap class of wxWidgets supports alpha transparency. So maybe your undocumented "alpha" option for the BMP type might come in handy - if I only understood the variants of this option. Alternatively, I could use the PNG format, but that would cause compressing and uncompressing the graphics data - certainly less efficient than using an uncompressed graphics format.

Regards,

Ulrich

  Re: Image formats and output options
Posted by Peter Kwan on May-09-2018 14:29
Hi Ulrich,

You are correct. BMP is fast, but there is no standard way for BMP to support transparency.

MFC actually has two different and incompatible methods to extend BMP for transparency, depending on which version of the "Windows Common Control" is used. That's why we need to detect implement different alpha modes.

(a) alpha=1 (or just "alpha") => if the image is transparent, use alpha BMP suitable for classical Windows Controls, otherwise use standard non-transparent BMP.

(b) alpha=2  => always use alpha BMP suitable for classical Windows Controls, even if the image is not transparent.

(c) alpha=3  => if the image is transparent, use alpha BMP for Windows Common Control v6, otherwise use standard non-transparent BMP.

(d) alpha=4  => always use alpha BMP for Windows Common Control v6, even if the image is not transparent.

Method (a) and (c) is faster, as it only uses transparency if necessary. However, it complicates the low level "bitblk" code, as it needs to determine whether the BMP contains alpha channel and handle them differently.

From testing, Qt does not support transparent BMP at all, so we need to use another method QTIMG.

Regards
Peter Kwan

  Re: Image formats and output options
Posted by Ulrich Telle on May-09-2018 14:45
Hi Peter,

thanks a lot for the technical details! I really appreciate your excellent support.

In principle, wxWidgets can handle transparent BMPs. So I will experiment a bit with the "alpha" output option. Hopefully I'll get it to work. I'll report back my findings.

Kind regards,

Ulrich

  Re: Image formats and output options
Posted by Ulrich Telle on Jul-09-2018 21:53
In the meantime I made already good progress in implementing a chart viewer control for wxWidgets.

I found out that wxWidgets can handle all BMP formats with alpha transparency. However, I have one further question. The MFC CChartViewer uses the following call

c->setTransparentColor(-2);

to set the transparent color, before setting the alpha output option and calling method makeChart. My question is whether the call to setTransparentColor is necessary and which value should be passed. The documentation of the method is a bit unclear. I understand that the value -1 would force the output of alpha transparency. Has the value -2 also a special meaning?

Kind regards,

Ulrich

P.S.:
Would you be interested in including wxWidgets based samples with ChartDirector, once I have finished my implementation? If not, I would consider to publish the code in my github account.

  Re: Image formats and output options
Posted by Peter Kwan on Jul-10-2018 10:09
Hi Ulrich,

The setTransparentColor(-2) has no effect if alpha option is used. So you can remove it.

The setTransparentColor(-2) is for older versions of ChartDirector that do not support the alpha option. To allow the CChartViewer.cpp to be usable by both newer and older versions of the ChartDirector DLL, we include both setTransparentColor and setOutputOption in it.

Due to the requirement of on-going support and maintenance, we probably would not include wxWidgets examples in the ChartDirector distribution in the near future. I think it is better to include it in the github. We might be interested in putting a link in our web site to your code in the "Library" section of our web page.

Regards
Peter Kwan

  Re: Image formats and output options
Posted by Ulrich Telle on Jul-12-2018 05:24
Hi Peter,

The setTransparentColor(-2) has no effect if alpha option is used. So you can remove it.

The setTransparentColor(-2) is for older versions of ChartDirector that do not support the alpha option. To allow the CChartViewer.cpp to be usable by both newer and older versions of the ChartDirector DLL, we include both setTransparentColor and setOutputOption in it.

Thanks for the explanation. Which older versions would be affected? Maybe I should keep the call, too, if it does no harm.

Due to the requirement of on-going support and maintenance, we probably would not include wxWidgets examples in the ChartDirector distribution in the near future. I think it is better to include it in the github. We might be interested in putting a link in our web site to your code in the "Library" section of our web page.

Ok, I understand your argument. I'll let you know when the github repository is available.

Regards,

Ulrich

  Re: Image formats and output options
Posted by Peter Kwan on Jul-12-2018 17:38
Hi Ulrich,

Yes, you can keep the setTransparentColor(-2). It does no harm.

In MFC, the setTransparentColor(-2) only works correct if "Windows Common Control version 6" is not used. It is because Windows use a different transparency format and memory management if "Windows Common Control version 6" is used. An executable would use "Windows Common Control version 6" only if a "manifest" is added to the EXE to specify "Windows Common Control version 6".

I believe around 2 years ago, we added the transparency format used for "Windows Common Control version 6", and added extra code to automatically select the correct format using setOutputOption.

Now the above is specific to MFC. Other frameworks may handle transparency differently. There is no standard. For example, in Qt, neither format works. So in our Qt QChartViewer, we need to implement yet another undocumented format QTIMG just for Qt transparency support.

Regards
Peter Kwan

  Re: Image formats and output options
Posted by Ulrich Telle on Jul-12-2018 22:03
Hi Peter,

Yes, you can keep the setTransparentColor(-2). It does no harm.

Thanks for the confirmation.

In MFC, the setTransparentColor(-2) only works correct if "Windows Common Control version 6" is not used. It is because Windows use a different transparency format and memory management if "Windows Common Control version 6" is used. An executable would use "Windows Common Control version 6" only if a "manifest" is added to the EXE to specify "Windows Common Control version 6".

wxWidgets applications typically add a manifest to specify WCC6.

I believe around 2 years ago, we added the transparency format used for "Windows Common Control version 6", and added extra code to automatically select the correct format using setOutputOption.

In my adaptation for wxWidgets I use the output option "alpha=3", since wxWidgets can handle BMPs both, with and without alpha transparency. However, it seems that the ChartDirector samples always return BMPs without alpha channel, when I use "alpha=3". How could I test that handling transparency works as expected?

Regards,

Ulrich

  Re: Image formats and output options
Posted by Peter Kwan on Jul-13-2018 01:22
Hi Ulrich,

ChartDirector will output the alpha channel only if the chart can be transparent (or semi-transparent). When creating the chart, please use a transparent (or semi-transparent) background color. For example:

XYChart *c = new XYChart(600, 400, Chart::Transparent);

If the background color is opaque, it is not possible for the chart to be transparent, and ChartDirector will skip the alpha channel.

(If not specified, the default background color is white and therefore the chart is opaque.)

Regards
Peter Kwan

  Re: Image formats and output options
Posted by Ulrich Telle on Jul-13-2018 01:31
Hi Peter,

thanks a lot for your support.

Regards,

Ulrich