Package java.awt.image

Examples of java.awt.image.SinglePixelPackedSampleModel


   *
   * @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 }
     );
     SinglePixelPackedSampleModel m2 = (SinglePixelPackedSampleModel) m1.createSubsetSampleModel(new int[] {0, 2});
     harness.check(m2.getDataType(), DataBuffer.TYPE_BYTE);              // check 1
     harness.check(m2.getWidth(), 1);                                    // check 2
     harness.check(m2.getHeight(), 2);                                   // check 3
     harness.check(m2.getNumBands(), 2);                                 // check 4
     harness.check(Arrays.equals(new int[] { 224, 3 }, m2.getBitMasks())); // check 5

     // if 'bands' contains an index outside the range there should be an ArrayIndexOutOfBoundsException
     try
     {
       /* SampleModel m3 = */ m1.createSubsetSampleModel(new int [] {0, 5});
View Full Code Here


   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    // two instances that are equal must have the same hashCode...
    SinglePixelPackedSampleModel m1 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_BYTE, 2, 2, new int[] { 224, 28, 3 }
    );
    SinglePixelPackedSampleModel m2 = new SinglePixelPackedSampleModel(
      DataBuffer.TYPE_BYTE, 2, 2, new int[] { 224, 28, 3 }
    );
    harness.check(m1.equals(m2));
    harness.check(m1.hashCode(), m2.hashCode());
  }
