Compressing a file/array by saving as PNG

Previous topic - Next topic

hardyx

Quote from: Kitty Hello on 2012-Feb-07
just remove the last 2 calls?
I think so. If you are creating an RGB file you don't need a palette. Palette is only for indexed colours, that is, when the pixels are indexes.

spacefractal

I did not meant 16bit for each color, more when graphics set to rgb 565 format (64k colors). I have seen example in blitzmax, colors might been reduced under loading.

So it's must not load directly to hardware, but to memory? Hence no color loss.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Wampus

I modified the original code to describe what was happening on the screen as it compresses the example file. Should make more sense now. I also modified the way files are saved so that the extra data the routine needs to decompress a PNG to an array is included in the PNG file itself. If that doesn't make sense, er, just download the new attached zip file to the original post and use that version instead of the old.

spacefractal

I have still not tried this code, since I are not need to do. Today I have used samething to manipulate a png image to scramble it and reload it. Howover while rgb works fine, alpha got changed. So using alpha as data should not been used, but I can see its have been commented out as well.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Wampus

Ah, so I take it you are trying to use scrambling to protect your image data from content thieves? Nice idea.

I'm not sure why that technique wouldn't work. However, using the routine I posted I haven't come across any data corruption on any of my test devices. As it is, it works.

Qedo

I am interested in compressing a file using Png compression but unfortunately the source is no longer available on the forum.
It shouldn't be hard to rewrite it but I wouldn't want to reinvent the wheel.
Could someone please, Wampus ?, make it available on the forum?
Thank you
Ad maiora

Qedo

don't worry i solved it by myself. I finally have my personalized shoebox  which uses png compression.
  :good:

dreamerman

If You can don't forget to share it here ;) Every code, specially with some tricks can learn us something.
Can it store multiple files? I'm not sure if there is some Mem2Sound function so does it support different file types or only images, maybe with some encoding for protection.
Check my source code editor for GLBasic - link Update: 20.04.2020

Qedo

when it is finished I will definitely share it  :good:. Now I'm optimizing the speed because it's a bit slow at the moment. The customized shoebox is written in pure GLBasic and therefore, since the Mem2Sound command is not present, the sound files will not be managed normally. However, the logic of the program is this:
all files in the Media folder will be compressed with png logic. Once unpacked, only the bmp, jpg, png files can be managed thanks to Mem2Sprite in the program, while all the others must be saved unpacked in the same Media folder.
ad maiora