Package java.awt.image

Examples of java.awt.image.DataBufferInt


   * @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);
    m.setPixels(0, 0, 1, 3, new int[] {0xA0, 0xB0, 0xA2, 0xB2, 0xA4, 0xB4}, b);
    m.setPixels(1, 0, 1, 3, new int[] {0xA1, 0xB1, 0xA3, 0xB3, 0xA5, 0xB5}, b);
    harness.check(b.getElem(0, 0), 0xA0);
    harness.check(b.getElem(0, 1), 0xA1);
    harness.check(b.getElem(0, 2), 0xA2);
    harness.check(b.getElem(0, 3), 0xA3);
    harness.check(b.getElem(0, 4), 0xA4);
    harness.check(b.getElem(0, 5), 0xA5);
    harness.check(b.getElem(1, 0), 0xB0);
    harness.check(b.getElem(1, 1), 0xB1);
    harness.check(b.getElem(1, 2), 0xB2);
    harness.check(b.getElem(1, 3), 0xB3);
    harness.check(b.getElem(1, 4), 0xB4);
    harness.check(b.getElem(1, 5), 0xB5);

    // check negative x
    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);
    m.setSamples(0, 0, 1, 3, 0, new int[] {0xA0, 0xA2, 0xA4}, b);
    m.setSamples(1, 0, 1, 1, 0, new int[] {0xA1}, b);
    m.setSamples(1, 1, 1, 2, 0, new int[] {0xA3, 0xA5}, b);
    m.setSamples(0, 0, 1, 3, 1, new int[] {0xB0, 0xB2, 0xB4}, b);
    m.setSamples(1, 0, 1, 3, 1, new int[] {0xB1, 0xB3, 0xB5}, b);
    harness.check(b.getElem(0, 0), 0xA0)// check 1
    harness.check(b.getElem(0, 1), 0xA1)// check 2
    harness.check(b.getElem(0, 2), 0xA2)// check 3
    harness.check(b.getElem(0, 3), 0xA3)// check 4
    harness.check(b.getElem(0, 4), 0xA4)// check 5
    harness.check(b.getElem(0, 5), 0xA5)// check 6
    harness.check(b.getElem(1, 0), 0xB0)// check 7
    harness.check(b.getElem(1, 1), 0xB1)// check 8
    harness.check(b.getElem(1, 2), 0xB2)// check 9
    harness.check(b.getElem(1, 3), 0xB3)// check 10
    harness.check(b.getElem(1, 4), 0xB4)// check 11
    harness.check(b.getElem(1, 5), 0xB5)// check 12

    // check negative x
    boolean pass = false;
    try
    {
View Full Code Here

  private void testGetData1(TestHarness harness) {
    harness.checkPoint("getData()")
   
    // check simple case
    int[] source = new int[] {1, 2};
    DataBufferInt b = new DataBufferInt(source, 2);
    int[] data = b.getData();
    harness.check(data.length == 2);
    harness.check(data[0] == 1);
    harness.check(data[1] == 2);
 
    // test where supplied array is bigger than 'size'
    source = new int[] {1, 2, 3};
    b = new DataBufferInt(source, 2);
    data = b.getData();
    harness.check(data.length == 3);
    harness.check(data[0] == 1);
    harness.check(data[1] == 2);
    harness.check(data[2] == 3);
 
    // test where offsets are specified
    source = new int[] {1, 2, 3, 4};
    b = new DataBufferInt(source, 2, 1);
    data = b.getData();
    harness.check(data.length == 4);
    harness.check(data[0] == 1);
    harness.check(data[1] == 2);
    harness.check(data[2] == 3);
    harness.check(data[3] == 4);
View Full Code Here

  private void testGetData2(TestHarness harness) {
    harness.checkPoint("getData(int)")
     
    int[][] source = new int[][] {{1, 2}, {3, 4}};
    DataBufferInt b = new DataBufferInt(source, 2);
    int[] data = b.getData(1);
    harness.check(data.length == 2);
    harness.check(data[0] == 3);
    harness.check(data[1] == 4);
   
    // test where supplied array is bigger than 'size'
    source = new int[][] {{1, 2, 3}, {4, 5, 6}};
    b = new DataBufferInt(source, 2);
    data = b.getData(1);
    harness.check(data.length == 3);
    harness.check(data[0] == 4);
    harness.check(data[1] == 5);
    harness.check(data[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});
    data = b.getData(1);
    harness.check(data.length == 4);
    harness.check(data[0] == 5);
    harness.check(data[1] == 6);
    harness.check(data[2] == 7);
    harness.check(data[3] == 8);
     
    // does a change to the source affect the DataBuffer? Yes
    source[1][2] = 99;
    harness.check(data[2] == 99);
     
    // check bounds exceptions
    boolean pass = true;
    try
    {
      b.getData(-1);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
    
    pass = false;
    try
    {
      b.getData(2);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

    harness.checkPoint("(int, int, int, int, DataBuffer(Int))");
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_INT, 2, 3, new int[] { 0xFFFF0000, 0x0000FFFF }
    );
    int[] i = new int[] { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666 };
    DataBuffer db = new DataBufferInt(i, 6)

    // set a value
    m1.setSample(0, 0, 0, 0x00CC, db);
    m1.setSample(1, 0, 0, 0x00BB, db);
    m1.setSample(0, 1, 0, 0x00AA, db);
    m1.setSample(1, 1, 0, 0x0099, db);
    m1.setSample(0, 2, 0, 0x0088, db);
    m1.setSample(1, 2, 0, 0x0077, db);
    m1.setSample(0, 0, 1, 0x0077, db);
    m1.setSample(1, 0, 1, 0x0088, db);
    m1.setSample(0, 1, 1, 0x0099, db);
    m1.setSample(1, 1, 1, 0x00AA, db);
    m1.setSample(0, 2, 1, 0x00BB, db);
    m1.setSample(1, 2, 1, 0x00CC, db);
    harness.check(db.getElem(0), 0x00CC0077);
    harness.check(db.getElem(1), 0x00BB0088);
    harness.check(db.getElem(2), 0x00AA0099);
    harness.check(db.getElem(3), 0x009900AA);
    harness.check(db.getElem(4), 0x008800BB);
    harness.check(db.getElem(5), 0x007700CC);
 
    // set a value with non-standard scanline stride
    SinglePixelPackedSampleModel m2 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_INT, 2, 2, 3, new int[] { 0xFFFF0000, 0x0000FFFF }
    );
    m2.setSample(0, 0, 0, 0x0044, db);
    m2.setSample(1, 0, 0, 0x0033, db);
    m2.setSample(0, 1, 0, 0x0022, db);
    m2.setSample(1, 1, 0, 0x0011, db);
    m2.setSample(0, 0, 1, 0x0011, db);
    m2.setSample(1, 0, 1, 0x0022, db);
    m2.setSample(0, 1, 1, 0x0033, db);
    m2.setSample(1, 1, 1, 0x0044, db);
    harness.check(db.getElem(0), 0x00440011);
    harness.check(db.getElem(1), 0x00330022);
    harness.check(db.getElem(3), 0x00220033);
    harness.check(db.getElem(4), 0x00110044);
   
    // set a value with x < 0
    try
    {
      m1.setSample(-1, 0, 0, 0x10, db);
View Full Code Here

  implements Testlet
{
  public void test(TestHarness h)
  {
    // Check #1.
    h.check(new DataBufferInt(5).getDataType(), DataBuffer.TYPE_INT);
  }
View Full Code Here

  private void testSetElem1(TestHarness harness) {
    harness.checkPoint("setElem(int, int)")
 
    int[] source = new int[] {1, 2};
    DataBufferInt b = new DataBufferInt(source, 2);
    b.setElem(1, 99);
    harness.check(b.getElem(1) == 99);
   
    // does the source array get updated? Yes
    harness.check(source[1] == 99);

    // test with offsets
    source = new int[] {1, 2, 3, 4, 5};
    b = new DataBufferInt(source, 4, 1);
    harness.check(b.getElem(1) == 3);
    b.setElem(1, 99);
    harness.check(b.getElem(1) == 99);
    harness.check(source[2] == 99);
   
    boolean pass = false;
    try
    {
      b.setElem(-2, 99);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    pass = false;
    try
    {
      b.setElem(4, 99);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

  private void testSetElem2(TestHarness harness) {
      harness.checkPoint("setElem(int, int, int)")
   
      int[][] source = new int[][] {{1, 2}, {3, 4}};
      DataBufferInt b = new DataBufferInt(source, 2);
      b.setElem(1, 1, 99);
      harness.check(b.getElem(1, 1) == 99);
      // does the source array get updated?
      harness.check(source[1][1] == 99);

      boolean pass = false;
      try
      {
        b.setElem(-1, 1, 99);
      }
      catch (ArrayIndexOutOfBoundsException e)
      {
        pass = true;
      }
      harness.check(pass);
     
      pass = false;
      try
      {
        b.setElem(2, 1, 99);
      }
      catch (ArrayIndexOutOfBoundsException e)
      {
        pass = true;
      }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    // check that array updates pass through
    int[][] data = new int[][] {{1, 2}};
    DataBufferInt b = new DataBufferInt(data, 2);
    int[][] banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));
    data[0][0] = 3;
    harness.check(banks[0][0] == 3);
   
    // test where supplied array is bigger than 'size'
    data = new int[][] {{1, 2, 3}};
    b = new DataBufferInt(data, 2);
    banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));
   
    // test where offsets are specified
    data = new int[][] {{1, 2, 3}, {4, 5, 6, 7}};
    b = new DataBufferInt(data, 2, new int[] {0, 1});
    banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));
   
    // check that a single bank buffer returns a valid array
    DataBufferInt b2 = new DataBufferInt(new int[] {1, 2}, 2);
    banks = b2.getBankData();
    harness.check(banks.length == 1);
    harness.check(banks[0][0] == 1);
    harness.check(banks[0][1] == 2);
   
    // check that a multi bank buffer returns a valid array
    DataBufferInt b3 = new DataBufferInt(new int[][] {{1}, {2}}, 1);
    banks = b3.getBankData();
    harness.check(banks.length == 2);
    harness.check(banks[0][0] == 1);
    harness.check(banks[1][0] == 2);
  }
View Full Code Here

    harness.checkPoint("(int, int, Object, DataBuffer(Int))");
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_INT, 2, 2, new int[] { 224, 28, 3 }
    );
    int[] i = new int[] { 11, 22, 33, 44 };
    DataBuffer db = new DataBufferInt(i, 4)
     
    int[] de = (int[]) m1.getDataElements(1, 1, null, db);
    harness.check(de.length, 1);
    harness.check(de[0], 44);
     
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.