Package java.awt.image

Examples of java.awt.image.DataBufferInt


  }

  private void testConstructor5(TestHarness harness)
  {
    harness.checkPoint("DataBufferInt(int[], int, int)");
    DataBufferInt b = new DataBufferInt(new int[] {1, 2}, 2, 0);
    harness.check(b.getSize() == 2);
    harness.check(b.getNumBanks() == 1);
    harness.check(b.getOffset() == 0);
   
    boolean pass = false;
    try
    {
      // this constructor doesn't throw an exception until you
      // try to access the (null) data bank
      DataBufferInt b1 = new DataBufferInt((int[]) null, 1, 0);
      int ignore = b1.getElem(0);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    // does negative size fail? no
    pass = true;
    try
    {
      DataBufferInt b2 = new DataBufferInt(new int[] {1, 2}, -1, 0);
    }
    catch (NegativeArraySizeException e)
    {
      pass = false;
    }
View Full Code Here


  }

  private void testConstructor6(TestHarness harness)
  {
    harness.checkPoint("DataBufferInt(int, int)");
    DataBufferInt b = new DataBufferInt(2, 3);
    harness.check(b.getNumBanks() == 3);
    harness.check(b.getSize() == 2);
    harness.check(b.getOffset() == 0);
   
    // does negative size fail? yes
    boolean pass = false;
    try
    {
      DataBufferInt b1 = new DataBufferInt(-1, 1);
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;
    }
    harness.check(pass);

    // does negative banks fail? yes
    pass = false;
    try
    {
      DataBufferInt b1 = new DataBufferInt(1, -1);
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;
    }
View Full Code Here

  public void test(TestHarness h)
  {
    DataBuffer buf;
    int[] data = new int[] { -11, -22, -33, -44 };
   
    buf = new DataBufferInt(new int[][] { data, data }, 2,
                            new int[] { 2, 0 });

    h.check(buf.getElem(0), -33);    // Check #1.
    h.check(buf.getElem(1), -44);    // Check #2.
    h.check(buf.getElem(0, 0), -33); // Check #3.
View Full Code Here

  {
    harness.checkPoint("getElem(int)")
     
    // test where supplied array is bigger than 'size'
    int[] source = new int[] {1, 2, 3};
    DataBufferInt b = new DataBufferInt(source, 2);
    harness.check(b.getElem(0) == 1);
    harness.check(b.getElem(1) == 2);
    harness.check(b.getElem(2) == 3);
   
    boolean pass = false;
    try
    {
      b.getElem(-1);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    pass = false;
    try
    {
      b.getElem(3);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // test where offsets are specified
    source = new int[] {1, 2, 3, 4};
    b = new DataBufferInt(source, 2, 1);
    harness.check(b.getElem(-1) == 1);
    harness.check(b.getElem(0) == 2);
    harness.check(b.getElem(1) == 3);
    harness.check(b.getElem(2) == 4);

    pass = false;
    try
    {
      b.getElem(3);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);

    pass = false;
    try
    {
      b.getElem(-2);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

  private void testGetElem2(TestHarness harness) {
    harness.checkPoint("getElem(int, int)")
   
    int[][] source = new int[][] {{1, 2}, {3, 4}};
    DataBufferInt b = new DataBufferInt(source, 2);
    harness.check(b.getElem(1, 0) == 3);
    harness.check(b.getElem(1, 1) == 4);
   
    // test where supplied array is bigger than 'size'
    source = new int[][] {{1, 2, 3}, {4, 5, 6}};
    b = new DataBufferInt(source, 2);
    harness.check(b.getElem(1, 2) == 6);
     
    // test where offsets are specified
    source = new int[][] {{1, 2, 3, 4}, {5, 6, 7, 8}};
    b = new DataBufferInt(source, 2, new int[] {1, 2});
    harness.check(b.getElem(1, -2) == 5);
    harness.check(b.getElem(1, -1) == 6);
    harness.check(b.getElem(1, 0) == 7);
    harness.check(b.getElem(1, 1) == 8);
      
    // does a change to the source affect the DataBuffer? Yes
    source[1][2] = 99;
    harness.check(source[1][2] == 99);
    harness.check(b.getElem(1, 0) == 99);
       
    // test when the bank index is out of bounds
    boolean pass = true;
    try
    {
      b.getElem(-1, 0);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
       
    pass = false;
    try
    {
      b.getElem(2, 0);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // test when the item index is out of bounds
    pass = true;
    try
    {
      b.getElem(0, -2);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
       
    pass = false;
    try
    {
      b.getElem(1, 5);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // the array of arrays should reflect the single dimension array
    DataBufferInt b2 = new DataBufferInt(new int[] {1, 2, 3}, 3);
    harness.check(b2.getElem(0, 1) == 2);
  }
View Full Code Here

   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    BandedSampleModel m = new BandedSampleModel(DataBuffer.TYPE_INT, 2, 3, 2);
    DataBufferInt b = new DataBufferInt(6, 2);
    b.setElem(0, 0, 0xA0);
    b.setElem(0, 1, 0xA1);
    b.setElem(0, 2, 0xA2);
    b.setElem(0, 3, 0xA3);
    b.setElem(0, 4, 0xA4);
    b.setElem(0, 5, 0xA5);
    b.setElem(1, 0, 0xB0);
    b.setElem(1, 1, 0xB1);
    b.setElem(1, 2, 0xB2);
    b.setElem(1, 3, 0xB3);
    b.setElem(1, 4, 0xB4);
    b.setElem(1, 5, 0xB5);
    harness.check(m.getSampleFloat(0, 0, 0, b), 0xA0);
    harness.check(m.getSampleFloat(1, 0, 0, b), 0xA1);
    harness.check(m.getSampleFloat(0, 1, 0, b), 0xA2);
    harness.check(m.getSampleFloat(1, 1, 0, b), 0xA3);
    harness.check(m.getSampleFloat(0, 2, 0, b), 0xA4);
View Full Code Here

   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    BandedSampleModel m = new BandedSampleModel(DataBuffer.TYPE_INT, 2, 3, 2);
    DataBufferInt b = new DataBufferInt(6, 2);
    b.setElem(0, 0, 0xFFA0);
    b.setElem(0, 1, 0xFFA1);
    b.setElem(0, 2, 0xFFA2);
    b.setElem(0, 3, 0xFFA3);
    b.setElem(0, 4, 0xFFA4);
    b.setElem(0, 5, 0xFFA5);
    b.setElem(1, 0, 0xFFB0);
    b.setElem(1, 1, 0xFFB1);
    b.setElem(1, 2, 0xFFB2);
    b.setElem(1, 3, 0xFFB3);
    b.setElem(1, 4, 0xFFB4);
    b.setElem(1, 5, 0xFFB5);
    harness.check(m.getSampleDouble(0, 0, 0, b), 0xFFA0);
    harness.check(m.getSampleDouble(1, 0, 0, b), 0xFFA1);
    harness.check(m.getSampleDouble(0, 1, 0, b), 0xFFA2);
    harness.check(m.getSampleDouble(1, 1, 0, b), 0xFFA3);
    harness.check(m.getSampleDouble(0, 2, 0, b), 0xFFA4);
View Full Code Here

public class setDataElements implements Testlet
{
  public void test(TestHarness harness)
  {
    DataBuffer db = new DataBufferInt(12);
    int[] pixel = new int[] {11, 22};
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
            3, 2, 2, 6, new int[] {0, 1});
    m.setDataElements(1, 1, pixel, db);
    harness.check(db.getElem(0, 8), 11);
    harness.check(db.getElem(0, 9), 22);
       
    // check bad type for data element array
    boolean pass = false;
    try
      {
View Full Code Here

public class setPixels implements Testlet
{
  public void test(TestHarness harness)
  {
    DataBuffer db = new DataBufferInt(12);
    int[] pixels = new int[] {11, 22, 33, 44};
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
            3, 2, 2, 6, new int[] {0, 1});
    m.setPixels(0, 0, 2, 1, pixels, db);
    harness.check(db.getElem(0, 0), 11);
    harness.check(db.getElem(0, 1), 22);
    harness.check(db.getElem(0, 2), 33);
    harness.check(db.getElem(0, 3), 44);
       
    // check that a null pixel array generates a NullPointerException
    boolean pass = false;
    try
      {
View Full Code Here

   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    BandedSampleModel m = new BandedSampleModel(DataBuffer.TYPE_INT, 2, 3, 2);
    DataBufferInt b = new DataBufferInt(6, 2);
    b.setElem(0, 0, 0xA0);
    b.setElem(0, 1, 0xA1);
    b.setElem(0, 2, 0xA2);
    b.setElem(0, 3, 0xA3);
    b.setElem(0, 4, 0xA4);
    b.setElem(0, 5, 0xA5);
    b.setElem(1, 0, 0xB0);
    b.setElem(1, 1, 0xB1);
    b.setElem(1, 2, 0xB2);
    b.setElem(1, 3, 0xB3);
    b.setElem(1, 4, 0xB4);
    b.setElem(1, 5, 0xB5);
    int[] pixels = m.getPixels(1, 1, 1, 2, (int[]) null, b);
    harness.check(pixels[0], 0xA3);
    harness.check(pixels[1], 0xB3);
    harness.check(pixels[2], 0xA5);
View Full Code Here

TOP

Related Classes of java.awt.image.DataBufferInt

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.