Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8302151

BMPImageReader throws an exception reading BMP images

    XMLWordPrintable

Details

    • b02
    • b11
    • generic
    • generic

    Backports

      Description

        ADDITIONAL SYSTEM INFORMATION :
        Windows 10, Java 19.0.2

        A DESCRIPTION OF THE PROBLEM :
        A black and white BMP image from multiple TWAIN scanners throws this exception:

        javax.imageio.IIOException: Invalid width/height for BI_RGB image data.
        at java.desktop/com.sun.imageio.plugins.bmp.BMPImageReader.readHeader(BMPImageReader.java:621)
        at java.desktop/com.sun.imageio.plugins.bmp.BMPImageReader.read(BMPImageReader.java:859)
        at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1466)
        at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1315)
        at com.usdataworks.javaplay.ReadBmpFromTwainScanner.main(ReadBmpFromTwainScanner.java:14)


        REGRESSION : Last worked in version 11

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the attached source code on a bitonal (1 bit per pixel) BMP images from a TWAIN scanner.
        I can provide an image if needed.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        BMP image file is read into a BufferedImage.
        ACTUAL -
        This exception is thrown:

        javax.imageio.IIOException: Invalid width/height for BI_RGB image data.
        at java.desktop/com.sun.imageio.plugins.bmp.BMPImageReader.readHeader(BMPImageReader.java:621)
        at java.desktop/com.sun.imageio.plugins.bmp.BMPImageReader.read(BMPImageReader.java:859)
        at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1466)
        at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1315)
        at com.usdataworks.javaplay.ReadBmpFromTwainScanner.main(ReadBmpFromTwainScanner.java:14)


        ---------- BEGIN SOURCE ----------
        package com.usdataworks.javaplay;

        import java.awt.image.BufferedImage;
        import java.io.File;
        import java.io.IOException;

        import javax.imageio.ImageIO;

        public class ReadBmpFromTwainScanner {

        public static void main(String[] args) {
        try {
        File input = new File("The Scanner Image 1675710585648.bmp");
        BufferedImage theImage = ImageIO.read(input);
        System.out.println("theImage width=" + theImage.getWidth() + " height=" + theImage.getHeight());
        } catch (IOException e) {
        e.printStackTrace();
        }
        }
        }

        ---------- END SOURCE ----------

        FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

                jdv Jayathirth D V
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: