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

PixelGrabber.setColorModel(ColorModel) - ColorModels returned are not correct

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs
    • 2d
    • x86
    • windows_nt



      Name: el35337 Date: 04/21/98


      Always returns DirectColorModel (may be based on MemoryImageSource used as source for the PixelGRabber...see code).

      Code used:

      byte[] indexArray = new byte[256];

      for (int i=0; i<indexArray.length; i++) {
      indexArray[i] = (byte)i;
      }

      int[] bitArray = {8,8,8};
      int[] maskArray = {0xff0000,0x00ff00,0x0000ff};

      ColorModel[] cms = {
      new IndexColorModel(24,8,indexArray,indexArray,indexArray,-1),
      new ComponentColorModel(new ICC_ColorSpace(ICC_Profile.getInstance(ColorSpace.CS_sRGB)),bitArray,false,
      false,-1),
      new DirectColorModel(24,0xff0000,0x00ff00,0x0000ff)
      };

      int[] testPixels = new int[1000];

      for (int i=0; i<testPixels.length; i++) {
      testPixels[i] = 0xffffff;
      }

      DirectColorModel dCM = new DirectColorModel(24,0xff0000,0x00ff00,0x0000ff);

      MemoryImageSource source = new
      MemoryImageSource(50,50,dCM,testPixels,0,50);

      int x,y,w,h;

      x = 10;
      y = 10;
      w = 10;
      h = 10;

      ColorModel currentCM = null;

      int[] pix = new int[1000];

      PixelGrabber pg = new PixelGrabber(
      source,
      x,
      y,
      w,
      h,
      pix,
      0,
      w
      );


      for (int i=0; i<cms.length; i++) {

      currentCM = cms[i];

      pg.setColorModel(currentCM);

      result = (pg.getColorModel() == currentCM);

      if (!result) {
      msg += "PixelGrabber(" +
      "new image (10,10) with all pixels == 0xffffff, " +
      x + ", " +
      y + ", " +
      w + ", " +
      h + ", " +
      "new int[1000], " +
      0 + ", " +
      w + ", " +
      ").setColorModel(" +
      currentCM +
      ") " +
      "\nreturned " + pg.getColorModel() +
      ". It should have returned " +
      currentCM +
      "\n";

                           System.out.println(msg + "\n");
      }
      (Review ID: 27734)
      ======================================================================

            flar Jim Graham
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: