Package java.awt.image

Examples of java.awt.image.IndexColorModel


   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)  
  {
    IndexColorModel m1 = new IndexColorModel(2, 4, R4, G4, B4);
    harness.check(m1.getPixelSize(), 2);

    IndexColorModel m2 = new IndexColorModel(2, 4, R4, G4, B4, 2);
    harness.check(m2.getPixelSize(), 2);

    IndexColorModel m3a = new IndexColorModel(2, 4, CMAP, 0, false);
    harness.check(m3a.getPixelSize(), 2);

    IndexColorModel m3b = new IndexColorModel(2, 4, CMAP, 0, false, 1);
    harness.check(m3b.getPixelSize(), 2);

    IndexColorModel m4 = new IndexColorModel(2, 4, CMAP_WITH_ALPHA, 0, true);
    harness.check(m4.getPixelSize(), 2);

    IndexColorModel m5 = new IndexColorModel(2, 4, CMAP_WITH_ALPHA0, 0, true);
    harness.check(m5.getPixelSize(), 2);

    IndexColorModel m6 = new IndexColorModel(2, 4, CMAP_WITH_ALPHA1, 0, true);
    harness.check(m6.getPixelSize(), 2);
 
View Full Code Here


   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness
  {
    IndexColorModel m1 = new IndexColorModel(2, 4, R4, G4, B4);
    harness.check(m1.getColorSpace().isCS_sRGB());
   
    IndexColorModel m2 = new IndexColorModel(2, 4, R4, G4, B4, 2);
    harness.check(m2.getColorSpace().isCS_sRGB());

    IndexColorModel m3 = new IndexColorModel(2, 4, CMAP, 0, false);
    harness.check(m3.getColorSpace().isCS_sRGB());

    IndexColorModel m4 = new IndexColorModel(2, 4, CMAP_WITH_ALPHA, 0, true);
    harness.check(m4.getColorSpace().isCS_sRGB());
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)
  {
    IndexColorModel m1 = new IndexColorModel(2, 4, R4, G4, B4);
    byte[] r = new byte[4];
    m1.getGreens(r);
    harness.check(r[0], (byte) 5);
    harness.check(r[1], (byte) 6);
    harness.check(r[2], (byte) 7);
    harness.check(r[3], (byte) 8);
    // try null array
    boolean pass = false;
    try
    {
      m1.getGreens(null);
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);
    // try array too small to hold results
    pass = false;
    try
    {
      m1.getGreens(new byte[3]);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

        new Color(4, 8, 12, 16).getRGB()};

  private void testConstructor1(TestHarness harness)
  { 
    harness.checkPoint("IndexColorModel(int, int, byte[], byte[], byte[])");
    IndexColorModel m1 = new IndexColorModel(2, 4, R4, G4, B4);
    harness.check(m1.getTransparency(), Transparency.OPAQUE);
    harness.check(m1.getMapSize(), 4);
    harness.check(m1.getPixelSize(), 2);
    harness.check(m1.getTransparentPixel(), -1);
    harness.check(!m1.hasAlpha());
    harness.check(!m1.isAlphaPremultiplied());
    harness.check(m1.getNumComponents(), 3);
    harness.check(m1.getNumColorComponents(), 3);
   
    // try bits < 1
    boolean pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(0, 4, R4, G4, B4);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try bits > 16
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(17, 4, R4, G4, B4);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try size bigger than arrays
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 99, R4, G4, B4);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true
    }
    harness.check(pass);
   
    // try null red array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, null, G4, B4);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);

    // try null green array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, R4, null, B4);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);

    // try null blue array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, R4, G4, null);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
View Full Code Here

  }

  private void testConstructor2(TestHarness harness)
  { 
    harness.checkPoint("IndexColorModel(int, int, byte[], byte[], byte[], byte[])");
    IndexColorModel m1 = new IndexColorModel(2, 4, R4, G4, B4, A4);
    harness.check(m1.getTransparency(), Transparency.TRANSLUCENT);
    harness.check(m1.getMapSize(), 4);
    harness.check(m1.getPixelSize(), 2);
    harness.check(m1.hasAlpha());
    harness.check(!m1.isAlphaPremultiplied());
   
    // try bits < 1
    boolean pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(0, 4, R4, G4, B4, A4);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try bits > 16
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(17, 4, R4, G4, B4, A4);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try size bigger than arrays
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 99, R4, G4, B4, A4);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true
    }
    harness.check(pass);
   
    // try null red array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, null, G4, B4, A4);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);

    // try null green array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, R4, null, B4, A4);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);

    // try null blue array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, R4, G4, null, A4);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);

    // try null alpha array
    IndexColorModel m = new IndexColorModel(2, 4, R4, G4, B4, null);
    harness.check(m.getTransparency(), Transparency.OPAQUE);
  }
