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

constructor of BufferedImage throws unexpected IllegalArgumentException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs
    • None
    • 2d
    • Fix Understood
    • sparc
    • solaris_7



      Name: atR10191 Date: 12/25/2001


      constructor public BufferedImage(int width, int height, int imageType)
      throws unexpected IllegalArgumentException when width and height are 0
      which shows the example below
      ============ Test55.java ==============================================
      import java.awt.image.BufferedImage;

      public class Test55 {
          public static void main(String argv[]) {
              try {
                   new BufferedImage(0, 0, BufferedImage.TYPE_INT_ARGB);
              } catch (Exception e) {
                  e.printStackTrace();
                  System.out.println("failed");
                  System.exit(1);
              }
              System.out.println("OKAY");
              System.exit(0);
          }
      }
      ======== end of Test55.java ==========================================
      ======== output of Test55 ==========================================
      java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0
              at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Direct
      ColorModel.java:999)
              at java.awt.image.BufferedImage.<init>(BufferedImage.java:259)
              at Test55.main(Test55.java:6)
      failed
      ======== end of output of Test55 ==========================================
      ======================================================================

            prr Philip Race
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: