Package java.awt.color

Examples of java.awt.color.ColorSpace


    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }
   
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    op = new ColorConvertOp(cs, null);
    try
    {
      op.createCompatibleDestRaster(src);
      harness.check(false);
View Full Code Here


 
  private void colorModelTest(TestHarness harness, int cspace1, int cspace2)
  {
    harness.checkPoint("two colorspaces defined, " + cspace1     + ", " + cspace2);

    ColorSpace cs = ColorSpace.getInstance(cspace1);
    ColorSpace cs2 = ColorSpace.getInstance(cspace2);
    ColorConvertOp op = new ColorConvertOp(cs, cs2, null);
    int bands = cs2.getNumComponents();

    Raster src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, bands, new Point(5, 5));

    try
    {
      Raster dst = op.createCompatibleDestRaster(src);
      harness.check(dst.getHeight(), src.getHeight());
      harness.check(dst.getWidth(), src.getWidth());
      harness.check(dst.getNumBands(), bands);
      harness.check(dst.getTransferType(), DataBuffer.TYPE_BYTE);
      harness.check(dst.getDataBuffer().getDataType(), DataBuffer.TYPE_BYTE);
      harness.check(dst.getNumDataElements(), cs2.getNumComponents());
      harness.check(dst.getSampleModel() instanceof PixelInterleavedSampleModel);
      harness.check(dst.getDataBuffer() instanceof DataBufferByte);
     
      PixelInterleavedSampleModel sm = (PixelInterleavedSampleModel)dst.getSampleModel();

      harness.check(sm.getPixelStride(), cs2.getNumComponents());
      harness.check(sm.getScanlineStride(), cs2.getNumComponents() * src.getWidth());
      int[] expected = new int[cs2.getNumComponents()];
     
      for (int i = 0; i < expected.length; i++)
        expected[i] = i;
      harness.check(Arrays.equals(sm.getBandOffsets(), expected));
     
      harness.check(dst.getDataBuffer().getNumBanks(), 1);
      harness.check(dst.getDataBuffer().getOffset(), 0);
      harness.check(dst.getDataBuffer().getSize(), src.getHeight() * src.getWidth() * cs2.getNumComponents());
     
    }
    catch (IllegalArgumentException e)
    {
      harness.check(false);
    }
   
    // Try a different type
    src = Raster.createBandedRaster(DataBuffer.TYPE_USHORT, 25, 40, bands, new Point(5, 5));
    try
    {
      Raster dst = op.createCompatibleDestRaster(src);
      harness.check(dst.getNumBands(), bands);
      harness.check(dst.getTransferType(), DataBuffer.TYPE_BYTE);
      harness.check(dst.getDataBuffer().getDataType(), DataBuffer.TYPE_BYTE);
      harness.check(dst.getNumDataElements(), cs2.getNumComponents());
      harness.check(dst.getSampleModel() instanceof PixelInterleavedSampleModel);
      harness.check(dst.getDataBuffer() instanceof DataBufferByte);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(false);
    }
   
    // Try different number of bands in the source; the destination should
    // ignore this and always have ColorSpace.getNumComponents() bands
    for (int i = 1; i < bands + 5; i++)
      {
        src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, i, new Point(5, 5));
        try
        {
          Raster dst = op.createCompatibleDestRaster(src);
          harness.check(dst.getNumBands(), cs2.getNumComponents());
          harness.check(dst.getNumDataElements(), cs2.getNumComponents());
        }
        catch (IllegalArgumentException e)
        {
          harness.check(false);
        }
View Full Code Here

    // Create an image to work on
    BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
    Graphics2D g = (Graphics2D)img.getGraphics();
    g.draw(new Line2D.Double(0, 0, 20, 20));
   
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorConvertOp op = new ColorConvertOp(cs, null);
   
    // Check null destination
    try
    {
View Full Code Here

    // Create an image to work on
    BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
    Graphics2D g = (Graphics2D)img.getGraphics();
    g.draw(new Line2D.Double(0, 0, 20, 20));
   
    ColorSpace cs1 = ColorSpace.getInstance(ColorSpace.CS_CIEXYZ);
    //ColorSpace cs2 = ColorSpace.getInstance(ColorSpace.CS_PYCC);
       // PYCC is not implemented
    ColorSpace cs2 = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorConvertOp op = new ColorConvertOp(cs1, cs2, null);

    // Simpler tests (ie, src != dest) are skipped, assume they work here if
    // they worked earlier
   
View Full Code Here

  }


  public void test_CS_sRGB(TestHarness h)
  {
    ColorSpace cs;

    h.checkPoint("CS_sRGB");
    cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    h.check(cs.getType(), ColorSpace.TYPE_RGB)// Check #1.
    h.check(cs.getNumComponents(), 3);           // Check #2.
    checkEpsilon(h, cs.getMinValue(0), 0.0f);    // Check #3.
    checkEpsilon(h, cs.getMaxValue(0), 1.0f);    // Check #4.
    checkEpsilon(h, cs.getMinValue(1), 0.0f);    // Check #5.
    checkEpsilon(h, cs.getMaxValue(1), 1.0f);    // Check #6.
    checkEpsilon(h, cs.getMinValue(2), 0.0f);    // Check #7.
    checkEpsilon(h, cs.getMaxValue(2), 1.0f);    // Check #8.
  }
View Full Code Here

  }


  public void test_CS_CIEXYZ(TestHarness h)
  {
    ColorSpace cs;

    h.checkPoint("CS_CIEXYZ");
    cs = ColorSpace.getInstance(ColorSpace.CS_CIEXYZ);
    h.check(cs.getType(), ColorSpace.TYPE_XYZ)// Check #1.
    h.check(cs.getNumComponents(), 3);           // Check #2.
    checkEpsilon(h, cs.getMinValue(0), 0.0f);    // Check #3.
    checkEpsilon(h, cs.getMaxValue(0), 2.0f);    // Check #4.
    checkEpsilon(h, cs.getMinValue(1), 0.0f);    // Check #5.
    checkEpsilon(h, cs.getMaxValue(1), 2.0f);    // Check #6.
    checkEpsilon(h, cs.getMinValue(2), 0.0f);    // Check #7.
    checkEpsilon(h, cs.getMaxValue(2), 2.0f);    // Check #8.
  }
