Package java.awt.image

Examples of java.awt.image.DataBuffer


 
  private void test2(TestHarness harness)
  {
    harness.checkPoint("(int, int, int, float, DataBuffer)")

    DataBuffer db = new DataBufferFloat(12);
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_FLOAT,
            3, 2, 2, 6, new int[] {0, 1});
    m.setSample(2, 1, 0, 99.9f, db);
    harness.check(db.getElem(0, 10), 99.0f);
    m.setSample(2, 1, 1, 88.8f, db);
    harness.check(db.getElem(0, 11), 88.0f);
   
    // what happens if the data buffer doesn't hold floats?
    DataBuffer db2 = new DataBufferInt(12);
    m.setSample(2, 1, 0, 99.9f, db2);
    harness.check(db2.getElem(0, 10), 99);
    m.setSample(2, 1, 1, 88.8f, db2);
    harness.check(db2.getElem(0, 11), 88);
    
    // check that a null data buffer generates a NullPointerException
    boolean pass = false;
    try
      {
View Full Code Here


    harness.checkPoint("(int, int, Object, DataBuffer(Byte))");
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_BYTE, 2, 3, new int[] { 0xF0, 0x0F }
    );
    byte[] b = new byte[] { (byte) 0x11, (byte) 0x22, (byte) 0x33, (byte) 0x44, (byte) 0x55, (byte) 0x66 };
    DataBuffer db = new DataBufferByte(b, 6)

    // set a value
    m1.setDataElements(0, 0, new byte[] { (byte) 0x77 }, db);
    m1.setDataElements(1, 0, new byte[] { (byte) 0x88 }, db);
    m1.setDataElements(0, 1, new byte[] { (byte) 0x99 }, db);
    m1.setDataElements(1, 1, new byte[] { (byte) 0xAA }, db);
    m1.setDataElements(0, 2, new byte[] { (byte) 0xBB }, db);
    m1.setDataElements(1, 2, new byte[] { (byte) 0xCC }, db);
    harness.check(db.getElem(0), 0x77);
    harness.check(db.getElem(1), 0x88);
    harness.check(db.getElem(2), 0x99);
    harness.check(db.getElem(3), 0xAA);
    harness.check(db.getElem(4), 0xBB);
    harness.check(db.getElem(5), 0xCC);
   
    // set a value with non-standard scanline stride
    SinglePixelPackedSampleModel m2 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_BYTE, 2, 2, 3, new int[] { 0xF0, 0x0F }
    );
    m2.setDataElements(0, 0, new byte[] { (byte) 0x11 }, db);
    m2.setDataElements(1, 0, new byte[] { (byte) 0x22 }, db);
    m2.setDataElements(0, 1, new byte[] { (byte) 0x33 }, db);
    m2.setDataElements(1, 1, new byte[] { (byte) 0x44 }, db);
    harness.check(db.getElem(0), 0x11);
    harness.check(db.getElem(1), 0x22);
    harness.check(db.getElem(3), 0x33);
    harness.check(db.getElem(4), 0x44);
     
    // set a value with x < 0
    try
    {
      m1.setDataElements(-1, 0, new byte[] { (byte) 0x99}, db);
View Full Code Here

 
  private void test3(TestHarness harness)
  {
    harness.checkPoint("(int, int, int, int, DataBuffer)")
   
    DataBuffer db = new DataBufferInt(12);
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
            3, 2, 2, 6, new int[] {0, 1});
    m.setSample(2, 1, 0, 99, db);
    harness.check(db.getElem(0, 10), 99);
    m.setSample(2, 1, 1, 88, db);
    harness.check(db.getElem(0, 11), 88);
   
    // what happens if the data buffer doesn't hold integers?
    DataBuffer db2 = new DataBufferByte(12);
    m.setSample(2, 1, 0, 99, db2);
    harness.check(db2.getElem(0, 10), 99);
    m.setSample(2, 1, 1, 888, db2);
    harness.check(db2.getElem(0, 11), 120)// (byte) 888
   
    // check that a null data buffer generates a NullPointerException
    boolean pass = false;
    try
      {
View Full Code Here

{
  public void test(TestHarness harness)
  {
    MultiPixelPackedSampleModel m = new MultiPixelPackedSampleModel(
        DataBuffer.TYPE_INT, 10, 20, 8);
    DataBuffer db = m.createDataBuffer();
    harness.check(db.getDataType(), DataBuffer.TYPE_INT);
    harness.check(db.getNumBanks(), 1);
    harness.check(db.getSize(), 60);

    MultiPixelPackedSampleModel m2 = new MultiPixelPackedSampleModel(
            DataBuffer.TYPE_INT, 10, 20, 8, 4, 16);
    DataBuffer db2 = m2.createDataBuffer();
    harness.check(db2.getDataType(), DataBuffer.TYPE_INT);
    harness.check(db2.getNumBanks(), 1);
    harness.check(db2.getSize(), 81);

    MultiPixelPackedSampleModel m3 = new MultiPixelPackedSampleModel(
            DataBuffer.TYPE_BYTE, 10, 20, 8);
    DataBuffer db3 = m3.createDataBuffer();
    harness.check(db3.getDataType(), DataBuffer.TYPE_BYTE);
    harness.check(db3.getNumBanks(), 1);
    harness.check(db3.getSize(), 200);

    MultiPixelPackedSampleModel m4 = new MultiPixelPackedSampleModel(
            DataBuffer.TYPE_BYTE, 10, 20, 8, 11, 16);
    DataBuffer db4 = m4.createDataBuffer();
    harness.check(db4.getDataType(), DataBuffer.TYPE_BYTE);
    harness.check(db4.getNumBanks(), 1);
    harness.check(db4.getSize(), 222);
 
    MultiPixelPackedSampleModel m5 = new MultiPixelPackedSampleModel(
            DataBuffer.TYPE_USHORT, 10, 20, 8);
    DataBuffer db5 = m5.createDataBuffer();
    harness.check(db5.getDataType(), DataBuffer.TYPE_USHORT);
    harness.check(db5.getNumBanks(), 1);
    harness.check(db5.getSize(), 100);

    MultiPixelPackedSampleModel m6 = new MultiPixelPackedSampleModel(
            DataBuffer.TYPE_USHORT, 10, 20, 8, 6, 16);
    DataBuffer db6 = m6.createDataBuffer();
    harness.check(db6.getDataType(), DataBuffer.TYPE_USHORT);
    harness.check(db6.getNumBanks(), 1);
    harness.check(db6.getSize(), 121);
  }
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

    harness.checkPoint("(int, int, Object, DataBuffer(Int))");
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_INT, 2, 3, new int[] { 0xFFFF00, 0x00FFFF }
    );
    int[] i = new int[] { (int) 0x11111111, (int) 0x22222222, (int) 0x33333333, (int) 0x44444444, (int) 0x55555555, (int) 0x66666666 };
    DataBuffer db = new DataBufferInt(i, 6)

    // set a value
    m1.setDataElements(0, 0, new int[] { (int) 0x77777777 }, db);
    m1.setDataElements(1, 0, new int[] { (int) 0x88888888 }, db);
    m1.setDataElements(0, 1, new int[] { (int) 0x99999999 }, db);
    m1.setDataElements(1, 1, new int[] { (int) 0xAAAAAAAA }, db);
    m1.setDataElements(0, 2, new int[] { (int) 0xBBBBBBBB }, db);
    m1.setDataElements(1, 2, new int[] { (int) 0xCCCCCCCC }, db);
    harness.check(db.getElem(0), 0x77777777);
    harness.check(db.getElem(1), 0x88888888);
    harness.check(db.getElem(2), 0x99999999);
    harness.check(db.getElem(3), 0xAAAAAAAA);
    harness.check(db.getElem(4), 0xBBBBBBBB);
    harness.check(db.getElem(5), 0xCCCCCCCC);
       
    // set a value with non-standard scanline stride
    SinglePixelPackedSampleModel m2 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_INT, 2, 2, 3, new int[] { 0xFFFF00, 0x00FFFF }
    );
    m2.setDataElements(0, 0, new int[] { (int) 0x11111111 }, db);
    m2.setDataElements(1, 0, new int[] { (int) 0x22222222 }, db);
    m2.setDataElements(0, 1, new int[] { (int) 0x33333333 }, db);
    m2.setDataElements(1, 1, new int[] { (int) 0x44444444 }, db);
    harness.check(db.getElem(0), 0x11111111);
    harness.check(db.getElem(1), 0x22222222);
    harness.check(db.getElem(3), 0x33333333);
    harness.check(db.getElem(4), 0x44444444);
         
    // set a value with x < 0
    try
    {
      m1.setDataElements(-1, 0, new int[] { (int) 0x9999 }, db);
View Full Code Here

public class getDataElements implements Testlet
{
  public void test(TestHarness harness)
  {
    DataBuffer db = new DataBufferInt(12);
    for (int i = 0; i < 12; i++)
      db.setElem(i, i);
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
            3, 2, 2, 6, new int[] {0, 1});
    Object elements = m.getDataElements(0, 0, 2, 1, null, db);
    int[] de = (int[]) elements;
    harness.check(de.length, 4);
View Full Code Here

public class setPixel 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.setPixel(1, 1, pixel, db);
    harness.check(db.getElem(0, 8), 11);
    harness.check(db.getElem(0, 9), 22);
       
    // check that a null pixel array generates a NullPointerException
    boolean pass = false;
    try
      {
View Full Code Here

  public void test(TestHarness harness)
  {
    harness.checkPoint("(int, int, int, DataBuffer)");
    SampleModel m = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, 10,
            20, new int[] { 224, 28, 3 });
    DataBuffer db = m.createDataBuffer();
    harness.check(m.getSampleFloat(1, 2, 0, db), 0);
    harness.check(m.getSampleFloat(1, 2, 1, db), 0);
    harness.check(m.getSampleFloat(1, 2, 2, db), 0);
    m.setPixel(1, 2, new int[] {1, 2, 3}, db);
    harness.check(m.getSampleFloat(1, 2, 0, db), 1);
View Full Code Here

{
  public void test(TestHarness harness)
  {
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 5,
            10, 3, 16, new int[] {0, 1, 2});
    DataBuffer db = m.createDataBuffer();
    harness.check(db.getNumBanks(), 1);
    db.setElem(0, 16, 0xAA);
    db.setElem(0, 17, 0xBB);
    db.setElem(0, 18, 0xCC);
    harness.check(m.getSample(0, 1, 0, db), 0xAA);
    harness.check(m.getSample(0, 1, 1, db), 0xBB);
    harness.check(m.getSample(0, 1, 2, db), 0xCC);
   
    // try negative x
View Full Code Here

TOP

Related Classes of java.awt.image.DataBuffer

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.