Package java.awt.image

Examples of java.awt.image.BandedSampleModel


   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    BandedSampleModel m1 = new BandedSampleModel(DataBuffer.TYPE_SHORT, 10, 20,
      10, new int[] {2, 1, 0}, new int[] {4, 5, 6});
    BandedSampleModel m2 = (BandedSampleModel) m1.createSubsetSampleModel(new int[] {0, 1});
    harness.check(m2.getDataType(), DataBuffer.TYPE_SHORT);
    harness.check(m2.getWidth(), 10);
    harness.check(m2.getHeight(), 20);
    harness.check(m2.getNumBands(), 2);
    harness.check(m2.getBandOffsets()[0], 4);
    harness.check(m2.getBandOffsets()[1], 5);  
   
    // try more bands than available
    boolean pass = false;
    try
    {
View Full Code Here


   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    // simply check that two identical models have the same hash code
    BandedSampleModel m1 = new BandedSampleModel(DataBuffer.TYPE_INT, 2, 3, 2);
    BandedSampleModel m2 = new BandedSampleModel(DataBuffer.TYPE_INT, 2, 3, 2);
    harness.check(m1.hashCode(), m2.hashCode());
  }
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)       
  {
    BandedSampleModel m = new BandedSampleModel(DataBuffer.TYPE_INT, 2, 3, 2);
    DataBufferInt b = new DataBufferInt(6, 2);
    b.setElem(0, 0, 0xA0);
    b.setElem(0, 1, 0xA1);
    b.setElem(0, 2, 0xA2);
    b.setElem(0, 3, 0xA3);
    b.setElem(0, 4, 0xA4);
    b.setElem(0, 5, 0xA5);
    b.setElem(1, 0, 0xB0);
    b.setElem(1, 1, 0xB1);
    b.setElem(1, 2, 0xB2);
    b.setElem(1, 3, 0xB3);
    b.setElem(1, 4, 0xB4);
    b.setElem(1, 5, 0xB5);
   
    int[] samples = m.getSamples(1, 1, 1, 2, 0, (int[]) null, b);
    harness.check(samples[0], 0xA3);
    harness.check(samples[1], 0xA5);
   
    samples = m.getSamples(1, 1, 1, 2, 1, (int[]) null, b);
    harness.check(samples[0], 0xB3);
    harness.check(samples[1], 0xB5);
   
    // check negative x
    boolean pass = false;
    try
    {
      m.getSamples(-1, 1, 1, 2, 1, (int[]) null, b);  
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // check negative y
    pass = false;
    try
    {
      m.getSamples(1, -1, 1, 2, 1, (int[]) null, b);  
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // check negative w
    pass = false;
    try
    {
      m.getSamples(1, 1, -1, 2, 1, (int[]) null, b);  
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // check negative h
    pass = false;
    try
    {
      m.getSamples(1, 1, 1, -1, 1, (int[]) null, b);  
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // check null data buffer
    pass = false;
    try
    {
      m.getSamples(1, 1, 1, 1, 1, (int[]) null, null);  
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
View Full Code Here

        // in-memory format of the image to a type that we know the
        // operator likes. This is not fool proof. It converts all images
        // into non-indexed representations that have a byte pixel width
        ImageLayout layout = new ImageLayout();
        layout.setSampleModel(
            new BandedSampleModel(DataBuffer.TYPE_BYTE,
                                  src.getWidth(),
                                  src.getHeight(),
                                  src.getColorModel().getNumColorComponents()));
        // set up the rendering hints object that is passed to the format
        // operation to effect this change.
View Full Code Here

                                                     hasAlpha,
                                                     isAlphaPremultiplied);

            int w = 1;
            int h = 1;
            this.sampleModel = new BandedSampleModel(dataType,
                                                     w, h,
                                                     w,
                                                     bankIndices,
                                                     bandOffsets);
        }
View Full Code Here

                                                     hasAlpha,
                                                     isAlphaPremultiplied);

            int w = 1;
            int h = 1;
            this.sampleModel = new BandedSampleModel(dataType,
                                                     w, h,
                                                     w,
                                                     bankIndices,
                                                     bandOffsets);
        }
View Full Code Here

                                          int tileWidth,
                                          int tileHeight,
                                          int[] bankIndices,
                                          int[] bandOffsets) {
        SampleModel sm =
            new BandedSampleModel(dataType,
                                  tileWidth, tileHeight,
                                  tileWidth,
                                  bankIndices,
                                  bandOffsets);
        return new TiledImage(minX, minY, width, height,
View Full Code Here

                "ushort DataBuffers");
        }
        DataBufferUShort dbus = (DataBufferUShort)dataBuffer;

        if (sampleModel instanceof BandedSampleModel) {
            BandedSampleModel bsm = (BandedSampleModel)sampleModel;
            this.scanlineStride = bsm.getScanlineStride();
            int bankIndices[] = bsm.getBankIndices();
            int bandOffsets[] = bsm.getBandOffsets();
            int dOffsets[] = dbus.getOffsets();
            dataOffsets = new int[bankIndices.length];
            data = new short[bankIndices.length][];
            int xOffset = aRegion.x - origin.x;
            int yOffset = aRegion.y - origin.y;
View Full Code Here

                "byte DataBuffers");
        }
        DataBufferByte dbb = (DataBufferByte)dataBuffer;

        if (sampleModel instanceof BandedSampleModel) {
            BandedSampleModel bsm = (BandedSampleModel)sampleModel;
            this.scanlineStride = bsm.getScanlineStride();
            int bankIndices[] = bsm.getBankIndices();
            int bandOffsets[] = bsm.getBandOffsets();
            int dOffsets[] = dbb.getOffsets();
            dataOffsets = new int[bankIndices.length];
            data = new byte[bankIndices.length][];
            int xOffset = aRegion.x - origin.x;
            int yOffset = aRegion.y - origin.y;
View Full Code Here

                                                     hasAlpha,
                                                     isAlphaPremultiplied);

            int w = 1;
            int h = 1;
            this.sampleModel = new BandedSampleModel(dataType,
                                                     w, h,
                                                     w,
                                                     bankIndices,
                                                     bandOffsets);
        }
View Full Code Here

TOP

Related Classes of java.awt.image.BandedSampleModel

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.