Package java.awt.image

Examples of java.awt.image.DataBufferInt


  public void testInt(TestHarness harness)       
  {
    harness.checkPoint("(int, int, int, int, DataBuffer)");
    BandedSampleModel m = new BandedSampleModel(DataBuffer.TYPE_INT, 2, 3, 2);
    DataBufferInt b = new DataBufferInt(6, 2);
    m.setSample(0, 0, 0, 0xA0, b);
    m.setSample(1, 0, 0, 0xA1, b);
    m.setSample(0, 1, 0, 0xA2, b);
    m.setSample(1, 1, 0, 0xA3, b);
    m.setSample(0, 2, 0, 0xA4, b);
    m.setSample(1, 2, 0, 0xA5, b);
    m.setSample(0, 0, 1, 0xB0, b);
    m.setSample(1, 0, 1, 0xB1, b);
    m.setSample(0, 1, 1, 0xB2, b);
    m.setSample(1, 1, 1, 0xB3, b);
    m.setSample(0, 2, 1, 0xB4, b);
    m.setSample(1, 2, 1, 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


  public void testFloat(TestHarness harness)       
  {
    harness.checkPoint("(int, int, int, float, DataBuffer)");
    BandedSampleModel m = new BandedSampleModel(DataBuffer.TYPE_INT, 2, 3, 2);
    DataBufferInt b = new DataBufferInt(6, 2);
    m.setSample(0, 0, 0, (float) 0xA0, b);
    m.setSample(1, 0, 0, (float) 0xA1, b);
    m.setSample(0, 1, 0, (float) 0xA2, b);
    m.setSample(1, 1, 0, (float) 0xA3, b);
    m.setSample(0, 2, 0, (float) 0xA4, b);
    m.setSample(1, 2, 0, (float) 0xA5, b);
    m.setSample(0, 0, 1, (float) 0xB0, b);
    m.setSample(1, 0, 1, (float) 0xB1, b);
    m.setSample(0, 1, 1, (float) 0xB2, b);
    m.setSample(1, 1, 1, (float) 0xB3, b);
    m.setSample(0, 2, 1, (float) 0xB4, b);
    m.setSample(1, 2, 1, (float) 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

   */
  public void testDouble(TestHarness harness)       
  {
    harness.checkPoint("(int, int, int, double, DataBuffer)");
    BandedSampleModel m = new BandedSampleModel(DataBuffer.TYPE_INT, 2, 3, 2);
    DataBufferInt b = new DataBufferInt(6, 2);
    m.setSample(0, 0, 0, (double) 0xA0, b);
    m.setSample(1, 0, 0, (double) 0xA1, b);
    m.setSample(0, 1, 0, (double) 0xA2, b);
    m.setSample(1, 1, 0, (double) 0xA3, b);
    m.setSample(0, 2, 0, (double) 0xA4, b);
    m.setSample(1, 2, 0, (double) 0xA5, b);
    m.setSample(0, 0, 1, (double) 0xB0, b);
    m.setSample(1, 0, 1, (double) 0xB1, b);
    m.setSample(0, 1, 1, (double) 0xB2, b);
    m.setSample(1, 1, 1, (double) 0xB3, b);
    m.setSample(0, 2, 1, (double) 0xB4, b);
    m.setSample(1, 2, 1, (double) 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);
    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[] elements = (int[]) m.getDataElements(1, 1, null, b);
    harness.check(elements[0], 0xA3);
    harness.check(elements[1], 0xB3);
 
View Full Code Here

    harness.checkPoint("(int, int, Object, 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.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), 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.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), 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.setPixel(-1, 0, new int[] { 0x10, 0x01 }, db);
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.setPixel(0, 0, new int[] {0xA0, 0xB0}, b);
    m.setPixel(1, 0, new int[] {0xA1, 0xB1}, b);
    m.setPixel(0, 1, new int[] {0xA2, 0xB2}, b);
    m.setPixel(1, 1, new int[] {0xA3, 0xB3}, b);
    m.setPixel(0, 2, new int[] {0xA4, 0xB4}, b);
    m.setPixel(1, 2, new int[] {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

  }
 
  private void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("DataBufferInt(int)");
    DataBufferInt b1 = new DataBufferInt(1);
    harness.check(b1.getDataType() == DataBuffer.TYPE_INT);
    harness.check(b1.getSize() == 1);
    harness.check(b1.getNumBanks() == 1);
    harness.check(b1.getOffset() == 0);
   
    DataBufferInt b2 = new DataBufferInt(0);
    harness.check(b2.getSize() == 0);
    harness.check(b2.getNumBanks() == 1);
    harness.check(b2.getOffset() == 0);
   
    boolean pass = false;
    try
    {
      DataBufferInt b3 = new DataBufferInt(-1);
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;
    }
View Full Code Here

  private void testConstructor2(TestHarness harness)
  {
    harness.checkPoint("DataBufferInt(int[][], int)");
    int[][] source = new int[][] {{1, 2}};
    DataBufferInt b = new DataBufferInt(source, 1);
    harness.check(b.getSize() == 1);
    harness.check(b.getNumBanks() == 1);
    harness.check(b.getOffset() == 0);
   
    // does a change to the source array affect the buffer? yes
    int[][] banks = b.getBankData();
    harness.check(banks[0][0] == 1);
    source[0][0] = 3;
    harness.check(banks[0][0] == 3);
   
    // check null source
    boolean pass = false;
    try
    {
      DataBufferInt b1 = new DataBufferInt((int[][]) null, 1);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // check negative size
    DataBufferInt b1 = new DataBufferInt(source, -1);
    harness.check(b1.getSize() == -1);
  }
View Full Code Here

  private void testConstructor3(TestHarness harness)
  {
    harness.checkPoint("DataBufferInt(int[][], int, int[])");
    int[][] source = new int[][] {{1, 2}};
    DataBufferInt b = new DataBufferInt(source, 1, new int[] {0});
    harness.check(b.getSize() == 1);
    harness.check(b.getNumBanks() == 1);
    harness.check(b.getOffset() == 0);

    // test where offsets are specified
    source = new int[][] {{1, 2, 3}, {4, 5, 6, 7}};
    b = new DataBufferInt(source, 2, new int[] {0, 1});
    harness.check(b.getSize() == 2);
    harness.check(b.getNumBanks() == 2);
    harness.check(b.getOffsets()[1] == 1);
    harness.check(b.getElem(1, 0) == 5);

    boolean pass = false;
    try
    {
      DataBufferInt b1 = new DataBufferInt((int[][]) null, 1, new int[] {0});
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    pass = false;
    try
    {
      DataBufferInt b1 = new DataBufferInt(new int[][]{{1, 2}}, 1, (int[]) null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    pass = false;
    try
    {
      DataBufferInt b2 = new DataBufferInt(new int[][]{{1, 2}}, 1, new int[] {0, 0});
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

  }

  private void testConstructor4(TestHarness harness)
  {
    harness.checkPoint("DataBufferInt(int[], int)");
    DataBufferInt b = new DataBufferInt(new int[] {1, 2}, 2);
    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);
      int ignore = b1.getElem(0);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
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.