Class MatrixToImageWriter


  • public final class MatrixToImageWriter
    extends java.lang.Object
    Writes a BitMatrix to BufferedImage, file or stream. Provided here instead of core since it depends on Java SE libraries.
    • Constructor Detail

      • MatrixToImageWriter

        private MatrixToImageWriter()
    • Method Detail

      • toBufferedImage

        public static java.awt.image.BufferedImage toBufferedImage​(BitMatrix matrix)
        Renders a BitMatrix as an image, where "false" bits are rendered as white, and "true" bits are rendered as black. Uses default configuration.
        Parameters:
        matrix - BitMatrix to write
        Returns:
        BufferedImage representation of the input
      • toBufferedImage

        public static java.awt.image.BufferedImage toBufferedImage​(BitMatrix matrix,
                                                                   MatrixToImageConfig config)
        As toBufferedImage(BitMatrix), but allows customization of the output.
        Parameters:
        matrix - BitMatrix to write
        config - output configuration
        Returns:
        BufferedImage representation of the input
      • writeToFile

        @Deprecated
        public static void writeToFile​(BitMatrix matrix,
                                       java.lang.String format,
                                       java.io.File file)
                                throws java.io.IOException
        Parameters:
        matrix - BitMatrix to write
        format - image format
        file - file File to write image to
        Throws:
        java.io.IOException - if writes to the file fail
      • writeToPath

        public static void writeToPath​(BitMatrix matrix,
                                       java.lang.String format,
                                       java.nio.file.Path file)
                                throws java.io.IOException
        Writes a BitMatrix to a file with default configuration.
        Parameters:
        matrix - BitMatrix to write
        format - image format
        file - file Path to write image to
        Throws:
        java.io.IOException - if writes to the stream fail
        See Also:
        toBufferedImage(BitMatrix)
      • writeToPath

        public static void writeToPath​(BitMatrix matrix,
                                       java.lang.String format,
                                       java.nio.file.Path file,
                                       MatrixToImageConfig config)
                                throws java.io.IOException
        As writeToPath(BitMatrix, String, Path), but allows customization of the output.
        Parameters:
        matrix - BitMatrix to write
        format - image format
        file - file Path to write image to
        config - output configuration
        Throws:
        java.io.IOException - if writes to the file fail
      • writeToStream

        public static void writeToStream​(BitMatrix matrix,
                                         java.lang.String format,
                                         java.io.OutputStream stream)
                                  throws java.io.IOException
        Writes a BitMatrix to a stream with default configuration.
        Parameters:
        matrix - BitMatrix to write
        format - image format
        stream - OutputStream to write image to
        Throws:
        java.io.IOException - if writes to the stream fail
        See Also:
        toBufferedImage(BitMatrix)
      • writeToStream

        public static void writeToStream​(BitMatrix matrix,
                                         java.lang.String format,
                                         java.io.OutputStream stream,
                                         MatrixToImageConfig config)
                                  throws java.io.IOException
        As writeToStream(BitMatrix, String, OutputStream), but allows customization of the output.
        Parameters:
        matrix - BitMatrix to write
        format - image format
        stream - OutputStream to write image to
        config - output configuration
        Throws:
        java.io.IOException - if writes to the stream fail