Java 8 ImageTypeSpecifier - 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 ImageTypeSpecifier class.

This code example shows how to use the following methods:getColorModel, getSampleModel
This code example shows how to use the following methods:
        csm = rasterHandler.getSampleModel();
        ccmdl = PlanarImage.createColorModel(csm);
        final List<ImageTypeSpecifier> l = new ArrayList<ImageTypeSpecifier>();
 
        if (imageType == null) {
            imageType = new ImageTypeSpecifier(ccmdl, csm);
            l.add(imageType);
        } 
        return l.iterator();
    } 
 
    public IIOMetadata getStreamMetadata() throws IOException {
        // grass raster data do not support stream metadata. 
        return null; 
    } 
 
    public IIOMetadata getImageMetadata( final int imageIndex ) throws IOException {
        ensureOpen(); 
        if (metadata == null)
            metadata = new GrassBinaryImageMetadata(this.rasterHandler);
5
CodeRank
This code example shows how to use the following methods:getColorModel, getSampleModel
 
    @Override 
    public boolean canEncodeImage(ImageTypeSpecifier type) {
        boolean canEncode = true;
 
        int numBands = type.getSampleModel().getNumBands();
 
        ColorModel colorModel = type.getColorModel();
 
        int bitDepth = colorModel.getPixelSize() / numBands;
 
        if (colorModel instanceof IndexColorModel) {
            if (bitDepth != 1 && bitDepth != 2 && bitDepth != 4 && bitDepth != 8) {
                canEncode = false;
            } 
            if (numBands != 1) {
                canEncode = false;
            } 
        } 
        else if (numBands == 1) {
5
CodeRank
This code example shows how to use the following methods:
    public static void main(String[] args) throws Exception {
        String format = "javax_imageio_1.0";
        BufferedImage img =
            new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
        ImageWriter iw = ImageIO.getImageWritersByMIMEType("image/png").next();
        IIOMetadata meta =
            iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), null);
        DOMImplementationRegistry registry;
        registry = DOMImplementationRegistry.newInstance();
        DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
        Document doc = impl.createDocument(null, format, null);
        Element root, text, entry;
        root = doc.getDocumentElement();
        root.appendChild(text = doc.createElement("Text"));
        text.appendChild(entry = doc.createElement("TextEntry"));
        // keyword isn't #REQUIRED by the standard metadata format. 
        // However, it is required by the PNG format, so we include it here. 
        entry.setAttribute("keyword", "Comment");
        entry.setAttribute("value", "Some demo comment");
        meta.mergeTree(format, root);
5
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:getBufferedImageType, getColorModel
 
 
    private boolean canEncodeImage(String compression,
                                   ImageTypeSpecifier imgType, int rawType)
    { 
        int biType = imgType.getBufferedImageType();
        if ((!compression.equals("BI_BITFIELDS")) &&
            ((rawType == BufferedImage.TYPE_USHORT_565_RGB) ||
             (rawType == TYPE_USHORT_565_BGR)))
        { 
            return false; 
        } 
 
        int bpp = imgType.getColorModel().getPixelSize();
        if (compression.equals("BI_RLE4") && bpp != 4) {
            // only 4bpp images can be encoded as BI_RLE4 
            return false; 
        } 
        if (compression.equals("BI_RLE8") && bpp != 8) {
            // only 8bpp images can be encoded as BI_RLE8 
5
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:createBufferedImage, getSampleModel
This code example shows how to use the following methods:getColorModel, getSampleModel
 
        Utilities.ensureNonNull("reader", reader);
        // save ImageLayout 
        ImageLayout2 layout = new ImageLayout2();
        ImageTypeSpecifier its = reader.getImageTypes(0).next();
        layout.setColorModel(its.getColorModel()).setSampleModel(its.getSampleModel());
        layout.setMinX(0).setMinY(0).setWidth(reader.getWidth(0)).setHeight(reader.getHeight(0));
        layout.setTileGridXOffset(0).setTileGridYOffset(0).setTileWidth(reader.getTileWidth(0))
                .setTileHeight(reader.getTileHeight(0));
        setlayout(layout);
    } 
 
    /** 
     * Set the provided layout for this {@link GridCoverage2DReader}- 
     *  
     * @param layout the {@link ImageLayout} to set. It must be nont null 
     */ 
    protected void setlayout(ImageLayout layout) {
        Utilities.ensureNonNull("layout", layout);
        this.imageLayout = (ImageLayout) layout.clone();
4
CodeRank
This code example shows how to use the following methods:
 
    @Override 
    public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException {
        readHeader(); 
        LinkedList<ImageTypeSpecifier> l = new LinkedList<ImageTypeSpecifier>();
        l.add(new ImageTypeSpecifier(RGB, RGB.createCompatibleSampleModel(image.getWidth(), image.getHeight())));
        return l.iterator();
    } 
 
    @Override 
    public IIOMetadata getStreamMetadata() throws IOException {
        return null; 
    } 
 
    @Override 
    public IIOMetadata getImageMetadata(int imageIndex) throws IOException {
        return null; 
    } 
 
    @Override 
3
CodeRank
See Code Examples for Java 8 ImageTypeSpecifier Methods: