Package java.awt.image

Examples of java.awt.image.SampleModel


        int tileHeight = bounds.height;

        // Retrieve layout information from the hints. The tile size hints
        // are ignored if a SampleModel hint is supplied. Set the hints
        // observed if any hints are used.
        SampleModel sm = null;
        ColorModel cm = null;
        RenderingHints hintsObserved = null;
        if(hints != null) {
            // Get the ImageLayout.
            ImageLayout layout = (ImageLayout)hints.get(JAI.KEY_IMAGE_LAYOUT);

            if(layout != null) {
                // Initialize the observed hint variables.
                hintsObserved = new RenderingHints(null);
                ImageLayout layoutObserved = new ImageLayout();

                // Get the SampleModel.
                if(layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
                    sm = layout.getSampleModel(null);
                    if(sm.getWidth() != tileWidth ||
                       sm.getHeight() != tileHeight) {
                        sm = sm.createCompatibleSampleModel(tileWidth,
                                                            tileHeight);
                    }
                    if(layoutObserved != null) {
                        layoutObserved.setSampleModel(sm);
                    }
                }

                // Get the ColorModel.
                if(layout.isValid(ImageLayout.COLOR_MODEL_MASK)) {
                    cm = layout.getColorModel(null);
                    if(layoutObserved != null) {
                        layoutObserved.setColorModel(cm);
                    }
                }

                // Get the tile dimensions.
                if(layout.isValid(ImageLayout.TILE_WIDTH_MASK)) {
                    tileWidth = layout.getTileWidth(null);
                    if(layoutObserved != null) {
                        layoutObserved.setTileWidth(tileWidth);
                    }
                } else if(sm != null) {
                    tileWidth = sm.getWidth();
                }
                if(layout.isValid(ImageLayout.TILE_HEIGHT_MASK)) {
                    tileHeight = layout.getTileHeight(null);
                    if(layoutObserved != null) {
                        layoutObserved.setTileHeight(tileHeight);
                    }
                } else if(sm != null) {
                    tileHeight = sm.getHeight();
                }

                // Set the observed hints layout.
                hintsObserved.put(JAI.KEY_IMAGE_LAYOUT, layoutObserved);
            } // layout != null
        } // hints != null

        // Ensure that the SampleModel is compatible with the tile size.
        if(sm != null &&
           (sm.getWidth() != tileWidth || sm.getHeight() != tileHeight)) {
            sm = sm.createCompatibleSampleModel(tileWidth, tileHeight);
        }

        // Attempt to derive compatible SampleModel/ColorModel combination.
        if(cm != null && (sm == null ||
                          !JDKWorkarounds.areCompatibleDataModels(sm, cm))) {
View Full Code Here


      source.getTileWidth() >= 32768 ||
      source.getTileHeight() >= 32768) {
            return null;
        }

        SampleModel sm = source.getSampleModel();
        boolean isBilevel = (sm instanceof MultiPixelPackedSampleModel) &&
            (sm.getSampleSize(0) == 1) &&
            (sm.getDataType() == DataBuffer.TYPE_BYTE ||
             sm.getDataType() == DataBuffer.TYPE_USHORT ||
             sm.getDataType() == DataBuffer.TYPE_INT);
        if (isBilevel) {
            // Let Java code handle it, reformatting is slower
            return null;
        }
View Full Code Here

    /** The Y translation. */
    protected float yTrans;

    private static SampleModel sampleModelHelper(int numBands,
                                                 ImageLayout layout) {
        SampleModel sampleModel;
        if (layout!= null && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
            sampleModel = layout.getSampleModel(null);

            if (sampleModel.getNumBands() != numBands) {
                throw new RuntimeException(JaiI18N.getString("ImageFunctionRIF0"));
            }
        } else { // Create a SampleModel.
            // Use a dummy width and height, OpImage will fix them
            sampleModel = RasterFactory.createBandedSampleModel(
View Full Code Here

                                            int[] bandIndices) {
        ImageLayout il = layout == null ?
            new ImageLayout() : (ImageLayout)layout.clone();

        // Create a sub-banded SampleModel.
        SampleModel sourceSM = source.getSampleModel();
        int numBands = bandIndices.length;

        // The only ColorModel compatible with a SinglePixelPackedSampleModel
        // in the J2SE is a DirectColorModel which is by definition of
        // ColorSpace.TYPE_RGB. Therefore if there are fewer than 3 bands
        // a data copy is obligatory if a ColorModel will be possible.
        SampleModel sm = null;
        if(sourceSM instanceof SinglePixelPackedSampleModel && numBands < 3) {
            sm = new PixelInterleavedSampleModel(
                     DataBuffer.TYPE_BYTE,
                     sourceSM.getWidth(), sourceSM.getHeight(),
                     numBands, sourceSM.getWidth()*numBands,
 
View Full Code Here

        boolean premultiplied =
            ((Boolean)args.getObjectParameter(2)).booleanValue();
        EnumeratedParameter destAlpha =
            (EnumeratedParameter)args.getObjectParameter(3);

        SampleModel sm = alpha1.getSampleModel();

        if (!(sm instanceof ComponentSampleModel) ||
            sm.getNumBands() != 1 ||
            !(alpha1.getColorModel() instanceof ComponentColorModel) ||
            alpha2 != null ||
            premultiplied ||
            !(destAlpha.equals(CompositeDescriptor.NO_DESTINATION_ALPHA))) {
            return null;
View Full Code Here

        sampleModelState = (SerializableState)in.readObject();
        dataBufferState = (SerializableState)in.readObject();
        location = (Point)in.readObject();

        // Restore the SampleModel from its serialized form.
        SampleModel sampleModel = (SampleModel)sampleModelState.getObject();
        if (sampleModel == null) {
            theObject = null;
            return;
        }
View Full Code Here

        if(colorModel == null) {
            // Try to guess an appropriate ColorModel.
            if(colorModel == null) {
                // First try to deduce one from the TiledImage SampleModel.
                SampleModel sm = ti.getSampleModel();
                colorModel = PlanarImage.createColorModel(sm);
                if(colorModel == null) {
                    // ColorModel still null: try RGB default model.
                    ColorModel cm = ColorModel.getRGBdefault();
                    if(JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
View Full Code Here

      * Serialize the <code>SampleModelState</code>.
      *
      * @param out The <code>ObjectOutputStream</code>.
      */
    private void writeObject(ObjectOutputStream out) throws IOException {
        SampleModel sampleModel = (SampleModel)theObject;
        if(sampleModel instanceof ComponentSampleModel) {
            ComponentSampleModel sm = (ComponentSampleModel)sampleModel;
            int sampleModelType = TYPE_COMPONENT;
            int transferType = sm.getTransferType();
            if(sampleModel instanceof PixelInterleavedSampleModel) {
View Full Code Here

      *
      * @param out The <code>ObjectInputStream</code>.
      */
    private void readObject(ObjectInputStream in)
        throws IOException, ClassNotFoundException {
        SampleModel sampleModel = null;
        int sampleModelType = (int)in.readInt();
        switch(sampleModelType) {
        case TYPE_PIXEL_INTERLEAVED:
            sampleModel =
                RasterFactory.createPixelInterleavedSampleModel(in.readInt(),
View Full Code Here

        sampleModelState = (SerializableState)in.readObject();
        dataBufferState = (SerializableState)in.readObject();
        location = (Point)in.readObject();

        // Restore the SampleModel from its serialized form.
        SampleModel sampleModel = (SampleModel)sampleModelState.getObject();
        if(sampleModel == null) {
            raster = null;
            return;
        }
View Full Code Here

TOP

Related Classes of java.awt.image.SampleModel

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.