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

spec: ImageTypeSpecifier - unspecified exceptions in createGrayscale

    Details

    • Subcomponent:
    • Resolved In Build:
      tiger
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: bkR10012 Date: 06/08/2001


      Spec. of the class javax.imageio.ImageTypeSpecifier
      doesn't describe any exceptions for methods
      createGrayscale(bits, dataType, isSigned)
      createGrayscale(bits, dataType, isSigned, isAlphaPremultiplied)

      But these methods throw unexpected exceptions in following cases:

      - bits = 100;
      IllegalArgumentException: Number of bits must be between 1 and 16.

      - bits = 10; dataType = DataBuffer.TYPE_BYTE;
      java.awt.image.RasterFormatException: MultiPixelPackedSampleModel does not
      allow pixels to span data element boundaries

      - dataType = 100;
      IllegalArgumentException: Unknown data type 100

      See test source and log below.
      ---------------------------------------- test.java
      import javax.imageio.ImageTypeSpecifier;
      import java.awt.image.DataBuffer;

      public class test {

          public static void main(String argv[]) {
              test t = new test();
              t.createGrayscaleTest();
          }

          public void createGrayscaleTest() {
          int bits = 8;
          int dataType = DataBuffer.TYPE_BYTE;
          boolean isSigned = true;
      // testcase 1
              try {
                  ImageTypeSpecifier.createGrayscale(100, dataType, isSigned);
              } catch (Throwable e) {
                  System.out.println("testcase 1: " + e);
              }
       // testcase 2
              try {
                  ImageTypeSpecifier.createGrayscale(10, dataType, isSigned);
              } catch (Throwable e) {
                  System.out.println("testcase 2: " + e);
              }
      // testcase 3
              try {
                  ImageTypeSpecifier.createGrayscale(bits, 100, isSigned);
              } catch (Throwable e) {
                  System.out.println("testcase 3: " + e);
              }
         }
      }
      ----------------------------------------
      % java -version
      java version "1.4.0-beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b66)
      Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b66, mixed mode)
      % java test
      testcase 1: java.lang.IllegalArgumentException: Number of bits must be between 1
      and 16.
      testcase 2: java.awt.image.RasterFormatException: MultiPixelPackedSampleModel
      does not allow pixels to span data element boundaries
      testcase 3: java.lang.IllegalArgumentException: Unknown data type 100
      ----------------------------------------

      This bug causes failure of the new JCK test
      api/javax_imageio/ImageTypeSpecifier/index.html#createGrayscale

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                campbell Christopher Campbell (Inactive)
                Reporter:
                kuzsunw Kuz Kuz (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: