Codesnippets > Code Snippets

Compressing a file/array by saving as PNG

<< < (2/5) > >>

Kitty Hello:

--- Code: (glbasic) ---   png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB_ALPHA,
      PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);



   /* set the palette if there is one.  REQUIRED for indexed-color images */
   palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
             * sizeof (png_color));
   /* ... set palette colors ... */
   png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
   /* You must not free palette here, because png_set_PLTE only makes a link to
      the palette that you malloced.  Wait until you are about to destroy
      the png structure. */

--- End code ---

just remove the last 2 calls?

mentalthink:
HI I don´t understand very well this functions... but I think it´s a png... very compresed in a xml file?¿ sorry for my ignorance...

And a question some time ago... I comment about streaming reading great images... whit this functions can be read a bit package of info, and finaly have the complete info and draw the huge Image?¿... I read the info goes into an Array... can be possible...

Kitty Hello:
@metalthink - He uses PNG "data" to save anything. Sound, Music, Level data, ...

mentalthink:
ok, don´t understand too much, but I suppose someone in the forum put an example...   :-* :-*

Ruidesco:
He is using the compression algorithm that PNG files use for any kind of file.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version