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

WritableRaster.setPixel throw NullPointerException on type SHORT/FLOAT/DOUBLE

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • CPU:
      generic
    • OS:
      generic

      Description


      WritableRaster.setPixel throw NullPointerException when the SampleModel has data
      type SHORT, FLOAT and DOUBLE.

      import java.awt.Point;
      import java.awt.image.Raster;
      import java.awt.image.WritableRaster;
      import java.awt.image.DataBuffer;
      import java.awt.image.PixelInterleavedSampleModel;

      class Bug_RasterSetPixel {
        public static void main(String args[]) {
          int dt[] =
          {
            DataBuffer.TYPE_BYTE,
            DataBuffer.TYPE_USHORT,
            DataBuffer.TYPE_INT,
            DataBuffer.TYPE_SHORT,
            DataBuffer.TYPE_FLOAT,
            DataBuffer.TYPE_DOUBLE,
          };
          String dtStr[] =
          {
            "BYTE : ",
            "USHORT : ",
            "INT : ",
            "SHORT : ",
            "FLOAT : ",
            "DOUBLE : ",
          };
          for(int i = 0; i < dt.length; i++) {
            PixelInterleavedSampleModel sm =
              new PixelInterleavedSampleModel(dt[i], 100, 100,
              3, 3*100, new int[] {2,1,0});
            WritableRaster ras =
              Raster.createWritableRaster(sm, new Point(0, 0));
            try {
              ras.setPixel(0, 0, new int[] {45,45,45});
              System.out.println(dtStr[i] + "OK");
            } catch(Exception e) {
              System.out.println(dtStr[i] + e);
            }
          }
        }
      }

        Attachments

          Activity

            People

            Assignee:
            jehung Jeannette Hung
            Reporter:
            chialin Chianphon Lin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: