Package java.awt.image

Examples of java.awt.image.DataBufferUShort


                                                 scanlineStride,
                                                 bands,
                                                 bandOffsets[bands],
                                                 origin);
        } else {
            dataBuffer = new DataBufferUShort(height*scanlineStride);
            ras = Raster.createInterleavedRaster(dataBuffer,
                                                 width, height,
                                                 scanlineStride,
                                                 bands,
                                                 bandOffsets[bands],
View Full Code Here


                System.arraycopy(srcDBT.getData(b), offsets[b],
                                 retDBT.getData(b), offsets[b], len);
                break;
            }
            case DataBuffer.TYPE_USHORT: {
                DataBufferUShort srcDBT = (DataBufferUShort)srcDB;
                DataBufferUShort retDBT = (DataBufferUShort)retDB;
                System.arraycopy(srcDBT.getData(b), offsets[b],
                                 retDBT.getData(b), offsets[b], len);
                break;
            }
            default:
                throw new
                    UnsupportedOperationException("unsupported data type: "
View Full Code Here

    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.setDataElements(0, 0, new short[] { (short) 0x7777 }, db);
    m1.setDataElements(1, 0, new short[] { (short) 0x8888 }, db);
    m1.setDataElements(0, 1, new short[] { (short) 0x9999 }, db);
    m1.setDataElements(1, 1, new short[] { (short) 0xAAAA }, db);
    m1.setDataElements(0, 2, new short[] { (short) 0xBBBB }, db);
    m1.setDataElements(1, 2, new short[] { (short) 0xCCCC }, db);
    harness.check(db.getElem(0), 0x7777);
    harness.check(db.getElem(1), 0x8888);
    harness.check(db.getElem(2), 0x9999);
    harness.check(db.getElem(3), 0xAAAA);
    harness.check(db.getElem(4), 0xBBBB);
    harness.check(db.getElem(5), 0xCCCC);
     
    // set a value with non-standard scanline stride
    SinglePixelPackedSampleModel m2 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_USHORT, 2, 2, 3, new int[] { 0xFF00, 0x00FF }
    );
    m2.setDataElements(0, 0, new short[] { (short) 0x1111 }, db);
    m2.setDataElements(1, 0, new short[] { (short) 0x2222 }, db);
    m2.setDataElements(0, 1, new short[] { (short) 0x3333 }, db);
    m2.setDataElements(1, 1, new short[] { (short) 0x4444 }, db);
    harness.check(db.getElem(0), 0x1111);
    harness.check(db.getElem(1), 0x2222);
    harness.check(db.getElem(3), 0x3333);
    harness.check(db.getElem(4), 0x4444);
       
    // set a value with x < 0
    try
    {
      m1.setDataElements(-1, 0, new short[] { (short) 0x9999 }, db);
View Full Code Here

  }

  private void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("DataBufferUShort(int)");
    DataBufferUShort b1 = new DataBufferUShort(1);
    harness.check(b1.getDataType() == DataBuffer.TYPE_USHORT);
    harness.check(b1.getSize() == 1);
    harness.check(b1.getNumBanks() == 1);
    harness.check(b1.getOffset() == 0);

    DataBufferUShort b2 = new DataBufferUShort(0);
    harness.check(b2.getSize() == 0);
    harness.check(b2.getNumBanks() == 1);
    harness.check(b2.getOffset() == 0);

   boolean pass = false;
    try
    {
        DataBufferUShort b3 = new DataBufferUShort(-1);
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;
    }
View Full Code Here

  private void testConstructor2(TestHarness harness
  {
    harness.checkPoint("DataBufferShort(short[][], int)");
    short[][] source = new short[][] {{1, 2}};
    DataBufferUShort b = new DataBufferUShort(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
    short[][] 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
    {
        DataBufferUShort b1 = new DataBufferUShort((short[][]) null, 1);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    // check negative size
    DataBufferUShort b1 = new DataBufferUShort(source, -1);
    harness.check(b1.getSize() == -1);
  }
View Full Code Here

  private void testConstructor3(TestHarness harness)  
  {
    harness.checkPoint("DataBufferUShort(short[][], int, int[])");
    short[][] source = new short[][] {{1, 2}};
    DataBufferUShort b = new DataBufferUShort(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 short[][] {{1, 2, 3}, {4, 5, 6, 7}};
    b = new DataBufferUShort(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
    {
      DataBufferUShort b1 = new DataBufferUShort((short[][]) null, 1, new int[] {0});
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    pass = false;
    try
    {
       DataBufferUShort b1 = new DataBufferUShort(new short[][]{{1, 2}}, 1, (int[]) null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    pass = false;
    try
    {
      DataBufferUShort b2 = new DataBufferUShort(new short[][]{{1, 2}}, 1, new int[] {0, 0});
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

    harness.checkPoint("(int, int, int, int, 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.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), 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.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), 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.setSample(-1, 0, 0, 0x0044, db);
View Full Code Here

  }

  private void testConstructor4(TestHarness harness
  {
    harness.checkPoint("DataBufferUShort(short[], int)");
    DataBufferUShort b = new DataBufferUShort(new short[] {1, 2}, 2);
    harness.check(b.getSize() == 2);
    harness.check(b.getNumBanks() == 1);
    harness.check(b.getOffset() == 0);
    // this constructor, unlike all the other DataBuffer classes, rejects
    // a null bank
    boolean pass = false;
    try
    {
      DataBufferUShort b1 = new DataBufferUShort((short[]) null, 1);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
View Full Code Here

  }

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

    // this constructor, unlike all the other DataBuffer classes, rejects
    // a null bank
    boolean pass = false;
    try
    {
      DataBufferUShort b1 = new DataBufferUShort((short[]) null, 1, 0);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

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

  }

  private void testConstructor6(TestHarness harness)
  {
    harness.checkPoint("DataBufferUShort(int, int)");
    DataBufferUShort b = new DataBufferUShort(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
    {
      DataBufferUShort b1 = new DataBufferUShort(-1, 1);
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;
    }
    harness.check(pass);

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

TOP

Related Classes of java.awt.image.DataBufferUShort

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.