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

Message ListMessage List     Post MessagePost Message

  Load BMP image in memory into DrawArea
Posted by Sal on May-09-2017 22:49
Hi Peter,

It must be so obvious, that I am totally missing the method on how to load a BMP image I created in memory programmatically using legacy MFC code into a DrawArea class and how to load the BMP from a file into the DrawArea as well.

I see methods into the class that LoadPNG, etc.. from files, not BMP

Also, I see a method that saves the image in DrawArea to File as BMP file using outBMP
and to memory using outBMP2

Finally, see the "load" function member to load files of type: png, jpg/jpeg, gif or wbmp/wmp only

What I am missing ?

---

Also, any MFC example that demonstrates and applies DrawArea::affinityTransform

Thanks
Sal

  Re: Load BMP image in memory into DrawArea
Posted by Peter Kwan on May-10-2017 15:12
Hi Sal,

Unluckily, there is no API to load a BMP image.

I think BMP is not commonly used for charting purposes - most images provided to ChartDirector are nowadays in PNG and JPG. Also, there are many types of BMP, and some of them are not standardized or documented. For example, it is not documented how to include alpha transparency in BMP. Certain Windows API can support BMP with transparency, while some Windows API will not support it. Mac OS X also supports BMP with transparency but interpreted the transparency differently from Windows. Mac OS X assumes it is "pre-multiplied alpha", while Windows assumes it is non-pre-multiplied alpha. As a result, the same BMP can render different in different OS.

To save to BMP is easy. We just choose the most standard format (the one without transparency, non-compressed, and either uses 24 bit RGB color of 8 bit palette color) and save it. To load BMP is much more tricky as we may need to support many BMP formats. As BMP is not commonly used as inputs to ChartDirector, we have not developed the code to load BMP.

For your case, if what you have is an array of pixels, you can easily incorporated it into the DrawArea or a BaseChart by using DrawArea.patternColor, the draw a rectangle using that pattern color.

http://www.advsofteng.com/doc/cdcpp.htm#DrawArea.patternColor.htm

If you have the most common BMP (non-compressed, and either uses 24 bit RGB color of 8 bit palette color), it is easy to convert it to an array of "pixels" (in this case, a pixel is a 32-bit integer representing the color of the pixel). Then you can use the above method to incorporate it into the chart.

If you do not know which type of BMP you have, you may need to use the MFC or Win32 API to load the BMP, then get the pixels in 24-bit RBG color format using GetDIBits, then use the method above to incorporate it into the chart.

Regards
Peter Kwan

  Re: Load BMP image in memory into DrawArea
Posted by Sal on May-10-2017 22:03
Peter,

Thanks for the reply about the BMP question and the suggestion about using the "DrawArea.patternColor" that I had overlooked

About the "DrawArea.affineTransform" usage, are there any MFC code samples I can take a look at ?

I am having a hard time in finding anything that can help me on my next drawing task

As always, you came to rescue
Thanks for everything

Sal
.

  Re: Load BMP image in memory into DrawArea
Posted by Peter Kwan on May-10-2017 23:32
Hi Sal,

You may add the following line in the MFC Hello World sample code, just before the chart is assigned to the CChartViewer:

c->makeChart()->affineTransform(1, 0.1, 0, 0, 1, 0);

When you view the chart, you will notice that it is "sheared" along the x-direction.

Hope this can help.

Regards
Peter Kwan