Package java.awt.image

Examples of java.awt.image.ComponentSampleModel


  }
 
  private void test2(TestHarness harness)
  {
    harness.checkPoint("(int)")
    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
            11, 2, 44, new int[] {0, 0});
    harness.check(m1.getSampleSize(0), 32);
    harness.check(m1.getSampleSize(1), 32);
    harness.check(m1.getSampleSize(2), 32);
    harness.check(m1.getSampleSize(3), 32);
    harness.check(m1.getSampleSize(-1), 32);
  }
View Full Code Here


{
  public void test(TestHarness harness)
  {
    DataBuffer db = new DataBufferInt(12);
    int[] samples = new int[] {11, 22};
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
            3, 2, 2, 6, new int[] {0, 1});
    m.setSamples(1, 0, 2, 1, 1, samples, db);
    harness.check(db.getElem(0, 3), 11);
    harness.check(db.getElem(0, 5), 22);
       
    // check that a null data buffer generates a NullPointerException
    boolean pass = false;
    try
      {
        m.setSamples(1, 0, 2, 1, 1, samples, null);
      }
    catch (NullPointerException e)
      {
        pass = true;
      }
View Full Code Here

  }
 
  public void testMethod1(TestHarness harness)
  {
    harness.checkPoint("(int, int)");
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 5,
            10, 3, 15, new int[] {0, 1, 2});
    harness.check(m.getOffset(0, 0), 0);
    harness.check(m.getOffset(1, 0), 3);
    harness.check(m.getOffset(2, 0), 6);
    harness.check(m.getOffset(3, 0), 9);
    harness.check(m.getOffset(4, 0), 12);
    harness.check(m.getOffset(5, 0), 15);
    harness.check(m.getOffset(0, 1), 15);
    harness.check(m.getOffset(1, 1), 18);
    harness.check(m.getOffset(2, 1), 21);
    harness.check(m.getOffset(3, 1), 24);
    harness.check(m.getOffset(4, 1), 27);
    harness.check(m.getOffset(5, 1), 30);
  }
View Full Code Here

  }

  public void testMethod2(TestHarness harness)
  {
    harness.checkPoint("(int, int, int)");
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 5,
            10, 3, 15, new int[] {0, 1, 2});
    harness.check(m.getOffset(0, 0, 1), 1);
    harness.check(m.getOffset(1, 0, 1), 4);
    harness.check(m.getOffset(2, 0, 1), 7);
    harness.check(m.getOffset(3, 0, 1), 10);
    harness.check(m.getOffset(4, 0, 1), 13);
    harness.check(m.getOffset(5, 0, 1), 16);
    harness.check(m.getOffset(0, 1, 1), 16);
    harness.check(m.getOffset(1, 1, 1), 19);
    harness.check(m.getOffset(2, 1, 1), 22);
    harness.check(m.getOffset(3, 1, 1), 25);
    harness.check(m.getOffset(4, 1, 1), 28);
    harness.check(m.getOffset(5, 1, 1), 31);
  }
View Full Code Here

public class getSampleFloat implements Testlet
{
  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.getSampleFloat(0, 1, 0, db), 0xAA);
    harness.check(m.getSampleFloat(0, 1, 1, db), 0xBB);
    harness.check(m.getSampleFloat(0, 1, 2, db), 0xCC);
   
    // try negative x
    boolean pass = false;
    try
    {
      m.getSampleFloat(-1, 1, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);

    // try x == width
    pass = false;
    try
    {
      m.getSampleFloat(5, 0, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    // try negative y
    pass = false;
    try
    {
      m.getSampleFloat(1, -1, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    // try y == height
    pass = false;
    try
    {
      m.getSampleFloat(0, 10, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

public class getSampleDouble implements Testlet
{
  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.getSampleDouble(0, 1, 0, db), 0xAA);
    harness.check(m.getSampleDouble(0, 1, 1, db), 0xBB);
    harness.check(m.getSampleDouble(0, 1, 2, db), 0xCC);
   
    // try negative x
    boolean pass = false;
    try
    {
      m.getSampleDouble(-1, 1, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);

    // try x == width
    pass = false;
    try
    {
      m.getSampleDouble(5, 0, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    // try negative y
    pass = false;
    try
    {
      m.getSampleDouble(1, -1, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    // try y == height
    pass = false;
    try
    {
      m.getSampleDouble(0, 10, 0, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

public class createCompatibleSampleModel implements Testlet
{
  public void test(TestHarness harness)
  {
    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
            11, 1, 25, new int[] {1, 2}, new int[] {3, 4});
    SampleModel m2 = m1.createCompatibleSampleModel(33, 44);
    harness.check(m2 instanceof ComponentSampleModel);
    harness.check(m2.getDataType(), DataBuffer.TYPE_INT);
    harness.check(m2.getWidth(), 33);
    harness.check(m2.getHeight(), 44);
    harness.check(m2.getNumBands(), 2);
    harness.check(Arrays.equals(m1.getBandOffsets(), new int[] {3, 4}));
    harness.check(Arrays.equals(m1.getBankIndices(), new int[] {1, 2}));
  }
View Full Code Here

    testMultiBand(harness);
  }
 
  public void testSingleBand(TestHarness harness)
  {
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 10,
            20, 1, 30, new int[] {0, 1, 2});
    DataBuffer db = m.createDataBuffer();
    harness.check(db.getDataType(), DataBuffer.TYPE_BYTE);
    harness.check(db.getNumBanks(), 1);
    harness.check(db.getSize(), 582);
   
    m = new ComponentSampleModel(DataBuffer.TYPE_INT, 5, 10, 1, 5,
            new int[] {0, 1, 2});
    db = m.createDataBuffer();
    harness.check(db.getDataType(), DataBuffer.TYPE_INT);
    harness.check(db.getNumBanks(), 1);
    harness.check(db.getSize(), 52);

    m = new ComponentSampleModel(DataBuffer.TYPE_INT, 5, 10, 1, 6,
            new int[] {0, 1, 2});
    db = m.createDataBuffer();
    harness.check(db.getDataType(), DataBuffer.TYPE_INT);
    harness.check(db.getNumBanks(), 1);
    harness.check(db.getSize(), 61)

    m = new ComponentSampleModel(DataBuffer.TYPE_INT, 5, 10, 2, 10,
            new int[] {0, 1});
    db = m.createDataBuffer();
    harness.check(db.getDataType(), DataBuffer.TYPE_INT);
    harness.check(db.getNumBanks(), 1);
    harness.check(db.getSize(), 100);   
  }
View Full Code Here

  }
 
  public void testMultiBand(TestHarness harness)
  {
    harness.checkPoint("testMultiBand()");
    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 10,
            20, 1, 10, new int[] {0, 1, 2}, new int[] {0, 0, 0});
    DataBuffer db = m.createDataBuffer();
    harness.check(db.getDataType(), DataBuffer.TYPE_BYTE);
    harness.check(db.getNumBanks(), 3);
    harness.check(db.getSize(), 200);
   
  }
View Full Code Here

public class getScanlineStride implements Testlet
{
  public void test(TestHarness harness)
  {
    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
        11, 2, 44, new int[] {0, 0});
    harness.check(m1.getScanlineStride(), 44);
  }
View Full Code Here

TOP

Related Classes of java.awt.image.ComponentSampleModel

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.