Package com.volantis.map.ics.imageprocessor.convertor

Examples of com.volantis.map.ics.imageprocessor.convertor.ImageConvertor


        ObjectParameters params = createParams();
        URL input =
            WatermarkingToolTestCase.class.getResource(
                "images/circusshow4256.bmp");
        RenderedOp sourceImage = JAI.create("url", input);
        ImageConvertor cnv =
            ImageConvertorFactory.getInstance().
            getImageConvertor(ImageRule.TRUECOLOUR);
        sourceImage = cnv.convert(sourceImage, params);
        RenderedOp[] watermarkedImage =
            tool.process(new RenderedOp[]{sourceImage}, params);

        assertNotNull("The RenderedOp shouldn't be null", watermarkedImage);
View Full Code Here


                Iterator it = composite.iterator();
                int i=0;
                while (it.hasNext()) {

                    RenderedOp comp = (RenderedOp) it.next();
                    ImageConvertor cnv = getImageConverter(comp, params);
                    RenderedOp conv = cnv.convert(comp, params);

                    Object obj = conv.getProperty("JAI.ImageMetadata");

                    if (obj instanceof GIFImageMetadata) {
                        // this is a hacky mess but the writer does not obay
View Full Code Here

    }

    // javadoc inherited
    public ImageConvertor getImageConvertor(int type) {
        Integer key = type;
        ImageConvertor cvt = (ImageConvertor) convertorMap.get(key);
        if (cvt == null) {
            switch (type) {
                case ImageRule.MONOCHROME:
                    cvt = new GreyscaleNConvertor(1);
                    break;
View Full Code Here

        try {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Writing true colour image");
            }
            ImageConvertor cvt =
                ImageConvertorFactory.getInstance().getImageConvertor(
                    ImageRule.TRUECOLOUR);
            if (!params.containsName(ParameterNames.MAX_IMAGE_SIZE)) {
                outputFrame(os, cvt.convert(ops[0], null), getFileFormat(), params);
            } else {

                RenderedOp[] rgb = new RenderedOp[1];
                rgb[0] = cvt.convert(ops[0], null);
                outputFrame(os, rgb[0], getFileFormat(), params);

                int maxImageSize = params.getInteger(ParameterNames.MAX_IMAGE_SIZE);
                long length = os.getSize();
                if (LOGGER.isDebugEnabled()) {
View Full Code Here

        try {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Writing true colour image");
            }
            ImageConvertor cvt =
                ImageConvertorFactory.getInstance().getImageConvertor(
                    ImageRule.TRUECOLOUR);
            RenderedOp converted = cvt.convert(ops[0], null);
            return super.outputImage(new RenderedOp[]{converted}, params, os);
        } catch (Exception e) {
            LOGGER.error("image-encoding-error", e.toString());
            throw new ImageWriterException(e);
        }
View Full Code Here

     */
    protected RenderedOp[] getConvertedImage(RenderedOp[] image,
                                             Parameters params)
        throws ImageWriterException {
        try {
            ImageConvertor converter;
            RenderedOp[] convertedImage = new RenderedOp[image.length];
            for (int frameCount = 0; frameCount < image.length; frameCount++) {
                converter = getImageConverter(image[frameCount], params);
                RenderedOp tmp = converter.convert(image[frameCount], params);
                convertedImage[frameCount] = conditionImage(tmp, params);            
            }
            return convertedImage;
        } catch (Exception e) {
            throw new ImageWriterException(e);
View Full Code Here

                                                    "os");
            throw new IllegalArgumentException(msg);
        }

        try {
            ImageConvertor cvt =
                ImageConvertorFactory.getInstance().getImageConvertor(
                    ImageRule.TRUECOLOUR);
            RenderedOp converted = cvt.convert(ops[0], params);
            try {
                // We remove alpha channel since bmp image does not keep
                // transparency.
                converted = ImageUtils.applyAlphaChannel(converted, 0);
View Full Code Here

            /*
             * Degrade the image by reducing the image quality until it either
             * fits in the required memory or it has reached the minimum
             * quality allowed.
             */
            ImageConvertor cvt =
                ImageConvertorFactory.getInstance().getImageConvertor(
                    ImageRule.TRUECOLOUR);

            /**
             * This converts the color model to linear RGB. This causes the
             * JPEG writer to NOT write out a ICC color profile as Linear RGB
             * is recognized as a standard. This is not necessary on JDK 1.6
             * and later. VBM.2008011813. Not writing the ICC color profile
             * saves about 3.5Kb in file size allowing us to produce larger
             * images for a given maxfilesize
             */
            if (src.getColorModel().getNumColorComponents() > 1) {
                SampleModel sm = src.getColorModel().
                    createCompatibleSampleModel(src.getWidth(), src.getHeight());
                ColorSpace sc = ColorSpaceJAI.getInstance(ColorSpaceJAI.CS_sRGB);
                ColorModel cm = new ComponentColorModel(sc, sm.getSampleSize(),
                    src.getColorModel().hasAlpha(),
                    src.getColorModel().isAlphaPremultiplied(),
                    src.getColorModel().getTransparency(),
                    src.getColorModel().getTransferType());
                src = ColorConvertDescriptor.create(src, cm, null);               
            }

            // ensure the minimum quality is never more then the default as
            // otherwise we won't terminate
            float minQuality =
                (float) (params.
                    getInteger(ParameterNames.MINIMUM_JPEG_QUALITY));
            if (minQuality >= DEFAULT_QUALITY * 100f) {
                LOGGER.warn("invalid-parameter-value", new Object[] {
                    ParameterNames.MINIMUM_JPEG_QUALITY,
                        Math.round(DEFAULT_QUALITY * 100f)});
                params.setObject(ParameterNames.MINIMUM_JPEG_QUALITY,
                        Math.round(DEFAULT_QUALITY * 100f));
            }

            RenderedOp resizedSrc = src;
            while (!degradeImage(os, resizedSrc, params, quality)) {
                /*
                 * Degradation did not get the image small enough so scale it
                 * and try again.
                 */
                quality = params.getInteger(ParameterNames.MINIMUM_JPEG_QUALITY) / 100F;
                Dimension d = new Dimension(src.getWidth(), src.getHeight());
                int maxImageSize = params.getInteger(ParameterNames.MAX_IMAGE_SIZE);
                Dimension newD = cvt.calcScale(d, lastLength, maxImageSize);
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Scaling image to width " + newD.width);
                }
                RenderedOp[] img = new RenderedOp[1];
                img[0] = src;
View Full Code Here

                iis = (ImageInputStream) params.getObject(
                    ParameterNames.WATERMARK_INPUT_STREAM);
            }
            watermark = ImageReader.loadImage(iis)[0];

            ImageConvertor cnv =
                ImageConvertorFactory.getInstance().
                getImageConvertor(ImageRule.TRUECOLOUR);
            watermark = cnv.convert(watermark, params);
            params.setObject(ParameterNames.WATERMARK_IMAGE, watermark);
        } catch (Exception e) {
            throw new ToolException(
                EXCEPTION_LOCALIZER.format("loading-watermark-failure"));
        }
View Full Code Here

TOP

Related Classes of com.volantis.map.ics.imageprocessor.convertor.ImageConvertor

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.