Compress/Decompress data buffers

About Monkey 2 Forums Monkey 2 Programming Help Compress/Decompress data buffers

This topic contains 11 replies, has 5 voices, and was last updated by  Mark Sibly 1 month, 2 weeks ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #14398

    PixelPaladin
    Participant

    Is it possible to compress/decompress data from/into a data buffer?

    I would like to do something like that:

    #14417

    nerobot
    Participant

    There is the miniz module.

    And example of its usage here:

    https://github.com/blitz-research/monkey2/blob/develop/modules/std/misc/zipfile.monkey2

    #14419

    Mark Sibly
    Keymaster

    It’s probably time I added a zlib module – will do this soon so stay tuned for compress/decompress data buffer methods.

    #14430

    Mark Sibly
    Keymaster

    New zlib module and data buffer compress/decompress methods have been pushed to develop branch.

    #14465

    PixelPaladin
    Participant

    Wow – that was fast!

    I already tried it and it works like a charm:

    #14713

    peterigz
    Participant

    Is there anyway yet to load an image straight from a zip file without the need to extract it to disk first?

    #14714

    Mark Sibly
    Keymaster

    See below for one possible solution. It loads a jpg image directly from a zip file.

    It’s not very nice though, a simple ‘zip::’ stream would be sexier, or even some way to pass a DataStream to Image.Load. Will look into this…

    #14718

    peterigz
    Participant

    zip::stream sounds awesome if you can add that 🙂

    Thanks for the example, didn’t know about memory:: looks like something I could use in the meantime.

    It was really cool in Blitzmax the way you could pass either a string or object to the image loader and it would handle it, so would be a nice feature to have. I’m looking to update TimelineFX to be able to load .eff files (basically zip files) rather then the need to unpack them first.

    #14721

    Mark Sibly
    Keymaster

    Ok, haven’t done zip:: stream yet but you can now use Stream.SharedPath to get a unique path to an already open stream. This means the zipfile stuff is a lot nicer:

    #14723

    peterigz
    Participant

    That’s great Mark, thanks.

    So if I wanted to save a zip would I compress stuff to a data buffer as above and then save the databuffer to disk, would that work?

    #14724

    Diffrenzy
    Keymaster

    @peterigz:

    I’m looking to update TimelineFX to be able to load .eff files (basically zip files) rather then the need to unpack them first.

    That would be awesome, because the editor does not export unzipped, and it is a bit of a hazzle, when you are finetuning effects.

    PS: When you update, please make it work with tinyxml2 out of the box, just a tlXmlElement will do it if you don’t wan’t to use tinyxml2.

    #14725

    Mark Sibly
    Keymaster

    So if I wanted to save a zip

    More functionality will need to be added to the ZipFile class before this can (easily) be done.

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.