A image encapsilation script...

Started by Ryex, November 25, 2009, 08:44:08 pm

Previous topic - Next topic

Ryex

I had a random Idea to day and it is one of those "why has none thought of this before now" ones. the thing is if it seems simple but has never been done there may be a reason. so I'm going to explain my idea and the more experienced than me people can tell me if it is good or not.

you know how big games often compress their graphics in to smaller collections that contain them?
why can't we do this in RMXP?
as far as I can see it would be fairly simple to do.

step 1: finish your game and have it ready for distribution.
step 2: use a script to one by one load all the images in the graphics folder separate them out and then dump a bunch of bitmap instance to a file. as each file is dumped ad the information as to which images are stored in said file to a master table that is later dumped into a file of its own.
step 3: over write the RPG::Cache Module to first search the the master table file and if it finds it then pull the bitmap from the appropriate file.

seems simple enough but what would the side effects be?
aka would this use up a lot of disk space because the images would take up more space?
would it simply not work?
that sort of thing.

one benefit I can see from this is that it would make it a lot easier to update you game if you only need to add and or modify a few graphics. you just update the collection files and the master table.
the other benefit is no average user will be able to obtain you images

well what do you think?
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

I already tried it and the compression effects are maybe 1% - 2%. The graphics are already .png and .jpg which are compressed formats. Further compression doesn't really help. Ever tried compressing an mp3? You get the same effect.
Besides, the rgssad archive is already compressed as well.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

so you don't think that it is worth the benefits?
and I'm not talking about putting them in that archive as that would make it harder to to updates.
I just thinking that the files would be in that same place they had always been but they would be collected in to configurable connections ie. all the base body sprites in Remexos would be inside a file named bodys.rxdata and all the armor or not even maybe a certain type of armor was inside a file called <type>_armor.rxdata
see what i'm getting at?
that way when we needed to update the game we could just tell the updater which collections had changed and it could download and replace them and replace the master table file with the new ones and every thing would work. as you know it take substantially longer to DL several hundred small files than it dose to DL a few large file that are equivalent to the same size. that's my experience at least.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Fantasist

I've had almost exactly the same idea about image compression, but I didn't even try because of what Blizz said.

About your idea of separating the graphics into 'packs': RGSSAD is already protecting the files. If updating small portions is really the concern, we could just script something that would read the RGSSAD archive AND some other source (the "Graphics\" folder structure, or a ZIP file containing the folder structure). That way, you release the game with the RGSSAD file. If you want to upgrade or add graphics, you simply release a ZIP file containing the pics in proper hierarchy as in the Graphics folder. The script would give preference to this additional source, so any new files are used instead of using the ones from the RGSSAD archive. Of course, if you want to encrypt the updates, simply use an encryption module like DREAM.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Blizzard

In the end you have to update the whole file either way if you don't know the internal structure of it.
And the "benefits" aren't even close to being worth it. Increased (and notable!) loading times of images due to the decompression process and internal archive searching compared to 1% more disk space requirement aren't what I would call a good thing.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

November 26, 2009, 04:00:22 pm #5 Last Edit: November 26, 2009, 04:02:16 pm by Ryexander
wait are you saying that the the graphics folder is already added to the RGSS encrypted archive? *does a test* .... it is...
well that means that this idea is dumped.
perhaps we just need something better than rgssad.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

fugibo

Quote from: Ryexander on November 26, 2009, 04:00:22 pm
wait are you saying that the the graphics folder is already added to the RGSS encrypted archive? *does a test* .... it is...
well that means that this idea is dumped.
perhaps we just need something better than rgssad.


No, you need to learn how to patch a file :/

Blizzard

Well, I do have that one thing... <_<; But it's not like I am going to release it publicly.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Zeriab

The RGSSAD archive is not compressed. It's only encrypted.
Scripts.rxdata is compressed, but the other .rxdata files are not.
You can compress them with Zlib::Deflate.deflate and Zlib::Inflate.inflate and then decompress them before loading them.
I have tried it on a commercial RMXP game and shaved the Data folder size from 5 MB down to 1 MB with no noticeable difference in speed. (The whole game went from 85 MB to 81 MB which I considered so insignificant that I didn't bother publishing my method)

As for your idea I do not think it's a worse idea than normally since the graphic loading surely is written in C or C++.
Intuitively I would think that you could not get any real benefit from it. It is true that compressing images can decrease loading times simply because it's so much faster to decompress a .png in the memory than it is to load the corresponding bitmap from the harddrive.

*hugs*

Blizzard

November 28, 2009, 06:01:59 am #9 Last Edit: November 28, 2009, 06:22:44 am by Blizzard
You're right, it really isn't compressed. O_o I remembered that it sized down my data folder after encrypting. I probably just made a mistake.

EDIT: Your signature has changed... WHO ARE YOU AND WHAT HAVE YOU DONE WITH ZERIAB?!
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Zeriab

Maybe you did some automated preprocessing?

The old sig is dead  :'(
I haven't done anything to Zeriab though!

Ryex

December 07, 2009, 09:56:50 pm #11 Last Edit: December 07, 2009, 09:58:02 pm by Ryexander
could a file containing several bitmaps be compress with zlib and then encrypted with DREAM?
I'm not really caring about the practicality of doing it.  just wondering if it would be possible and what he effects would be.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

Yeah, it can be done. You'd need to put them all in one bytestream and have some way to distinguish the parts which are different bitmaps. Or you could simply read bitmaps and put them all into one stream to save them as one file. DREAM won't work because DREAM is for RMXP classes. It's actually a serializer more than an encryptor. >.< In any case the benefit of multiple bitmaps in one file and then zipped may decrease the file size by 1%-2% in comparison to each bitmap zipped separately. I've tried that already. Also, PNG compression is better than zip. So a PNG is smaller than a zipped BMP.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.