Compressing some data

Discussion in 'Game Development (Technical)' started by Raptisoft, Aug 9, 2004.

  1. Raptisoft

    Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    804
    Likes Received:
    0
    Hi all,

    I have a question and am looking for advice. I'm looking for a way to apply zip (or preferably, LZMA) compression to a block of memory. That is to say, I do NOT want to produce a file, I want essentially say:

    theMemory=new char[10000];
    //
    // Fill 'theMemory' with data
    //
    char *newMemory=Compress(theMemory);

    and then do:

    char *restoreMemory=UnCompress(newMemory);

    * * *

    As far as I know, none of the existing compression SDKs will compress a hunk of memory-- they're all file writes (am I correct? I haven't researched this extensively). I know I'll need to write up my own stuff, but I wondered if anyone has a good link to a nice hold-my-hand tutorial on how to do this shtuff?

    Thanks in advance!
     
  2. Nikster

    Original Member

    Joined:
    Jul 27, 2004
    Messages:
    698
    Likes Received:
    0
    This should be what you want SDK wise, not sure how extensive the tutorials are but it's simple to get working IMHO.
     
  3. Jim Buck

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    1,158
    Likes Received:
    0
    I'm not sure of the api you are using, but like Rapisoft said, zlib is definitely the way to go. If it's impossible, perhaps you could implement the file pointer you pass to the api (if it takes a file pointer instead of a filename) as one that actually writes to memory. For example, if it's a class, you would inherit from it and override the "write" function.
     
  4. Nemesis

    Original Member

    Joined:
    Jul 27, 2004
    Messages:
    273
    Likes Received:
    0
    Raptisoft,

    Here's one function from zlib:

    int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);

    By the looks of it.. it works from a memory source to a destination.
     
  5. Hercule

    Original Member

    Joined:
    Aug 10, 2004
    Messages:
    6
    Likes Received:
    0
    The function of Nemesis work (I did something similar myself).
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer