java.lang.Object
com.google.zxing.client.j2se.MatrixToImageWriter
Writes a
BitMatrix to BufferedImage, file or stream. Provided here instead of core since it depends on Java SE libraries.Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final MatrixToImageConfigThe config used when the caller supplies noneConstructor Summary
ConstructorsModifierConstructorDescriptionprivateUtility class, not intended for instantiation.Method Summary
All MethodsModifier and TypeMethodDescriptionstatic BufferedImagetoBufferedImage(BitMatrix matrix) Renders aBitMatrixas an image, where "false" bits are rendered as white, and "true" bits are rendered as black.static BufferedImagetoBufferedImage(BitMatrix matrix, MatrixToImageConfig config) AstoBufferedImage(BitMatrix), but allows customization of the output.static voidwriteToPath(BitMatrix matrix, String format, Path file) Writes aBitMatrixto a file with default configuration.static voidwriteToPath(BitMatrix matrix, String format, Path file, MatrixToImageConfig config) AswriteToPath(BitMatrix, String, Path), but allows customization of the output.static voidwriteToStream(BitMatrix matrix, String format, OutputStream stream) Writes aBitMatrixto a stream with default configuration.static voidwriteToStream(BitMatrix matrix, String format, OutputStream stream, MatrixToImageConfig config) AswriteToStream(BitMatrix, String, OutputStream), but allows customization of the output.
Field Details
DEFAULT_CONFIG
The config used when the caller supplies none
Constructor Details
MatrixToImageWriter
private MatrixToImageWriter()Utility class, not intended for instantiation.
Method Details
toBufferedImage
Renders aBitMatrixas an image, where "false" bits are rendered as white, and "true" bits are rendered as black. Uses default configuration.- Parameters:
matrix-BitMatrixto write- Returns:
BufferedImagerepresentation of the input
toBufferedImage
AstoBufferedImage(BitMatrix), but allows customization of the output.- Parameters:
matrix-BitMatrixto writeconfig- theMatrixToImageConfigsupplying the colors and color model- Returns:
BufferedImagerepresentation of the input
writeToPath
Writes aBitMatrixto a file with default configuration.- Parameters:
matrix-BitMatrixto writeformat- the ImageIO format name, e.g. PNGfile- filePathto write image to- Throws:
IOException- if writes to the stream fail- See Also:
writeToPath
public static void writeToPath(BitMatrix matrix, String format, Path file, MatrixToImageConfig config) throws IOException AswriteToPath(BitMatrix, String, Path), but allows customization of the output.- Parameters:
matrix-BitMatrixto writeformat- the ImageIO format name, e.g. PNGfile- filePathto write image toconfig- theMatrixToImageConfigsupplying the colors and color model- Throws:
IOException- if writes to the file fail
writeToStream
public static void writeToStream(BitMatrix matrix, String format, OutputStream stream) throws IOException Writes aBitMatrixto a stream with default configuration.- Parameters:
matrix-BitMatrixto writeformat- the ImageIO format name, e.g. PNGstream-OutputStreamto write image to- Throws:
IOException- if writes to the stream fail- See Also:
writeToStream
public static void writeToStream(BitMatrix matrix, String format, OutputStream stream, MatrixToImageConfig config) throws IOException AswriteToStream(BitMatrix, String, OutputStream), but allows customization of the output.- Parameters:
matrix-BitMatrixto writeformat- the ImageIO format name, e.g. PNGstream-OutputStreamto write image toconfig- theMatrixToImageConfigsupplying the colors and color model- Throws:
IOException- if writes to the stream fail