Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Compressed memblock!

Author
Message
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 14th Feb 2013 00:51 Edited at: 14th Feb 2013 20:47
Hi everyone!

These days, I have been creating two functions: Compress/uncompress memblocks and I have finally finished and I have decided to share it with you!

I think that the memblocks are an important feature, but there is one problem... their size. An image of 640x480x32 has 100-300 Kb in png format, but the memblock of this image is around 1.2Mb (640*480*4bytes)... and I think that this size is very big (especially for mobile).


Compressing memblock

The function needs the image filename and the "loss factor" (%error).

The function compares the different bytes. I have named "loss factor" to the difference between a byte and the initial byte of that serie. If two bytes are practically similar and the loss factor is the appropriate, then I consider that the bytes are identical. I have seen that a good "loss factor" is between 10-20.

This is the code...




Uncompressing memblock

You need the compressed file with the previous function (I have used the extension .img) The function returns the ID of the image.



With this code, I have gotten memblocks of 250 k (image of 640x376).

It's evident that you can use it in your applications (free cost hehe, free royalty and more...)

I hope that you like it!

Edit: I'm sorry, I have corrected the code... there were some errors. There is another problem... the load time...
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 15th Feb 2013 12:46
Hi everyone,

I have made a little AppGameKit application (it's in attachment) where you can convert an image (png or jpg) in compressed memblock. Also, you can see the compressed memblock in a sprite and so, you can see the quality.

I am trying improve the code (the load times are big)... but I don't find the readshort (for file) command.

Greetings

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-07 15:04:17
Your offset time is: 2024-05-07 15:04:17