BASIC

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

Offline hardyx

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 487
    • 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: 3515
    • 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.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

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: 3515
    • 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.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

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.