Author Topic: A image encapsilation script...  (Read 2248 times)

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Female
  • Wants to write a compiler for fun
    • View Profile
A image encapsilation script...
« on: November 26, 2009, 03:44:08 AM »
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.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20015
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: A image encapsilation script...
« Reply #1 on: November 26, 2009, 10:59:56 AM »
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      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Female
  • Wants to write a compiler for fun
    • View Profile
Re: A image encapsilation script...
« Reply #2 on: November 26, 2009, 07:40:25 PM »
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.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Fantasist

  • Lexima Warrior
  • *******
  • Posts: 2223
  • LV: 146
  • Gender: Male
    • View Profile
    • Blog
Re: A image encapsilation script...
« Reply #3 on: November 26, 2009, 08:20:22 PM »
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



Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20015
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: A image encapsilation script...
« Reply #4 on: November 26, 2009, 08:51:53 PM »
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      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Female
  • Wants to write a compiler for fun
    • View Profile
Re: A image encapsilation script...
« Reply #5 on: November 26, 2009, 11: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.
« Last Edit: November 26, 2009, 11:02:16 PM by Ryexander »
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.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline fugibo

  • World Conqueror
  • Chaos User
  • ******
  • Posts: 1966
  • LV: 44
    • View Profile
Re: A image encapsilation script...
« Reply #6 on: November 27, 2009, 12:02:58 AM »
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 :/

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20015
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: A image encapsilation script...
« Reply #7 on: November 27, 2009, 12:05:24 AM »
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      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
Re: A image encapsilation script...
« Reply #8 on: November 28, 2009, 12:39:29 PM »
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*

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20015
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: A image encapsilation script...
« Reply #9 on: November 28, 2009, 01:01:59 PM »
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?!
« Last Edit: November 28, 2009, 01:22:44 PM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
Re: A image encapsilation script...
« Reply #10 on: December 02, 2009, 10:16:41 PM »
Maybe you did some automated preprocessing?

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

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Female
  • Wants to write a compiler for fun
    • View Profile
Re: A image encapsilation script...
« Reply #11 on: December 08, 2009, 04:56:50 AM »
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.
« Last Edit: December 08, 2009, 04:58:02 AM by Ryexander »
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.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20015
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: A image encapsilation script...
« Reply #12 on: December 08, 2009, 03:17:09 PM »
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      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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