Java 8 SampleModel - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SampleModel class.

This code example shows how to use the following methods:getDataBitOffset, getPixelBitStride, getScanlineStride, getTransferType, getHeight
            out.writeObject(sm.getBitMasks());
        } else if(sampleModel instanceof MultiPixelPackedSampleModel) {
            MultiPixelPackedSampleModel sm =
                (MultiPixelPackedSampleModel)sampleModel;
            out.writeInt(TYPE_MULTI_PIXEL_PACKED);
            out.writeInt(sm.getTransferType());
            out.writeInt(sm.getWidth());
            out.writeInt(sm.getHeight());
            out.writeInt(sm.getPixelBitStride());
            out.writeInt(sm.getScanlineStride());
            out.writeInt(sm.getDataBitOffset());
        } else { 
            throw new RuntimeException(JaiI18N.getString("SampleModelProxy0"));
        } 
    } 
 
    /** 
      * Deserialize the <code>SampleModelProxy</code>. 
      * 
      * @param out The <code>ObjectInputStream</code>. 
7
CodeRank
This code example shows how to use the following methods:getHeight, getNumBands, getNumDataElements, getTransferType, getWidth
        if (!isEnabled()) { 
            return; 
        } 
 
        if (sm != null) {
            traceObjStart(label, sm, sb, indent);
            indent += INDENT_INCR;
 
            if (isFlagSet(traceMask, F_ATTRIBUTES)) {
                traceField("width", sm.getWidth(), sb, indent);
                traceField("height", sm.getHeight(), sb, indent);
                traceField("numBands", sm.getNumBands(), sb, indent);
                traceField("numDataElements", sm.getNumDataElements(), sb, indent);
                traceField("transferType", ImageUtils.getDataTypeName(sm.getTransferType()), sb, indent);
            } 
 
            indent -= INDENT_INCR;
            traceObjEnd(sb, indent);
        } else { 
            traceField(label, sm, sb, indent);

6
CodeRank
This code example shows how to use the following methods:createDataBuffer, getSamples, setSamples
    } 
    private static void doTest(Class<? extends SampleModel> c) {
        System.out.println("Test for: " + c.getName());
        SampleModel sm = createSampleModel(c);
 
        DataBuffer db = sm.createDataBuffer();
 
        int[] iArray = new int[ width * height + numBands];
        float[] fArray = new float[ width * height + numBands];
        double[] dArray = new double[ width * height + numBands];
 
        boolean iOk = false;
        boolean fOk = false;
        boolean dOk = false;
 
        try { 
            sm.getSamples(Integer.MAX_VALUE, 0, 1, 1, 0, iArray, db);
            sm.setSamples(Integer.MAX_VALUE, 0, 1, 1, 0, iArray, db);
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println(e.getMessage());

6
CodeRank
This code example shows how to use the following methods:getNumBands, getSampleSize, getTransferType
     * Checks if the specified {@code SampleModel} is compatible  
     * with this {@code ColorModel}. 
     */ 
    public boolean isCompatibleSampleModel(final SampleModel sm) {
        return (sm instanceof ComponentSampleModel)                  &&
                sm.getTransferType()                 == transferType &&
                sm.getNumBands()                     == numBands     &&
                (1 << sm.getSampleSize(visibleBand)) >= getMapSize();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getPixelStride, getScanlineStride, getDataType, getHeight, getWidth
This code example shows how to use the following methods:createCompatibleSampleModel, getHeight, getWidth
                return null; 
            } 
        } 
 
        SampleModel sm = img.getSampleModel();
        if (sm.getWidth() != region.width || sm.getHeight() != region.height) {
            sm = sm.createCompatibleSampleModel(region.width, region.height);
        } 
 
        WritableRaster raster = RasterFactory.createWritableRaster(sm, region.getLocation());
 
        // int startTileX = img.XToTileX(region.x); 
        // int startTileY = img.YToTileY(region.y); 
        // int endTileX = img.XToTileX(region.x + region.width - 1); 
        // int endTileY = img.YToTileY(region.y + region.height - 1); 
        // 
        // SampleModel[] sampleModels = { img.getSampleModel() }; 
        // int tagID = RasterAccessor.findCompatibleTag(sampleModels, raster.getSampleModel()); 
        // 
        // RasterFormatTag srcTag = new RasterFormatTag(img.getSampleModel(), tagID); 
6
CodeRank
This code example shows how to use the following methods:getDataType, getSampleSize
        EnumeratedParameter type =
            (EnumeratedParameter)paramBlock.getObjectParameter(0);
 
        SampleModel sm = source.getSampleModel();
        if ((sm instanceof MultiPixelPackedSampleModel) &&
            (sm.getSampleSize(0) == 1) &&
            (sm.getDataType() == DataBuffer.TYPE_BYTE || 
             sm.getDataType() == DataBuffer.TYPE_USHORT || 
             sm.getDataType() == DataBuffer.TYPE_INT)) {
            return new TransposeBinaryOpImage(source, renderHints, layout,
                                              type.getValue());
        } else { 
            return new TransposeOpImage(source, renderHints, layout,
                                        type.getValue());
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getDataBitOffset, getScanlineStride, getHeight
This code example shows how to use the following methods:getDataType, getSampleSize
 
        RenderedImage source = args.getRenderedSource(0);
 
        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; 
        } 
 
        EnumeratedParameter transposeType =
            (EnumeratedParameter)args.getObjectParameter(0);
        return new MlibTransposeOpImage(args.getRenderedSource(0),
                                        hints, layout,
                                        transposeType.getValue());
    } 
6
CodeRank
This code example shows how to use the following methods:getDataBitOffset, getScanlineStride, getHeight
See Code Examples for Java 8 SampleModel Methods: