Package org.apache.xmlgraphics.image.loader.impl

Examples of org.apache.xmlgraphics.image.loader.impl.ImageRendered


    /** {@inheritDoc} */
    public void handleImage(RenderingContext context, Image image, Rectangle pos)
                throws IOException {
        PDFRenderingContext pdfContext = (PDFRenderingContext)context;
        PDFContentGenerator generator = pdfContext.getGenerator();
        ImageRendered imageRend = (ImageRendered)image;

        PDFImage pdfimage = new ImageRenderedAdapter(imageRend, image.getInfo().getOriginalURI());
        PDFXObject xobj = generator.getDocument().addImage(
                generator.getResourceContext(), pdfimage);

View Full Code Here


    /** {@inheritDoc} */
    public void handleImage(RenderingContext context, Image image, Rectangle pos)
            throws IOException {
        PCLRenderingContext pclContext = (PCLRenderingContext)context;
        ImageRendered imageRend = (ImageRendered)image;
        PCLGenerator gen = pclContext.getPCLGenerator();

        RenderedImage ri = imageRend.getRenderedImage();
        Point2D transPoint = pclContext.transformedPoint(pos.x, pos.y);
        gen.setCursorPos(transPoint.getX(), transPoint.getY());
        gen.paintBitmap(ri, new Dimension(pos.width, pos.height),
                pclContext.isSourceTransparencyEnabled());
    }
View Full Code Here

        img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE,
                    userAgent.getImageSessionContext());
        assertNotNull("Image must not be null", img);
        assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
        ImageRendered imgRed = (ImageRendered)img;
        assertNotNull(imgRed.getRenderedImage());
        if (DEBUG_TARGET_DIR != null) {
            ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(),
                    (int)userAgent.getTargetResolution(),
                    new File(DEBUG_TARGET_DIR, "out.svg.png"));
        }
        assertEquals(67, imgRed.getRenderedImage().getWidth());
        assertEquals(67, imgRed.getRenderedImage().getHeight());
        info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image
        assertEquals(16000, info.getSize().getWidthMpt());
        assertEquals(16000, info.getSize().getHeightMpt());
    }
View Full Code Here

        img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE,
                    userAgent.getImageSessionContext());
        assertNotNull("Image must not be null", img);
        assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
        ImageRendered imgRed = (ImageRendered)img;
        assertNotNull(imgRed.getRenderedImage());
        if (DEBUG_TARGET_DIR != null) {
            ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(),
                    (int)userAgent.getTargetResolution(),
                    new File(DEBUG_TARGET_DIR, "circles.svg.png"));
        }
        assertEquals(1418, imgRed.getRenderedImage().getWidth());
        assertEquals(1418, imgRed.getRenderedImage().getHeight());
        info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image
        assertEquals(340158, info.getSize().getWidthMpt());
        assertEquals(340158, info.getSize().getHeightMpt());
    }
View Full Code Here

        Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE,
                userAgent.getImageSessionContext());
        assertNotNull("Image must not be null", img);
        assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
        ImageRendered imgRed = (ImageRendered)img;
        assertNotNull(imgRed.getRenderedImage());
        if (DEBUG_TARGET_DIR != null) {
            ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(),
                    (int)userAgent.getTargetResolution(),
                    new File(DEBUG_TARGET_DIR, "out.wmf.png"));
        }
        assertEquals(3300, imgRed.getRenderedImage().getWidth());
        assertEquals(2550, imgRed.getRenderedImage().getHeight());
        info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image
        assertEquals(792000, info.getSize().getWidthMpt());
        assertEquals(612000, info.getSize().getHeightMpt());
    }
View Full Code Here

        img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE,
                    userAgent.getImageSessionContext());
        assertNotNull("Image must not be null", img);
        assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
        ImageRendered imgRed = (ImageRendered)img;
        RenderedImage renImg = imgRed.getRenderedImage();
        assertNotNull(renImg);
        if (DEBUG_TARGET_DIR != null) {
            ImageWriterUtil.saveAsPNG(renImg,
                    (int)userAgent.getTargetResolution(),
                    new File(DEBUG_TARGET_DIR, "images.svg.png"));
        }
        assertEquals(400, renImg.getWidth());
        assertEquals(400, renImg.getHeight());
        info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image
        assertEquals(400000, info.getSize().getWidthMpt());
        assertEquals(400000, info.getSize().getHeightMpt());
        Raster raster = renImg.getData();
        // This pixel is white
        int[] pixel1 = raster.getPixel(1, 1, (int[] )null);
