Class PixmapIO


  • public class PixmapIO
    extends java.lang.Object
    Writes Pixmaps to various formats.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  PixmapIO.PNG
      PNG encoder with compression.
    • Constructor Summary

      Constructors 
      Constructor Description
      PixmapIO()  
    • Constructor Detail

      • PixmapIO

        public PixmapIO()
    • Method Detail

      • writeCIM

        public static void writeCIM​(FileHandle file,
                                    Pixmap pixmap)
        Writes the Pixmap to the given file using a custom compression scheme. First three integers define the width, height and format, remaining bytes are zlib compressed pixels. To be able to load the Pixmap to a Texture, use ".cim" as the file suffix. Throws a GdxRuntimeException in case the Pixmap couldn't be written to the file.
        Parameters:
        file - the file to write the Pixmap to
      • readCIM

        public static Pixmap readCIM​(FileHandle file)
        Reads the Pixmap from the given file, assuming the Pixmap was written with the writeCIM(FileHandle, Pixmap) method. Throws a GdxRuntimeException in case the file couldn't be read.
        Parameters:
        file - the file to read the Pixmap from
      • writePNG

        public static void writePNG​(FileHandle file,
                                    Pixmap pixmap,
                                    int compression,
                                    boolean flipY)
        Writes the pixmap as a PNG. See PixmapIO.PNG to write out multiple PNGs with minimal allocation.
        Parameters:
        compression - sets the deflate compression level. Default is Deflater.DEFAULT_COMPRESSION
        flipY - flips the Pixmap vertically if true
      • writePNG

        public static void writePNG​(FileHandle file,
                                    Pixmap pixmap)
        Writes the pixmap as a PNG with compression. See PixmapIO.PNG to configure the compression level, more efficiently flip the pixmap vertically, and to write out multiple PNGs with minimal allocation.