Barcode-Lib4J requires Java 9+

Java Class «BitmapImageIO»  –  PNG, JPG, BMP

java.lang.Object
de.vwsoft.barcodelib4j.image.BitmapImageIO

public class BitmapImageIO extends Object
Provides static utility methods for writing raster graphics with a specified resolution.

The specified resolution is typically written to the header of an image file, allowing graphics software to determine the image's dimensions, such as in millimeters or inches. The formats currently supported are PNG, JPEG, and BMP.

  • Method Details

    • writePNG

      public static void writePNG(RenderedImage img, OutputStream out, int dpiResX, int dpiResY) throws IOException
      Writes a rendered image in PNG format with the specified resolution.
      Parameters:
      img - the RenderedImage object to write
      out - the OutputStream to write the image data to
      dpiResX - the horizontal resolution in dots per inch (DPI)
      dpiResY - the vertical resolution in dots per inch (DPI)
      Throws:
      IOException - if an I/O error occurs during writing
    • writeJPG

      public static void writeJPG(RenderedImage img, OutputStream out, int dpiResX, int dpiResY, float quality) throws IOException
      Writes a rendered image in JPEG format with the specified resolution and quality.
      Parameters:
      img - the RenderedImage object to write
      out - the OutputStream to write the image data to
      dpiResX - the horizontal resolution in dots per inch (DPI)
      dpiResY - the vertical resolution in dots per inch (DPI)
      quality - the quality of the JPEG image (0.0f to 1.0f)
      Throws:
      IOException - if an I/O error occurs during writing
    • writeBMP

      public static void writeBMP(RenderedImage img, OutputStream out, int dpiResX, int dpiResY) throws IOException
      Writes a rendered image in BMP format with the specified resolution.
      Parameters:
      img - the RenderedImage object to write
      out - the OutputStream to write the image data to
      dpiResX - the horizontal resolution in dots per inch (DPI)
      dpiResY - the vertical resolution in dots per inch (DPI)
      Throws:
      IOException - if an I/O error occurs during writing
    • writeTIFF

      public static void writeTIFF(RenderedImage img, OutputStream out) throws IOException
      Writes a rendered image in the standard TIFF format with LZW compression.
      Parameters:
      img - the RenderedImage object to write
      out - the OutputStream to write the image data to
      Throws:
      IOException - if an I/O error occurs during writing
    • getResolution

      public static Point getResolution(ImageReader imgReader) throws IOException
      Retreives the resolution of an image.

      The formats currently supported are PNG, JPEG, and BMP.

      Parameters:
      imgReader - the ImageReader object used to read the image
      Returns:
      a Point object representing the resolution (in DPI) of the image
      Throws:
      IOException - if an I/O error occurs during reading