View Full Code Here

                RendererContext context = createRendererContext(
                        x, y, width, height, foreignAttributes);
                getGraphics2DAdapter().paintImage(imageG2D.getGraphics2DImagePainter(),
                        context, x, y, width, height);
            } else if (img instanceof ImageRendered) {
                ImageRendered imgRend = (ImageRendered)img;
                AffineTransform at = new AffineTransform();
                at.translate(x / 1000f, y / 1000f);
                double sx = pos.getWidth() / info.getSize().getWidthMpt();
                double sy = pos.getHeight() / info.getSize().getHeightMpt();
                sx *= userAgent.getSourceResolution() / info.getSize().getDpiHorizontal();
                sy *= userAgent.getSourceResolution() / info.getSize().getDpiVertical();
                at.scale(sx, sy);
                state.getGraph().drawRenderedImage(imgRend.getRenderedImage(), at);
            } else if (img instanceof ImageXMLDOM) {
                ImageXMLDOM imgXML = (ImageXMLDOM)img;
                renderDocument(imgXML.getDocument(), imgXML.getRootNamespace(),
                        pos, foreignAttributes);
            }
View Full Code Here

        AFPImageHandlerRenderedImage handler = new AFPImageHandlerRenderedImage();
        ImageInfo imageInfo = new ImageInfo(null, null);
        imageInfo.setSize(new ImageSize(
                img.getWidth(), img.getHeight(), paintingState.getResolution()));
        imageInfo.getSize().calcSizeFromPixels();
        ImageRendered red = new ImageRendered(imageInfo, img, null);
        Rectangle targetPos = new Rectangle(
                (int)Math.round(x),
                (int)Math.round(y),
                (int)Math.round(w),
                (int)Math.round(h));
View Full Code Here

    /** {@inheritDoc} */
    public void handleImage(RenderingContext context, Image image, Rectangle pos)
            throws IOException {
        Java2DRenderingContext java2dContext = (Java2DRenderingContext)context;
        ImageInfo info = image.getInfo();
        ImageRendered imageRend = (ImageRendered)image;
        Graphics2D g2d = java2dContext.getGraphics2D();

        AffineTransform at = new AffineTransform();
        at.translate(pos.x, pos.y);
        //scaling based on layout instructions
        double sx = pos.getWidth() / (double)info.getSize().getWidthMpt();
        double sy = pos.getHeight() / (double)info.getSize().getHeightMpt();

        //scaling because of image resolution
        //float sourceResolution = java2dContext.getUserAgent().getSourceResolution();
        //source resolution seems to be a bad idea, not sure why
        float sourceResolution = GraphicsConstants.DEFAULT_DPI;
        sourceResolution *= 1000; //we're working in the millipoint area
        sx *= sourceResolution / info.getSize().getDpiHorizontal();
        sy *= sourceResolution / info.getSize().getDpiVertical();
        at.scale(sx, sy);
        RenderedImage rend = imageRend.getRenderedImage();
        if (imageRend.getTransparentColor() != null && !rend.getColorModel().hasAlpha()) {
            int transCol = imageRend.getTransparentColor().getRGB();
            BufferedImage bufImage = makeTransparentImage(rend);
            WritableRaster alphaRaster = bufImage.getAlphaRaster();
            //TODO Masked images: Does anyone know a more efficient method to do this?
            final int[] transparent = new int[] {0x00};
            for (int y = 0, maxy = bufImage.getHeight(); y < maxy; y++) {
View Full Code Here

        if (!painted) {
            //Fallback solution: Paint to a BufferedImage
            FOUserAgent ua = context.getUserAgent();
            ImageManager imageManager = ua.getFactory().getImageManager();
            ImageRendered imgRend;
            try {
                imgRend = (ImageRendered)imageManager.convertImage(
                        imageG2D, new ImageFlavor[] {ImageFlavor.RENDERED_IMAGE}/*, hints*/);
            } catch (ImageException e) {
                throw new IOException(
                        "Image conversion error while converting the image to a bitmap"
                          + " as a fallback measure: " + e.getMessage());
            }

            gen.paintBitmap(imgRend.getRenderedImage(), new Dimension(pos.width, pos.height),
                    pclContext.isSourceTransparencyEnabled());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.xmlgraphics.image.loader.impl.ImageRendered

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.