Package java.awt.image

Examples of java.awt.image.ComponentSampleModel


  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});
    int[] pixels = m.getPixels(1, 0, 2, 1, (int[]) null, db);
    harness.check(pixels.length, 4);
    harness.check(pixels[0], 2);
    harness.check(pixels[1], 3);
    harness.check(pixels[2], 4);
    harness.check(pixels[3], 5);
   
    // try passing in a result array
    int[] result = new int[4];
    pixels = m.getPixels(1, 1, 2, 1, result, db);
    harness.check(pixels[0], 8);
    harness.check(pixels[1], 9);
    harness.check(pixels[2], 10);
    harness.check(pixels[3], 11);
    harness.check(pixels == result);
   
    // try null data buffer
    boolean pass = false;
    try
      {
        m.getPixels(1, 1, 2, 1, result, null);
      }
    catch (NullPointerException e)
      {
        pass = true
      }
View Full Code Here


public class createSubsetSampleModel implements Testlet
{
  public void test(TestHarness harness)
  {
    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
            11, 2, 44, new int[] {0, 1});
    SampleModel m2 = m1.createSubsetSampleModel(new int[] {1});
    harness.check(m2 instanceof ComponentSampleModel);
    harness.check(m2.getDataType(), DataBuffer.TYPE_INT);
    harness.check(m2.getWidth(), 22);
    harness.check(m2.getHeight(), 11);
    harness.check(m2.getNumBands(), 1);
View Full Code Here

public class hashCode implements Testlet
{
  public void test(TestHarness harness)
  {
    // equal instances should have equal hashCodes...
    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT,
            10, 20, 3, 3, new int[] {0, 1, 2});
    ComponentSampleModel m2 = new ComponentSampleModel(DataBuffer.TYPE_INT,
            10, 20, 3, 3, new int[] {0, 1, 2});
    harness.check(m1.equals(m2));
    harness.check(m1.hashCode(), m2.hashCode());
  }
View Full Code Here

  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});
    int[] samples = m.getSamples(0, 1, 2, 1, 0, (int[]) null, db);
    harness.check(samples.length, 2);
    harness.check(samples[0], 6);
    harness.check(samples[1], 8);
   
    // try passing in a result array
    int[] result = new int[2];
    samples = m.getSamples(0, 1, 2, 1, 1, result, db);
    harness.check(samples.length, 2);
    harness.check(samples[0], 7);
    harness.check(samples[1], 9);
    harness.check(samples == result);
   
    // try null data buffer
    boolean pass = false;
    try
      {
        m.getSamples(0, 1, 2, 1, 1, result, null);
      }
    catch (NullPointerException e)
      {
        pass = true
      }
View Full Code Here

public class getBandOffsets implements Testlet
{
  public void test(TestHarness harness)
  {
    int[] bo = new int[] {1, 2};
    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
            33, 1, 23, bo);
    int[] bo1 = m1.getBandOffsets();
    harness.check(Arrays.equals(bo1, new int[] {1, 2}));
    int[] bo2 = m1.getBandOffsets();
    harness.check(bo1 != bo2);
    bo[1] = 3;
    harness.check(m1.getBandOffsets()[1], 2);
  }
View Full Code Here

        if(masks[0] != 0x00ff0000) return false;
        if(masks[1] != 0x0000ff00) return false;
        if(masks[2] != 0x000000ff) return false;
        if(masks[3] != 0xff000000) return false;
        ComponentSampleModel csm;
        csm = (ComponentSampleModel)alpSM;
        if (csm.getNumBands()    != 1) return false;
        if (csm.getPixelStride() != 1) return false;

        return true;
   }
View Full Code Here

        Rectangle rgn = wr.getBounds();
        rgn = rgn.intersection(alphaRed.getBounds());
           
        Raster r = alphaRed.getData(rgn);

        ComponentSampleModel csm;
        csm = (ComponentSampleModel)r.getSampleModel();
        final int alpScanStride = csm.getScanlineStride();

        DataBufferByte alpDB   = (DataBufferByte)r.getDataBuffer();
        final int      alpBase
            = (alpDB.getOffset() +
               csm.getOffset(rgn.x-r.getSampleModelTranslateX(),
                             rgn.y-r.getSampleModelTranslateY()));

           
          // Access the pixel data array
        final byte alpPixels[] = alpDB.getBankData()[0];
View Full Code Here

        boolean preMult  = srcCM.isAlphaPremultiplied();
        if (!hasAlpha)
            preMult = false;

        if (sm instanceof ComponentSampleModel) {
            ComponentSampleModel csm = (ComponentSampleModel)sm;

            int [] bitsPer = new int[bands];
            for (int i=0; i<bands; i++)
                bitsPer[i] = bits;
View Full Code Here


    protected static void divide_BYTE_COMP_Data(WritableRaster wr) {
        // System.out.println("Multiply Int: " + wr);

        ComponentSampleModel csm;
        csm = (ComponentSampleModel)wr.getSampleModel();

        final int width = wr.getWidth();

        final int scanStride = csm.getScanlineStride();
        final int pixStride  = csm.getPixelStride();
        final int [] bandOff = csm.getBandOffsets();

        DataBufferByte db = (DataBufferByte)wr.getDataBuffer();
        final int base
            = (db.getOffset() +
               csm.getOffset(wr.getMinX()-wr.getSampleModelTranslateX(),
                             wr.getMinY()-wr.getSampleModelTranslateY()));


        int a=0;
        int aOff = bandOff[bandOff.length-1];
View Full Code Here

    }

    protected static void mult_BYTE_COMP_Data(WritableRaster wr) {
        // System.out.println("Multiply Int: " + wr);

        ComponentSampleModel csm;
        csm = (ComponentSampleModel)wr.getSampleModel();

        final int width = wr.getWidth();

        final int scanStride = csm.getScanlineStride();
        final int pixStride  = csm.getPixelStride();
        final int [] bandOff = csm.getBandOffsets();

        DataBufferByte db = (DataBufferByte)wr.getDataBuffer();
        final int base
            = (db.getOffset() +
               csm.getOffset(wr.getMinX()-wr.getSampleModelTranslateX(),
                             wr.getMinY()-wr.getSampleModelTranslateY()));


        int a=0;
        int aOff = bandOff[bandOff.length-1];
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.