View Full Code Here

  }

  private void testConstructor3(TestHarness harness)
  { 
    harness.checkPoint("IndexColorModel(int, int, byte[], byte[], byte[], int)");
    IndexColorModel m1 = new IndexColorModel(2, 4, R4, G4, B4, 2);
    harness.check(m1.getTransparency(), Transparency.BITMASK);
    harness.check(m1.getMapSize(), 4);
    harness.check(m1.getPixelSize(), 2);
    harness.check(m1.getTransparentPixel(), 2);
    harness.check(m1.hasAlpha());
    harness.check(!m1.isAlphaPremultiplied());
   
    // try bits < 1
    boolean pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(0, 4, R4, G4, B4, 2);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try bits > 16
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(17, 4, R4, G4, B4, 2);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try size bigger than arrays
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 99, R4, G4, B4, 2);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true
    }
    harness.check(pass);
   
    // try null red array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, null, G4, B4, 2);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);

    // try null green array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, R4, null, B4, 2);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);

    // try null blue array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, R4, G4, null, 2);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);

    // try negative trans
    IndexColorModel m = new IndexColorModel(2, 4, R4, G4, B4, -1);
    harness.check(m.getTransparentPixel(), -1);
    harness.check(m.getTransparency(), Transparency.OPAQUE);
   
    m = new IndexColorModel(2, 4, R4, G4, B4, -99);
    harness.check(m.getTransparentPixel(), -1);
    harness.check(m.getTransparency(), Transparency.OPAQUE);
   
    // try trans too large
    m = new IndexColorModel(2, 4, R4, G4, B4, 4);
    harness.check(m.getTransparentPixel(), -1);
  }
View Full Code Here

  }

  private void testConstructor4(TestHarness harness)
  { 
    harness.checkPoint("IndexColorModel(int, int, byte[], int, boolean)");
    IndexColorModel m1 = new IndexColorModel(2, 4, CMAP, 0, false);
    harness.check(!m1.isAlphaPremultiplied());

    harness.check(m1.getRed(0), 1);
    harness.check(m1.getRed(1), 2);
    harness.check(m1.getRed(2), 3);
    harness.check(m1.getRed(3), 4);
    harness.check(m1.getGreen(0), 5);
    harness.check(m1.getGreen(1), 6);
    harness.check(m1.getGreen(2), 7);
    harness.check(m1.getGreen(3), 8);
    harness.check(m1.getBlue(0), 9);
    harness.check(m1.getBlue(1), 10);
    harness.check(m1.getBlue(2), 11);
    harness.check(m1.getBlue(3), 12);
    harness.check(m1.getAlpha(0), 255);
    harness.check(m1.getAlpha(1), 255);
    harness.check(m1.getAlpha(2), 255);
    harness.check(m1.getAlpha(3), 255);
    harness.check(!m1.hasAlpha());
   
    IndexColorModel m2 = new IndexColorModel(2, 4, CMAP_WITH_ALPHA, 0, true);
    harness.check(m2.getRed(0), 1);
    harness.check(m2.getRed(1), 2);
    harness.check(m2.getRed(2), 3);
    harness.check(m2.getRed(3), 4);
    harness.check(m2.getGreen(0), 5);
    harness.check(m2.getGreen(1), 6);
    harness.check(m2.getGreen(2), 7);
    harness.check(m2.getGreen(3), 8);
    harness.check(m2.getBlue(0), 9);
    harness.check(m2.getBlue(1), 10);
    harness.check(m2.getBlue(2), 11);
    harness.check(m2.getBlue(3), 12);
    harness.check(m2.getAlpha(0), 13);
    harness.check(m2.getAlpha(1), 14);
    harness.check(m2.getAlpha(2), 15);
    harness.check(m2.getAlpha(3), 16);
    harness.check(m2.hasAlpha());
   
    // try bits < 1
    boolean pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(0, 4, CMAP, 0, false);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try bits > 16
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(17, 4, CMAP, 0, false);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try size bigger than arrays
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 99, CMAP, 0, false);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true
    }
    harness.check(pass);
   
    // try null cmap array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, null, 0, false);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)
  {
    IndexColorModel m1 = new IndexColorModel(2, 4, R4, G4, B4, A4);
    harness.check(m1.getAlpha(0), 13);
    harness.check(m1.getAlpha(1), 14);
    harness.check(m1.getAlpha(2), 15);
    harness.check(m1.getAlpha(3), 16);
    IndexColorModel m2 = new IndexColorModel(2, 4, CMAP, 0, false, 1);
    harness.check(m2.getAlpha(0), 255);
    harness.check(m2.getAlpha(1), 0);
    harness.check(m2.getAlpha(2), 255);
    harness.check(m2.getAlpha(3), 255);
   
    // try negative pixel
    boolean pass = false;
    try
    {
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)
  {
    IndexColorModel m1 = new IndexColorModel(2, 4, R4, G4, B4);
    byte[] b = new byte[4];
    m1.getBlues(b);
    harness.check(b[0], (byte) 9);
    harness.check(b[1], (byte) 10);
    harness.check(b[2], (byte) 11);
    harness.check(b[3], (byte) 12);
    // try null array
    boolean pass = false;
    try
    {
      m1.getBlues(null);
    }
    catch (NullPointerException e
    {
      pass = true;  
    }
    harness.check(pass);
    // try array too small to hold results
    pass = false;
    try
    {
      m1.getBlues(new byte[3]);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

  }
 
  public void test1(TestHarness harness)
  {
    harness.checkPoint("isValid()");
    IndexColorModel m1 = new IndexColorModel(2, 4, R4, G4, B4);
    harness.check(m1.isValid());

    IndexColorModel m2 = new IndexColorModel(2, 4, CMAP_INT, 0,
            DataBuffer.TYPE_BYTE, new BigInteger("11"));
    harness.check(!m2.isValid());
 
View Full Code Here

TOP

Related Classes of java.awt.image.IndexColorModel

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.