C# - XFL content: Convert .dat file to bitmap

1.1k views Asked by At

I have .fla files that use XFL format. inside there's a /bin folder with some .dat files, these files are images.

is there a way to convert these .dat file to bitmap and display them in PictureBox control?

here's an example of a dat file: link

And the corresponding image (exported from Flash) link

UPDATE: below my code:

string scenePath = "Path to .fla file";
ZipFile zip = new ZipFile(scenePath);
MemoryStream ms = new MemoryStream();

foreach (ZipEntry entry in zip)
{
    if (entry.FileName.Contains(objName))
    {
        entry.Extract(ms);

        //TODO: Need to convert the content of MemoryStream to image type!

        Bitmap bmp = new Bitmap(ms);
        pictureBoxObjView.Image = bmp;
    }
}

UPDATE2: I found a post that describe a similar issue XFL - What are the ./bin/*.dat files?. in the answer I found this :

where the decompressed data are pixels with storage type: ARGB, so with the size info it should be enough to get the image from it. It's using ZLIB compression (www.zlib.net) Flash is using compression level 1, but it's possible to use any level (but it's not necessary as the sources are normally compressed altogether.

but I still don't undestand how to convert the .dat file to bitmap !!

I tried manualy to uncompress the .fla and rename the .dat file to image ext (.jpg, .png, .bmp) to check if it's a normal image file, but I got the error "Incorrect format" when I try to open it.

My problem is how to convert the content of my MemoryStream to Bitmap?

Regards,

1

There are 1 answers

3
Oliver On

If you can extract the files from the /bin folder into a stream or byte array (which would then be encapsulated in a stream) you could call the corresponding Bitmap constructor and simply assign this bitmap to the image property of the PictureBox.