Package java.awt.image

Examples of java.awt.image.IndexColorModel


        final byte[] b = new byte[size];
        for (int i = size - 1; i >= 0; i--) {
            getPaletteEntry(io, i, r, g, b);
        }
        // log.debug("Save-Size:" + size + ", R=" + NumberUtils.hex(r));
        palette = new IndexColorModel(8/* 32 *//* 6 */, size, r, g, b);
    }
View Full Code Here


  }

  private void testConstructor5(TestHarness harness)
  { 
    harness.checkPoint("IndexColorModel(int, int, byte[], int, boolean, int)");
    IndexColorModel m1 = new IndexColorModel(2, 4, CMAP, 0, false, 1);
    harness.check(m1.getTransparentPixel(), 1);
    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), 0);
    harness.check(m1.getAlpha(2), 255);
    harness.check(m1.getAlpha(3), 255);
   
    IndexColorModel m2 = new IndexColorModel(2, 4, CMAP_WITH_ALPHA, 0, true, 2);
    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), 0);
    harness.check(m2.getAlpha(3), 16);
   
    // try bits < 1
    boolean pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(0, 4, CMAP, 0, false, 3);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try bits > 16
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(17, 4, CMAP, 0, false, 3);
    }
    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, 3);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true
    }
    harness.check(pass);
   
    // try null cmap array
    pass = false;
    try
    {
      /* IndexColorModel m = */ new IndexColorModel(2, 4, null, 0, false, 3);     
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
View Full Code Here

  }

  private void testConstructor6(TestHarness harness)
  { 
    harness.checkPoint("IndexColorModel(int, int, int[], int, boolean, int, int)");
    IndexColorModel m1 = new IndexColorModel(2, 4, CMAP_INT, 0, false, 1, DataBuffer.TYPE_BYTE);
    harness.check(m1.getTransferType(), DataBuffer.TYPE_BYTE);
    harness.check(m1.getTransparentPixel(), 1);
    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), 0);
    harness.check(m1.getAlpha(2), 255);
    harness.check(m1.getAlpha(3), 255);

    IndexColorModel m2 = new IndexColorModel(2, 4, CMAP_INT_WITH_ALPHA, 0, true, 1, DataBuffer.TYPE_BYTE);
    harness.check(m2.getTransferType(), DataBuffer.TYPE_BYTE);
    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), 0);
    harness.check(m2.getAlpha(2), 15);
    harness.check(m2.getAlpha(3), 16);
  }
View Full Code Here

  }

  private void testConstructor7(TestHarness harness)
  { 
    harness.checkPoint("IndexColorModel(int, int, int[], int, int, BigInteger)");
    IndexColorModel m1 = new IndexColorModel(2, 4, CMAP_INT, 0, DataBuffer.TYPE_BYTE, new BigInteger("11"));
    harness.check(!m1.isAlphaPremultiplied());

    harness.check(m1.isValid(0));
    harness.check(m1.isValid(1));
    harness.check(!m1.isValid(2));
    harness.check(m1.isValid(3));
  }
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.getGreen(0), 5);
    harness.check(m1.getGreen(1), 6);
    harness.check(m1.getGreen(2), 7);
    harness.check(m1.getGreen(3), 8);

    // try negative pixel
    boolean pass = false;
    try
    {
      m1.getGreen(-1);  
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);

    // try pixel too large
    harness.check(m1.getGreen(4), 0);
 
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.getRed(0), 1);
    harness.check(m1.getRed(1), 2);
    harness.check(m1.getRed(2), 3);
    harness.check(m1.getRed(3), 4);
    // try negative pixel
    boolean pass = false;
    try
    {
      m1.getRed(-1);  
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
    // try pixel too large
    harness.check(m1.getRed(4), 0);
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.getBlue(0), 9);
    harness.check(m1.getBlue(1), 10);
    harness.check(m1.getBlue(2), 11);
    harness.check(m1.getBlue(3), 12);

    // try negative pixel
    boolean pass = false;
    try
    {
      m1.getGreen(-1);  
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);

    // try pixel too large
    harness.check(m1.getBlue(4), 0);
 
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.getReds(r);
    harness.check(r[0], (byte) 1);
    harness.check(r[1], (byte) 2);
    harness.check(r[2], (byte) 3);
    harness.check(r[3], (byte) 4);
   
    // try null array
    boolean pass = false;
    try
    {
      m1.getReds(null);
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try array too small to hold results
    pass = false;
    try
    {
      m1.getReds(new byte[3]);
    }
    catch (ArrayIndexOutOfBoundsException 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);
    harness.check(m1.getTransparency(), Transparency.OPAQUE);
 
    IndexColorModel m2a = new IndexColorModel(2, 4, R4, G4, B4, 2);
    harness.check(m2a.getTransparency(), Transparency.BITMASK);
    IndexColorModel m2b = new IndexColorModel(2, 4, R4, G4, B4, -1);
    harness.check(m2b.getTransparency(), Transparency.OPAQUE);
    IndexColorModel m2c = new IndexColorModel(2, 4, R4, G4, B4, 99);
    harness.check(m2c.getTransparency(), Transparency.OPAQUE);
   
    IndexColorModel m3a = new IndexColorModel(2, 4, CMAP, 0, false);
    harness.check(m3a.getTransparency(), Transparency.OPAQUE);
    IndexColorModel m3b = new IndexColorModel(2, 4, CMAP, 0, false, 2);
    harness.check(m3b.getTransparency(), Transparency.BITMASK);

    IndexColorModel m4a = new IndexColorModel(2, 4, CMAP_WITH_ALPHA, 0, true);
    harness.check(m4a.getTransparency(), Transparency.TRANSLUCENT);
    IndexColorModel m4b = new IndexColorModel(2, 4, CMAP_WITH_ALPHA, 0, true, 2);
    harness.check(m4b.getTransparency(), Transparency.TRANSLUCENT);

    IndexColorModel m5a = new IndexColorModel(2, 4, CMAP_WITH_ALPHA0, 0, true);
    harness.check(m5a.getTransparency(), Transparency.BITMASK);
    IndexColorModel m5b = new IndexColorModel(2, 4, CMAP_WITH_ALPHA0, 0, true, 2);
    harness.check(m5b.getTransparency(), Transparency.BITMASK);

    IndexColorModel m6a = new IndexColorModel(2, 4, CMAP_WITH_ALPHA1, 0, true);
    harness.check(m6a.getTransparency(), Transparency.OPAQUE);
    IndexColorModel m6b = new IndexColorModel(2, 4, CMAP_WITH_ALPHA1, 0, true, 2);
    harness.check(m6b.getTransparency(), Transparency.BITMASK);
 
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);
    byte[] a = new byte[4];
    m1.getAlphas(a);
    harness.check(a[0], (byte) 13);
    harness.check(a[1], (byte) 14);
    harness.check(a[2], (byte) 15);
    harness.check(a[3], (byte) 16);
    // try null array
    boolean pass = false;
    try
    {
      m1.getAlphas(null);
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
    harness.check(pass);
    // try array too small to hold results
    pass = false;
    try
    {
      m1.getAlphas(new byte[3]);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
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.