Package java.awt.image

Examples of java.awt.image.SinglePixelPackedSampleModel


  }

  public void testMethod3(TestHarness harness)
  {
    harness.checkPoint("(int, int, int, int, double[], DataBuffer)");    
    SampleModel m = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, 10,
            20, new int[] { 224, 28, 3 });
    DataBuffer db = m.createDataBuffer();
    double[] pixel = new double[18];
    m.getPixels(1, 2, 2, 3, pixel, db);
    harness.check(Arrays.equals(pixel, new double[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0}));
    m.setPixels(1, 2, 2, 3, new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
            13, 14, 15, 16, 17, 18}, db);
    m.getPixels(1, 2, 2, 3, pixel, db);
    harness.check(Arrays.equals(pixel, new double[] {1, 2, 3, 4, 5, 2, 7, 0, 1,
            2, 3, 0, 5, 6, 3, 0, 1, 2}));
   
    // try null pixel data
    boolean pass = false;
    try
    {
      m.setPixels(1, 2, 2, 3, (double[]) null, db);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    // try null data buffer
    pass = false;
    try
    {
      m.setPixels(1, 2, 2, 3, pixel, null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
View Full Code Here


  }

  private void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("(int, int, int, int[])");
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_BYTE, 1, 2, new int[] { 224, 28, 3 }
    );
    harness.check(m1.getDataType(), DataBuffer.TYPE_BYTE);       // check 1
    harness.check(m1.getWidth(), 1);                             // check 2
    harness.check(m1.getHeight(), 2);                            // check 3
    harness.check(m1.getNumBands(), 3);                          // check 4
   
    // unsupported data type should throw an IllegalArgumentException
    try                                                          // check 5
    {
      /* SampleModel m2 = */ new SinglePixelPackedSampleModel(
        DataBuffer.TYPE_DOUBLE, 1, 2, new int[] { 224, 28, 3 }
      );
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }
   
    // if 'w' is <= 0 there should be an IllegalArgumentException
    try                                                          // check 6
    {
      /* SampleModel m2 = */ new SinglePixelPackedSampleModel(
        DataBuffer.TYPE_BYTE, 0, 2, new int[] { 224, 28, 3 }
      );
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }
   
    // if 'h' is <= 0 there should be an IllegalArgumentException
    try                                                          // check 7
    {
      /* SampleModel m2 = */ new SinglePixelPackedSampleModel(
        DataBuffer.TYPE_BYTE, 1, 0, new int[] { 224, 28, 3 }
      );
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }
   
    // if mask array is empty there should be an IllegalArgumentException
    try                                                          // check 8
    {
      /* SampleModel m2 = */ new SinglePixelPackedSampleModel(
        DataBuffer.TYPE_BYTE, 1, 2, new int[] { }
      );
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }

    // if mask array contains a non-contiguous mask there should be an IllegalArgumentException
    try
    {
      /* SampleModel m2 = */ new SinglePixelPackedSampleModel(
        DataBuffer.TYPE_BYTE, 1, 2, new int[] { 224, 27, 3 }
      );
      harness.check(false);
    }
    catch (IllegalArgumentException e)
View Full Code Here

  }

  private void testConstructor2(TestHarness harness)  
  {
    harness.checkPoint("(int, int, int, int, int[])");
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_BYTE, 1, 2, 3, new int[] { 224, 28, 3 }
    );
    harness.check(m1.getDataType(), DataBuffer.TYPE_BYTE);       // check 1
    harness.check(m1.getWidth(), 1);                             // check 2
    harness.check(m1.getHeight(), 2);                            // check 3
    harness.check(m1.getNumBands(), 3);                          // check 4
   
    // unsupported data type should throw an IllegalArgumentException
    try
    {
      /* SampleModel m2 = */ new SinglePixelPackedSampleModel(
        DataBuffer.TYPE_DOUBLE, 1, 2, 3, new int[] { 224, 28, 3 }
      );
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }
   
    // if 'w' is <= 0 there should be an IllegalArgumentException
    try
    {
      /* SampleModel m2 = */ new SinglePixelPackedSampleModel(
        DataBuffer.TYPE_BYTE, 0, 2, 3, new int[] { 224, 28, 3 }
      );
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }
   
    // if 'h' is <= 0 there should be an IllegalArgumentException
    try
    {
      /* SampleModel m2 = */ new SinglePixelPackedSampleModel(
        DataBuffer.TYPE_BYTE, 1, 0, 3, new int[] { 224, 28, 3 }
      );
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }
   
    // if mask array is empty there should be an IllegalArgumentException
    try
    {
      /* SampleModel m2 = */ new SinglePixelPackedSampleModel(
        DataBuffer.TYPE_BYTE, 1, 2, 3, new int[] { }
      );
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }

    // if mask array contains a non-contiguous mask there should be an IllegalArgumentException
    try
    {
      /* SampleModel m2 = */ new SinglePixelPackedSampleModel(
        DataBuffer.TYPE_BYTE, 1, 2, new int[] { 224, 27, 3 }
      );
      harness.check(false);
    }
    catch (IllegalArgumentException e)
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_BYTE, 2, 2, new int[] { 0xF0, 0x0F }
    );
    DataBufferByte db = new DataBufferByte(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0xAB, (byte) 0xCD }, 4);

    // check regular fetch
    int sample = m1.getSample(1, 1, 1, db);
    harness.check(sample, 0x0D);
    // check regular fetch with negative x
    try
    {
      sample = m1.getSample(-2, 0, 0, db);
      harness.check(false);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      harness.check(true);
    }
    // check regular fetch with negative y
    try
    {
      sample = m1.getSample(0, -1, 0, db);
      harness.check(false);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      harness.check(true);
    }
 
    // check null data buffer
    try
    {
      sample = m1.getSample(0, 0, 0, null);
      harness.check(false);
    }
    catch (NullPointerException e)
    {
      harness.check(true);
View Full Code Here

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

  }
 
  public void test2(TestHarness harness)
  {
    harness.checkPoint("(int)");
    SampleModel m = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, 10,
            20, new int[] { 224, 28, 3 });
    harness.check(m.getSampleSize(0), 3);
    harness.check(m.getSampleSize(1), 3);
    harness.check(m.getSampleSize(2), 2);
   
    boolean pass = false;
    try
    {
      m.getSampleSize(-1);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    pass = false;
    try
    {
      m.getSampleSize(3);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_BYTE, 1, 2, new int[] { 224, 28, 3 }
    );
    harness.check(Arrays.equals(m1.getBitOffsets(), new int[] { 5, 2, 0 }));
  }
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_BYTE, 2, 2, new int[] { 0xF0, 0x0F }
    );
    DataBufferByte db = new DataBufferByte(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0xAB, (byte) 0xCD }, 4);

    // check regular fetch
    int[] samples = m1.getPixel(1, 1, (int[]) null, db);
    harness.check(samples[0], 0x0C);
    harness.check(samples[1], 0x0D);
   
    // check regular fetch with negative x
    try
    {
      samples = m1.getPixel(-2, 0, (int[]) null, db);
      harness.check(false);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      harness.check(true);
    }
   
    // check regular fetch with negative y
    try
    {
      samples = m1.getPixel(0, -1, (int[]) null, db);
      harness.check(false);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      harness.check(true);
    }
   
    // check regular fetch with presupplied array
    int[] samplesIn = new int[2];
    int[] samplesOut = m1.getPixel(1, 1, samplesIn, db);
    harness.check(samplesIn == samplesOut);
    harness.check(samplesOut[0], 0x0C);
    harness.check(samplesOut[1], 0x0D);

    // check regular fetch with presupplied array too short
    int[] samplesIn2 = new int[1];
    try
    {
      /* int[] samplesOut2 = */ m1.getPixel(1, 1, samplesIn2, db);
      harness.check(false);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      harness.check(true);
    }
   
    // check null data buffer
    try
    {
      samples = m1.getPixel(0, 0, (int[]) null, null);
      harness.check(false);
    }
    catch (NullPointerException e)
    {
      harness.check(true);
View Full Code Here

  }
 
  public void testMethod1(TestHarness harness)
  {
    harness.checkPoint("(int, int, int, int, int, int[], DataBuffer)");
    SampleModel m = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, 10,
            20, new int[] { 224, 28, 3 });
    DataBuffer db = m.createDataBuffer();
    int[] samples = new int[6];
    m.getSamples(1, 2, 2, 3, 1, samples, db);
    harness.check(Arrays.equals(samples, new int[] {0, 0, 0, 0, 0, 0}));
    m.setSamples(1, 2, 2, 3, 0, new int[] {1, 2, 3, 4 ,5 ,6}, db);
    m.getSamples(1, 2, 2, 3, 0, samples, db);
    harness.check(Arrays.equals(samples, new int[] {1, 2, 3, 4, 5, 6}));
    m.setSamples(1, 2, 2, 3, 1, new int[] {7, 8, 9, 10, 11, 12}, db);
    m.getSamples(1, 2, 2, 3, 1, samples, db);
    harness.check(Arrays.equals(samples, new int[] {7, 0, 1, 2, 3, 4}));
    m.setSamples(1, 2, 2, 3, 2, new int[] {13, 14, 15, 16, 17, 18}, db);
    m.getSamples(1, 2, 2, 3, 2, samples, db);
    harness.check(Arrays.equals(samples, new int[] {1, 2, 3, 0, 1, 2}));
   
    // try invalid band
    boolean pass = false;
    try
    {
      m.setSamples(1, 2, 2, 3, 3, samples, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try null sample data
    pass = false;
    try
    {
      m.setSamples(1, 2, 2, 3, 0, (int[]) null, db);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    // try null data buffer
    pass = false;
    try
    {
      m.getSamples(1, 2, 2, 3, 0, samples, null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
View Full Code Here

  }
 
  public void testMethod2(TestHarness harness)
  {
    harness.checkPoint("(int, int, int, int, int, float[], DataBuffer)");    
    SampleModel m = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, 10,
            20, new int[] { 224, 28, 3 });
    DataBuffer db = m.createDataBuffer();
    float[] samples = new float[6];
    m.getSamples(1, 2, 2, 3, 1, samples, db);
    harness.check(Arrays.equals(samples, new float[] {0, 0, 0, 0, 0, 0}));
    m.setSamples(1, 2, 2, 3, 0, new float[] {1, 2, 3, 4 ,5 ,6}, db);
    m.getSamples(1, 2, 2, 3, 0, samples, db);
    harness.check(Arrays.equals(samples, new float[] {1, 2, 3, 4, 5, 6}));
    m.setSamples(1, 2, 2, 3, 1, new float[] {7, 8, 9, 10, 11, 12}, db);
    m.getSamples(1, 2, 2, 3, 1, samples, db);
    harness.check(Arrays.equals(samples, new float[] {7, 0, 1, 2, 3, 4}));
    m.setSamples(1, 2, 2, 3, 2, new float[] {13, 14, 15, 16, 17, 18}, db);
    m.getSamples(1, 2, 2, 3, 2, samples, db);
    harness.check(Arrays.equals(samples, new float[] {1, 2, 3, 0, 1, 2}));
   
    // try invalid band
    boolean pass = false;
    try
    {
      m.setSamples(1, 2, 2, 3, 3, samples, db);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try null sample data
    pass = false;
    try
    {
      m.setSamples(1, 2, 2, 3, 0, (float[]) null, db);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);

    // try null data buffer
    pass = false;
    try
    {
      m.getSamples(1, 2, 2, 3, 0, samples, null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
View Full Code Here

TOP

Related Classes of java.awt.image.SinglePixelPackedSampleModel

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.