Examples of DataBufferUShort


Examples of java.awt.image.DataBufferUShort

  private void testSetElem2(TestHarness harness) {
    harness.checkPoint("setElem(int, int, int)")

    short[][] source = new short[][] {{1, 2}, {3, 4}};
    DataBufferUShort b = new DataBufferUShort(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

Examples of java.awt.image.DataBufferUShort

   */
  public void test(TestHarness harness)      
  {
    // check that array updates pass through
    short[][] data = new short[][] {{1, 2}};
    DataBufferUShort b = new DataBufferUShort(data, 2);
    short[][] 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 short[][] {{1, 2, 3}};
    b = new DataBufferUShort(data, 2);
    banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));

    // test where offsets are specified
    data = new short[][] {{1, 2, 3}, {4, 5, 6, 7}};
    b = new DataBufferUShort(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
    DataBufferUShort b2 = new DataBufferUShort(new short[] {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
    DataBufferUShort b3 = new DataBufferUShort(new short[][] {{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

Examples of java.awt.image.DataBufferUShort

    harness.checkPoint("(int, int, Object, DataBuffer(UShort))");
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_USHORT, 2, 3, new int[] { 0xFF00, 0x00FF }
    );
    short[] s = new short[] { (short) 0x1111, (short) 0x2222, (short) 0x3333, (short) 0x4444, (short) 0x5555, (short) 0x6666 };
    DataBuffer db = new DataBufferUShort(s, 6)

    // set a value
    m1.setPixel(0, 0, new int[] { 0x00CC, 0x0077 }, db);
    m1.setPixel(1, 0, new int[] { 0x00BB, 0x0088 }, db);
    m1.setPixel(0, 1, new int[] { 0x00AA, 0x0099 }, db);
    m1.setPixel(1, 1, new int[] { 0x0099, 0x00AA }, db);
    m1.setPixel(0, 2, new int[] { 0x0088, 0x00BB }, db);
    m1.setPixel(1, 2, new int[] { 0x0077, 0x00CC }, db);
    harness.check(db.getElem(0), 0xCC77);
    harness.check(db.getElem(1), 0xBB88);
    harness.check(db.getElem(2), 0xAA99);
    harness.check(db.getElem(3), 0x99AA);
    harness.check(db.getElem(4), 0x88BB);
    harness.check(db.getElem(5), 0x77CC);
  
    // set a value with non-standard scanline stride
    SinglePixelPackedSampleModel m2 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_USHORT, 2, 2, 3, new int[] { 0xFF00, 0x00FF }
    );
    m2.setPixel(0, 0, new int[] { 0x0044, 0x0011 }, db);
    m2.setPixel(1, 0, new int[] { 0x0033, 0x0022 }, db);
    m2.setPixel(0, 1, new int[] { 0x0022, 0x0033 }, db);
    m2.setPixel(1, 1, new int[] { 0x0011, 0x0044 }, db);
    harness.check(db.getElem(0), 0x4411);
    harness.check(db.getElem(1), 0x3322);
    harness.check(db.getElem(3), 0x2233);
    harness.check(db.getElem(4), 0x1144);
    
    // set a value with x < 0
    try
    {
      m1.setPixel(-1, 0, new int[] { 0x10, 0x01 }, db);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.