Package java.awt.image

Examples of java.awt.image.PixelInterleavedSampleModel


    BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);
    harness.check(img.getColorModel().equals(new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                                                     false, false,
                                                                     BufferedImage.OPAQUE,
                                                                     DataBuffer.TYPE_BYTE)));
    harness.check(img.getSampleModel().equals(new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE,
                                                                               10, 10,
                                                                               3, 10 * 3,
                                                                               new int[]{ 2, 1, 0 } )));
    harness.check(img.isAlphaPremultiplied(), img.getColorModel().isAlphaPremultiplied());
  }
View Full Code Here


    BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_4BYTE_ABGR);
    harness.check(img.getColorModel().equals(new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                                                     true, false,
                                                                     BufferedImage.TRANSLUCENT,
                                                                     DataBuffer.TYPE_BYTE)));
    harness.check(img.getSampleModel().equals(new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
                                                                              10, 10,
                                                                              4, 4*10,
                                                                              new int[]{3, 2, 1, 0})));
    harness.check(img.isAlphaPremultiplied(), img.getColorModel().isAlphaPremultiplied());
  }
View Full Code Here

    BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_4BYTE_ABGR_PRE);
    harness.check(img.getColorModel().equals(new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                                                     true, true,
                                                                     BufferedImage.TRANSLUCENT,
                                                                     DataBuffer.TYPE_BYTE)));
    harness.check(img.getSampleModel().equals(new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
                                                                              10, 10,
                                                                              4, 4*10,
                                                                              new int[]{3, 2, 1, 0})));
    harness.check(img.isAlphaPremultiplied(), img.getColorModel().isAlphaPremultiplied());
  }
View Full Code Here

  {
    BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_BYTE_GRAY);
    harness.check(img.getColorModel().equals(new ComponentColorModel( ColorSpace.getInstance( ColorSpace.CS_GRAY ),
                                                                      new int[]{8}, false, false,
                                                                      Transparency.OPAQUE, DataBuffer.TYPE_BYTE)));
    harness.check(img.getSampleModel().equals(new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE,
                                                                              10, 10,
                                                                              1, 10, new int[]{ 0 } )));
    harness.check(img.isAlphaPremultiplied(), img.getColorModel().isAlphaPremultiplied());
  }
View Full Code Here

  {
    BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_USHORT_GRAY);
    harness.check(img.getColorModel().equals(new ComponentColorModel( ColorSpace.getInstance( ColorSpace.CS_GRAY ),
                                                                      new int[]{16}, false, false,
                                                                      Transparency.OPAQUE, DataBuffer.TYPE_USHORT)));
    harness.check(img.getSampleModel().equals(new PixelInterleavedSampleModel( DataBuffer.TYPE_USHORT,
                                                                              10, 10,
                                                                              1, 10, new int[]{ 0 } )));
    harness.check(img.isAlphaPremultiplied(), img.getColorModel().isAlphaPremultiplied());
  }
View Full Code Here

    r[ index ] = g[ index ] = b[ index ] =
      (byte)(18 + (index - 216) * 6);
    index++;
      }
    harness.check(img.getColorModel().equals(new IndexColorModel( 8, 256, r, g, b )));
    harness.check(img.getSampleModel().equals(new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE,
                                                                              10, 10,
                                                                              1, 10, new int[]{ 0 } )));
    harness.check(img.isAlphaPremultiplied(), img.getColorModel().isAlphaPremultiplied());
  }
View Full Code Here

        int [] offsets = new int[b];
        for (int i=0; i < b; i++)
            offsets[i] = i;

        // Really should check DataType range in srcSM...
        return new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
                                               w, h, b, w*b, offsets);
    }
View Full Code Here

              new ComponentColorModel
                  (ColorSpace.getInstance(ColorSpace.CS_GRAY),
                   new int [] {8}, false, false,
                   Transparency.OPAQUE,
                   DataBuffer.TYPE_BYTE),
              new PixelInterleavedSampleModel
                  (DataBuffer.TYPE_BYTE,
                   src.getSampleModel().getWidth(),
                   src.getSampleModel().getHeight(),
                   1, src.getSampleModel().getWidth(),
                   new int [] { 0 }),
View Full Code Here

        // Note: Our source will always have either one or two bands
        // since we insert an Any2Lum transform before ourself in the
        // rendering chain.

        Raster srcRas = srcRed.getData(wr.getBounds());
        PixelInterleavedSampleModel srcSM;
        srcSM = (PixelInterleavedSampleModel)srcRas.getSampleModel();

        DataBufferByte srcDB = (DataBufferByte)srcRas.getDataBuffer();
        byte []        src   = srcDB.getData();
       
        PixelInterleavedSampleModel dstSM;
        dstSM = (PixelInterleavedSampleModel)wr.getSampleModel();

        DataBufferByte dstDB = (DataBufferByte)wr.getDataBuffer();
        byte []        dst   = dstDB.getData();

        int srcX0 = srcRas.getMinX()-srcRas.getSampleModelTranslateX();
        int srcY0 = srcRas.getMinY()-srcRas.getSampleModelTranslateY();

        int dstX0 = wr.getMinX()-wr.getSampleModelTranslateX();
        int dstX1 = dstX0+wr.getWidth()-1;
        int dstY0 = wr.getMinY()-wr.getSampleModelTranslateY();

        int    srcStep = srcSM.getPixelStride();
        int [] offsets = srcSM.getBandOffsets();
        int    srcLOff = offsets[0];
        int    srcAOff = offsets[1];

        if (srcRed.getColorModel().isAlphaPremultiplied()) {
            // Lum is already multiplied by alpha so we just copy lum channel.
            for (int y=0; y<srcRas.getHeight(); y++) {
                int srcI  = srcDB.getOffset() + srcSM.getOffset(srcX0,  srcY0);
                int dstI  = dstDB.getOffset() + dstSM.getOffset(dstX0,  dstY0);
                int dstE  = dstDB.getOffset() + dstSM.getOffset(dstX1+1,dstY0);

                srcI += srcLOff; // Go to Lum Channel (already mult by alpha).

                while (dstI < dstE) {
                    dst[dstI++] = src[srcI];
                        srcI += srcStep; // Go to next pixel
                }
                srcY0++;
                dstY0++;
            }
        }
        else {
            // This allows me to pre-adjust my index by srcLOff
            // Then only add the offset for srcAOff
            srcAOff = srcAOff-srcLOff;

            for (int y=0; y<srcRas.getHeight(); y++) {
                int srcI  = srcDB.getOffset() + srcSM.getOffset(srcX0,  srcY0);
                int dstI  = dstDB.getOffset() + dstSM.getOffset(dstX0,  dstY0);
                int dstE  = dstDB.getOffset() + dstSM.getOffset(dstX1+1,dstY0);

                srcI += srcLOff;

                while (dstI < dstE) {
                    int sl = (src[srcI])&0xFF; // LOff already included
View Full Code Here

    private static SampleModel createPixelInterleavedSampleModel
        (int dataType, int tileWidth, int tileHeight, int bands) {
        int [] bandOffsets = new int[bands];
        for (int i=0; i<bands; i++)
            bandOffsets[i] = i;
        return new PixelInterleavedSampleModel
            (dataType, tileWidth, tileHeight, bands,
             tileWidth*bands, bandOffsets);
    }
View Full Code Here

TOP

Related Classes of java.awt.image.PixelInterleavedSampleModel

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.