View Full Code Here

  }


  public void test_CS_PYCC(TestHarness h)
  {
    ColorSpace cs;

    h.checkPoint("CS_PYCC");
    cs = ColorSpace.getInstance(ColorSpace.CS_PYCC);
    h.check(cs.getType(), ColorSpace.TYPE_3CLR); // Check #1.
    h.check(cs.getNumComponents(), 3);           // Check #2.
    checkEpsilon(h, cs.getMinValue(0), 0.0f);    // Check #3.
    checkEpsilon(h, cs.getMaxValue(0), 1.0f);    // Check #4.
    checkEpsilon(h, cs.getMinValue(1), 0.0f);    // Check #5.
    checkEpsilon(h, cs.getMaxValue(1), 1.0f);    // Check #6.
    checkEpsilon(h, cs.getMinValue(2), 0.0f);    // Check #7.
    checkEpsilon(h, cs.getMaxValue(2), 1.0f);    // Check #8.
  }
View Full Code Here

  }


  public void test_CS_GRAY(TestHarness h)
  {
    ColorSpace cs;

    h.checkPoint("CS_GRAY");
    cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    h.check(cs.getType(), ColorSpace.TYPE_GRAY); // Check #1.
    h.check(cs.getNumComponents(), 1);           // Check #2.
    h.check(cs.getMinValue(0), 0.0f);            // Check #3.
    h.check(cs.getMaxValue(0), 1.0f);            // Check #4.
  }
View Full Code Here

  }


  public void test_CS_LINEAR_RGB(TestHarness h)
  {
    ColorSpace cs;

    h.checkPoint("CS_LINEAR_RGB");
    cs = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
    h.check(cs.getType(), ColorSpace.TYPE_RGB)// Check #1.
    h.check(cs.getNumComponents(), 3);           // Check #2.
    checkEpsilon(h, cs.getMinValue(0), 0.0f);    // Check #3.
    checkEpsilon(h, cs.getMaxValue(0), 1.0f);    // Check #4.
    checkEpsilon(h, cs.getMinValue(1), 0.0f);    // Check #5.
    checkEpsilon(h, cs.getMaxValue(1), 1.0f);    // Check #6.
    checkEpsilon(h, cs.getMinValue(2), 0.0f);    // Check #7.
    checkEpsilon(h, cs.getMaxValue(2), 1.0f);    // Check #8.
  }
View Full Code Here

  private void simpleTest(TestHarness harness)
  {
    harness.checkPoint("createCompatibleDestImage");

    // Simple test
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorConvertOp op = new ColorConvertOp(cs, null);
   
    BufferedImage img = new BufferedImage(25, 40, BufferedImage.TYPE_INT_RGB);
    BufferedImage dest = op.createCompatibleDestImage(img, img.getColorModel());
   
View Full Code Here

TOP

Related Classes of java.awt.color.ColorSpace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.