StiImage Serialization

Stimulsoft Reports.Flex discussion
Locked
ke4ktz
Posts: 4
Joined: Thu Feb 07, 2013 3:09 pm

StiImage Serialization

Post by ke4ktz »

I am writing a (one-way) conversion utility to convert reports from our custom system into XML that can be used by the Stimulsoft viewier and designer. I'm having an issue getting the Image (aka, StiImage) token to be accepted by the Stimulsoft viewer.

Can anyone direct me to the code that the Stimulsoft designer uses to serialize the StiImage objects? I need to be able to have the converter utility serialize our report image data in the same format.

Thanks.

...Glenn
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: StiImage Serialization

Post by HighAley »

Hello.

The Images are stored in Base64 format.

Thank you.
ke4ktz
Posts: 4
Joined: Thu Feb 07, 2013 3:09 pm

Re: StiImage Serialization

Post by ke4ktz »

Can you provide a bit more detail?

I am using Base64 but the output that I get in the XML does not match the output that is generated from the Stimulsoft designer. We have the full source but I am not able to find out where the serailization takes place. I was hoping someone could guide me to the correct class and/or method so that I could generate the same output.

As it stands now, the report does not load in the viewer with the Base64-generated output that I create.

...Glenn
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: StiImage Serialization

Post by HighAley »

Hello.

What pictures format do you use? Could you send us a sample image? And a report sample that you've got.

Thank you.
ke4ktz
Posts: 4
Joined: Thu Feb 07, 2013 3:09 pm

Re: StiImage Serialization

Post by ke4ktz »

I am using a standard jpeg image and am converting it using C# with the following code:

Code: Select all

            var image = Image.FromFile(pathToImage);
            return image.ToBase64();
The output in my XML looks like the following:

Code: Select all

<Image>Qk32JwkAAAAAADYAAAAoAAAA9AEAAJABAAABABgAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAAAz8DBD8CBj8AA0AABD8CBEAACD8ABD8CBD8CBD8CBD8CBD
8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD
   ... <snip> ...
AABEAABD8CBD8CBD8CBD8CBD8CBD8CAz4BBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD8CBD
8CBD8CBD8CBD8CBD8CAz8CBD8C</Image>
When I update the report in the Stimulsoft designer and select the very same image file, the output in the XML looks like the following:

Code: Select all

<Image>iVBORw0KGgoAAAANSUhEUgAAAfQAAAGQCAYAAABYs5LGAAHVOUlEQVR42uy993dUV7Yu2un0+zfeeOP98sZ9955zz+ljt3PECQO2wSYKkBAClEOJDCIqZySQBIo
oAgpkEEG5SioFUEagVIqAJJIxuO0+b7415wp775KAciMwPi0Ya1SpalfVDmuvb4ZvfvN3f3jvD/D79/8Mv/sABz7/E3tk4/3/g57PjKcPec7o+fu/Y4/yfP5JnFN8/Y/0Gt/uz2Ib
   ... <snip> ...
JHgUyqH6Hb9mMBiL4w97/yQu9/yJ3kf/sld9D+39V/oZvqfo/bTPfV1xPd1tKL/7x33/SpcS7p//0fA78mfG6yz8t/b9fQvB/28Mxu8Eu/8kWu3K13/a/W/w/wEKwvtf7jKrn
wAAAABJRU5ErkJggg==</Image>
The size of my data is approximately 800k whereas the Stimulsoft output is approximately 150k.

...Glenn
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: StiImage Serialization

Post by HighAley »

Hello.

Please, try to use next code:
using (MemoryStream ms = new MemoryStream())

Code: Select all

{
    image.Save(ms, ImageFormat.Jpeg);
    string base64 = Convert.ToBase64String(ms.ToArray());
}
Thank you.
ke4ktz
Posts: 4
Joined: Thu Feb 07, 2013 3:09 pm

Re: StiImage Serialization

Post by ke4ktz »

SUCCESS!!!

Thank you, Aleksey. That worked.

...Glenn
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: StiImage Serialization

Post by HighAley »

Hello.

We are always glad to help you.
Let us know if you will need any additional help.

Thank you.
Locked