View Full Code Here

  }
 
  public void testMethod1(TestHarness harness)
  {
    harness.checkPoint("(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[] pixel = new int[18];
    m.getPixels(1, 2, 2, 3, pixel, db);
    harness.check(Arrays.equals(pixel, new int[] {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 int[] {1, 2, 3, 4, 5, 2, 7, 0, 1,
            2, 3, 0, 5, 6, 3, 0, 1, 2}));
   
    // if the incoming array is null, a new one is created
    pixel = m.getPixels(1, 2, 2, 3, (int[]) null, db);
    harness.check(Arrays.equals(pixel, new int[] {1, 2, 3, 4, 5, 2, 7, 0, 1,
            2, 3, 0, 5, 6, 3, 0, 1, 2}));
   
    // try null data buffer
    boolean pass = false;
    try
    {
      m.getPixels(1, 2, 2, 3, pixel, null);
    }
    catch (NullPointerException 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, 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.getSamples(0, 0, 1, 2, 1, (int[]) null, db);
    harness.check(samples[0], 0x02)// 1
    harness.check(samples[1], 0x0B)// 2

    // check regular fetch with negative x
    try 
    {
      samples = m1.getSamples(-1, 0, 1, 1, 1, (int[]) null, db);
      harness.check(false);
    }
    catch (ArrayIndexOutOfBoundsException e)  
    {
      harness.check(true);
    }

    // check regular fetch with negative y
    try
    {
      samples = m1.getSamples(0, -1, 1, 1, 1, (int[]) null, db);
      harness.check(false);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      harness.check(true);
    }

    // check regular fetch with w < 0
    try
    {
      samples = m1.getSamples(0, 0, -1, 1, 1, (int[]) null, db);
      harness.check(false);
    }
    catch (NegativeArraySizeException e)
    {
      harness.check(true);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      harness.check(true);
    }

    // check regular fetch with h < 0
    try
    {
      samples = m1.getSamples(0, 0, 1, -1, 1, (int[]) null, db);
      harness.check(false);
    }
    catch (NegativeArraySizeException e)
    {
      harness.check(true);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      harness.check(true);
    }

    // check regular fetch with band < 0
    try
    {
      samples = m1.getSamples(0, 0, 1, 1, -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.getSamples(1, 0, 1, 2, 0, samplesIn, db);
    harness.check(samplesIn == samplesOut);
    harness.check(samplesOut[0], 0x03);
    harness.check(samplesOut[1], 0x0C);

    // check regular fetch with presupplied array too short
    int[] samplesIn2 = new int[1];
    try
    {
      /* int[] samplesOut2 = */ m1.getSamples(1, 1, 1, 2, 1, samplesIn2, db);
      harness.check(false);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      harness.check(true);
    }

    // check null data buffer
    try
    {
      samples = m1.getSamples(0, 0, 1, 1, 1, (int[]) null, null);
      harness.check(false);
    }
    catch (NullPointerException e)
    {
      harness.check(true);
View Full Code Here

  }
 
  public void testMethod2(TestHarness harness)
  {
    harness.checkPoint("(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[] pixel = new float[18];
    m.getPixels(1, 2, 2, 3, pixel, db);
    harness.check(Arrays.equals(pixel, new float[] {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 float[] {1, 2, 3, 4, 5, 2, 7, 0, 1,
            2, 3, 0, 5, 6, 3, 0, 1, 2}));
   
    // if the incoming array is null, a new one is created
    pixel = m.getPixels(1, 2, 2, 3, (float[]) null, db);
    harness.check(Arrays.equals(pixel, new float[] {1, 2, 3, 4, 5, 2, 7, 0, 1,
            2, 3, 0, 5, 6, 3, 0, 1, 2}));
   
    // try null data buffer
    boolean pass = false;
    try
    {
      m.getPixels(1, 2, 2, 3, pixel, null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
View Full Code Here

  }

  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 double[] {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}));
   
    // if the incoming array is null, a new one is created
    pixel = m.getPixels(1, 2, 2, 3, (double[]) null, 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 data buffer
    boolean pass = false;
    try
    {
      m.getPixels(1, 2, 2, 3, pixel, null);
    }
    catch (NullPointerException e)
    {
      pass = 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.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.getSamples(1, 2, 2, 3, 0, samples, db);
    harness.check(Arrays.equals(samples, new int[] {1, 4, 7, 2, 5, 0}));
    m.getSamples(1, 2, 2, 3, 1, samples, db);
    harness.check(Arrays.equals(samples, new int[] {2, 5, 0, 3, 6, 1}));
    m.getSamples(1, 2, 2, 3, 2, samples, db);
    harness.check(Arrays.equals(samples, new int[] {3, 2, 1, 0, 3, 2}));
   
    // if the incoming array is null, a new one is created
    samples = m.getSamples(1, 2, 2, 3, 2, (int[]) null, db);
    harness.check(Arrays.equals(samples, new int[] {3, 2, 1, 0, 3, 2}));
   
    // try invalid band
    boolean pass = false;
    try
    {
      m.getSamples(1, 2, 2, 3, 3, samples, db);
    }
    catch (ArrayIndexOutOfBoundsException 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.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.getSamples(1, 2, 2, 3, 0, samples, db);
    harness.check(Arrays.equals(samples, new float[] {1, 4, 7, 2, 5, 0}));
    m.getSamples(1, 2, 2, 3, 1, samples, db);
    harness.check(Arrays.equals(samples, new float[] {2, 5, 0, 3, 6, 1}));
    m.getSamples(1, 2, 2, 3, 2, samples, db);
    harness.check(Arrays.equals(samples, new float[] {3, 2, 1, 0, 3, 2}));
   
    // if the incoming array is null, a new one is created
    samples = m.getSamples(1, 2, 2, 3, 2, (float[]) null, db);
    harness.check(Arrays.equals(samples, new float[] {3, 2, 1, 0, 3, 2}));
   
    // try invalid band
    boolean pass = false;
    try
    {
      m.getSamples(1, 2, 2, 3, 3, samples, db);
    }
    catch (ArrayIndexOutOfBoundsException 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 testMethod3(TestHarness harness)
  {
    harness.checkPoint("(int, 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[] samples = new double[6];
    m.getSamples(1, 2, 2, 3, 1, samples, db);
    harness.check(Arrays.equals(samples, new double[] {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.getSamples(1, 2, 2, 3, 0, samples, db);
    harness.check(Arrays.equals(samples, new double[] {1, 4, 7, 2, 5, 0}));
    m.getSamples(1, 2, 2, 3, 1, samples, db);
    harness.check(Arrays.equals(samples, new double[] {2, 5, 0, 3, 6, 1}));
    m.getSamples(1, 2, 2, 3, 2, samples, db);
    harness.check(Arrays.equals(samples, new double[] {3, 2, 1, 0, 3, 2}));
   
    // if the incoming array is null, a new one is created
    samples = m.getSamples(1, 2, 2, 3, 2, (double[]) null, db);
    harness.check(Arrays.equals(samples, new double[] {3, 2, 1, 0, 3, 2}));
   
    // try invalid band
    boolean pass = false;
    try
    {
      m.getSamples(1, 2, 2, 3, 3, samples, db);
    }
    catch (ArrayIndexOutOfBoundsException 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

  }
 
  private Raster createRaster(TestHarness harness)
  {
    // Create initial raster
    WritableRaster rst = Raster.createWritableRaster(new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,
                                                                                      50, 40,
                                                                                      new int[]{0xff0000, 0xff00, 0xff}),
                                                     new Point(0, 0));

    // Fill with test data
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.