Barcode-Lib4J requires Java 9+
Package de.vwsoft.barcodelib4j.image
Java Class «BitmapImageIO» – PNG, JPG, BMP
java.lang.Object
de.vwsoft.barcodelib4j.image.BitmapImageIO
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 Summary
Modifier and TypeMethodDescriptionstatic Point
getResolution
(ImageReader imgReader) Retreives the resolution of an image.static void
writeBMP
(RenderedImage img, OutputStream out, int dpiResX, int dpiResY) Writes a rendered image in BMP format with the specified resolution.static void
writeJPG
(RenderedImage img, OutputStream out, int dpiResX, int dpiResY, float quality) Writes a rendered image in JPEG format with the specified resolution and quality.static void
writePNG
(RenderedImage img, OutputStream out, int dpiResX, int dpiResY) Writes a rendered image in PNG format with the specified resolution.static void
writeTIFF
(RenderedImage img, OutputStream out) Writes a rendered image in the standard TIFF format with LZW compression.
-
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
- theRenderedImage
object to writeout
- theOutputStream
to write the image data todpiResX
- 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
- theRenderedImage
object to writeout
- theOutputStream
to write the image data todpiResX
- 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
- theRenderedImage
object to writeout
- theOutputStream
to write the image data todpiResX
- 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
Writes a rendered image in the standard TIFF format with LZW compression.- Parameters:
img
- theRenderedImage
object to writeout
- theOutputStream
to write the image data to- Throws:
IOException
- if an I/O error occurs during writing
-
getResolution
Retreives the resolution of an image.The formats currently supported are PNG, JPEG, and BMP.
- Parameters:
imgReader
- theImageReader
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
-