Package it.geosolutions.imageio.plugins.png

Examples of it.geosolutions.imageio.plugins.png.PNGWriter


                .produceLegendGraphic(legendGraphicRequest);
        if (legendGraphic instanceof BufferedImageLegendGraphic) {
            BufferedImage image = ((BufferedImageLegendGraphic) legendGraphic)
                    .getLegend();

            PNGWriter writer = new PNGWriter();
            FileOutputStream outStream = null;
            try {
                File sampleFile = new File(sampleLegendFolder.getAbsolutePath() + File.separator +
                        getSampleFileName(style));
                if(!sampleFile.getParentFile().exists()) {
                    sampleFile.getParentFile().mkdirs();
                }
                outStream = new FileOutputStream(sampleFile);
                writer.writePNG(image, outStream, 0.0f, FilterType.FILTER_NONE);
                removeStyleSampleInvalidation(style);
                return new Dimension(image.getWidth(), image.getHeight());
            } finally {
                if(outStream != null) {
                    outStream.close();
View Full Code Here


    public RenderedImage writePNG(RenderedImage image, OutputStream outStream, float quality,
            WMSMapContent mapContent) {
        // what kind of scaline filtering are we going to use?
        FilterType filterType = getFilterType(mapContent);
        // Creation of a new PNGWriter object
        PNGWriter writer = new PNGWriter();
        // Check if a Scanline is supported by the writer
        boolean isScanlineSupported = writer.isScanlineSupported(image);
        // If it is not supported, then the image is rescaled to bytes
        if(!isScanlineSupported){
            image = new ImageWorker(image).rescaleToBytes().forceComponentColorModel().getRenderedImage();          
        }
       
        RenderedImage output = null;
        // Image writing
        try {
            output =  writer.writePNG(image, outStream, quality, filterType);
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, "Failed to encode the PNG", e);
            throw new ServiceException(e);
        }
       
View Full Code Here

        // If the new PNGWriter must be disabled then the other writers are used
        if (disablePNG) {
            super.encode(image, destination, aggressiveOutputStreamOptimization, type, map);
        } else {
            // Creation of the associated Writer
            PNGWriter writer = new PNGWriter();
            OutputStream stream = null;
            try {
                // writer = new PNGJWriter();
                // Check if the input object is an OutputStream
                if (destination instanceof OutputStream) {
                    boolean isScanlinePresent = writer.isScanlineSupported(image);
                    if (!isScanlinePresent) {
                        image = new ImageWorker(image).rescaleToBytes().forceComponentColorModel()
                                .getRenderedImage();
                    }
                    Object filterObj = null;
                    if (map != null) {
                        filterObj = map.get(FILTER_TYPE);
                    }
                    FilterType filter = null;
                    if (filterObj == null || !(filterObj instanceof FilterType)) {
                        filter = FilterType.FILTER_NONE;
                    } else {
                        filter = (FilterType) filterObj;
                    }
                    stream = (OutputStream) destination;
                   
                    //Image preparation if an image helper is present
                    WriteHelper helper = getHelper();
                    RenderedImage finalImage = image;
                    if(helper!=null){
                        finalImage = helper.prepareImage(image, type);
                    }                  
                    // Image writing
                    writer.writePNG(finalImage, stream, quality, filter);
                } else {
                    throw new IllegalArgumentException(
                            "Only an OutputStream can be provided to the PNGEncoder");
                }
            } catch (Exception e) {
View Full Code Here

TOP

Related Classes of it.geosolutions.imageio.plugins.png.PNGWriter

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.