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

Message ListMessage List     Post MessagePost Message

  How to Load CImage that uses IStream PNG Image into a DrawArea
Posted by Sal on Aug-02-2017 05:46
Hi Peter,

Since DrawArea does not load BMP images directly, and they must be coming fwith a File from a format other than BMP, I worked out the following as workaround:

[Note: I have written code that from BMP writes a PNG File, and I load into the DrawArea - All this works, now I want to avoid the creation of this physical temporary file]

Create a BMP File (Header + other + PixelsData) programmatically in memory
This is some scientific data that I am trying to visualize

Write to IStream as PNG, since DrawArea loads many formats, but no BMP

Sometime later...

DrawArea dVision;

// Make room by using the dimension of the Area that I converted to PNG
dVision.setSize(pbmi->bmiHeader.biWidth, abs(pbmi->bmiHeader.biHeight), Chart::brushedSilverColor());

// Load the IStream Picture
CImage Image;
Image.Load(pStream);

How do I transfer the Picture in CImage into the DrawArea ?

I must be missing something
Any help is appreciated

Thanks
Sal

  Re: How to Load CImage that uses IStream PNG Image into a DrawArea
Posted by Sal on Aug-02-2017 06:07
Also,

If DrawArea.outPNG2 writes an Image to Memory, how you load into from memory back into another DrawArea ?

Thanks again
Sal

  Re: How to Load CImage that uses IStream PNG Image into a DrawArea
Posted by Peter Kwan on Aug-02-2017 20:17
Hi Sal,

According to your information, you have some "PixelsData". Then your code use it to create a BMP, and then a PNG and then a CImage and then tries to load it into DrawArea. The BMP, PNG and CImage are not necessary, as you can directly load the PixelsData into DrawArea, assuming your pixel data are an array of 32-bit integers (int *), with each integer representing a 32-bit ARGB color. (If your "pixel" is not in ARGB color, it should be easy to convert to this format.) Note that in ChartDirector, an alpha level of 0 (A = 0) means opaque, while an alpha level of 255 means completely transparent.

The code is like:

DrawArea dVision;
dVision.setSize(width, height, patternColor(IntArray(PixelsData, width * height), height));

Hope this can help.

Regards
Peter Kwan