Author Topic: Compressing a file/array by saving as PNG  (Read 22083 times)

Offline hardyx

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 500
    • View Profile
Re: Compressing a file/array by saving as PNG
« Reply #15 on: 2012-Feb-08 »
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.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3956
    • View Profile
    • Space Fractal
Re: Compressing a file/array by saving as PNG
« Reply #16 on: 2012-Feb-08 »
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 and The beagle Jam.

Offline Wampus

  • Prof. Inline
  • *****
  • Posts: 1004
    • View Profile
Re: Compressing a file/array by saving as PNG
« Reply #17 on: 2012-Feb-28 »
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.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3956
    • View Profile
    • Space Fractal
Re: Compressing a file/array by saving as PNG
« Reply #18 on: 2012-Mar-24 »
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 and The beagle Jam.

Offline Wampus

  • Prof. Inline
  • *****
  • Posts: 1004
    • View Profile
Re: Compressing a file/array by saving as PNG
« Reply #19 on: 2012-Mar-25 »
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.

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 350
  • to program what I have todo how should I program?
    • View Profile
Re: Compressing a file/array by saving as PNG
« Reply #20 on: 2021-Mar-13 »
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

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 350
  • to program what I have todo how should I program?
    • View Profile
Re: Compressing a file/array by saving as PNG
« Reply #21 on: 2021-Mar-19 »
don't worry i solved it by myself. I finally have my personalized shoebox  which uses png compression.
  :good:

Offline dreamerman

  • Global Moderator
  • Dr. Type
  • *******
  • Posts: 400
    • View Profile
    • my personal website
Re: Compressing a file/array by saving as PNG
« Reply #22 on: 2021-Mar-19 »
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

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 350
  • to program what I have todo how should I program?
    • View Profile
Re: Compressing a file/array by saving as PNG
« Reply #23 on: 2021-Mar-19 »
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