Package org.apache.xmlgraphics.image.loader

Examples of org.apache.xmlgraphics.image.loader.ImageSize


                int width = wmfStore.getWidthUnits();
                int height = wmfStore.getHeightUnits();
                int dpi = wmfStore.getMetaFileUnitsPerInch();

                ImageInfo info = new ImageInfo(uri, "image/x-wmf");
                ImageSize size = new ImageSize();
                size.setSizeInPixels(width, height);
                size.setResolution(dpi);
                size.calcSizeFromPixels();
                info.setSize(size);
                ImageWMF img = new ImageWMF(info, wmfStore);
                info.getCustomObjects().put(ImageInfo.ORIGINAL_IMAGE, img);

                return info;
View Full Code Here


        genCtx.setComment("Generated by Apache Batik's SVGGraphics2D");
        genCtx.setEmbeddedFontsOn(true);

        // Create an instance of the SVG Generator
        SVGGraphics2D g2d = new SVGGraphics2D(genCtx, true);
        ImageSize size = src.getSize();
        Dimension dim = size.getDimensionMpt();
        g2d.setSVGCanvasSize(dim);
        //SVGGraphics2D doesn't generate the viewBox by itself
        root.setAttribute("viewBox", "0 0 " + dim.width + " " + dim.height);

        g2dImage.getGraphics2DImagePainter().paint(g2d,
View Full Code Here

            int widthMpt = (int)Math.round(px2mpt(width, context.getSourceResolution()));
            int heightMpt = (int)Math.round(px2mpt(height, context.getSourceResolution()));

            ImageInfo info = new ImageInfo(uri, MimeConstants.MIME_SVG);
            ImageSize size = new ImageSize();
            size.setSizeInMillipoints(widthMpt, heightMpt);
            //Set the resolution to that of the FOUserAgent
            size.setResolution(context.getSourceResolution());
            size.calcPixelsFromSize();
            info.setSize(size);

            //The whole image had to be loaded for this, so keep it
            ImageXMLDOM xmlImage = new ImageXMLDOM(info,
                    doc, BatikImageFlavors.SVG_DOM);
View Full Code Here

            if (back.getColor() != null) {
                updateColor(back.getColor(), true);
                fillRect(sx, sy, paddRectWidth, paddRectHeight);
            }
            if (back.getImageInfo() != null) {
                ImageSize imageSize = back.getImageInfo().getSize();
                saveGraphicsState();
                clipRect(sx, sy, paddRectWidth, paddRectHeight);
                int horzCount = (int)((paddRectWidth
                        * 1000 / imageSize.getWidthMpt()) + 1.0f);
                int vertCount = (int)((paddRectHeight
                        * 1000 / imageSize.getHeightMpt()) + 1.0f);
                if (back.getRepeat() == EN_NOREPEAT) {
                    horzCount = 1;
                    vertCount = 1;
                } else if (back.getRepeat() == EN_REPEATX) {
                    vertCount = 1;
                } else if (back.getRepeat() == EN_REPEATY) {
                    horzCount = 1;
                }
                //change from points to millipoints
                sx *= 1000;
                sy *= 1000;
                if (horzCount == 1) {
                    sx += back.getHoriz();
                }
                if (vertCount == 1) {
                    sy += back.getVertical();
                }
                for (int x = 0; x < horzCount; x++) {
                    for (int y = 0; y < vertCount; y++) {
                        // place once
                        Rectangle2D pos;
                        // Image positions are relative to the currentIP/BP
                        pos = new Rectangle2D.Float(sx - currentIPPosition
                                                        + (x * imageSize.getWidthMpt()),
                                                    sy - currentBPPosition
                                                        + (y * imageSize.getHeightMpt()),
                                                        imageSize.getWidthMpt(),
                                                        imageSize.getHeightMpt());
                        drawImage(back.getURL(), pos);
                    }
                }

                restoreGraphicsState();
View Full Code Here

        }
        float ditheringQuality = paintingState.getDitheringQuality();
        RenderedImage renderedImage = imageRendered.getRenderedImage();

        ImageInfo imageInfo = imageRendered.getInfo();
        ImageSize intrinsicSize = imageInfo.getSize();

        boolean useFS10 = (maxPixelSize == 1) || BitmapImageUtil.isMonochromeImage(renderedImage);
        int functionSet = useFS10 ? 10 : 11;
        boolean usePageSegments = useFS10
                    && !imageObjectInfo.getResourceInfo().getLevel().isInline();

        ImageSize effIntrinsicSize = intrinsicSize;
        if (usePageSegments) {
            //Resize, optionally resample and convert image
            Dimension resampledDim = new Dimension(
                    (int)Math.ceil(UnitConv.mpt2px(targetSize.getWidth(), resolution)),
                    (int)Math.ceil(UnitConv.mpt2px(targetSize.getHeight(), resolution)));

            imageObjectInfo.setCreatePageSegment(true);
            imageObjectInfo.getResourceInfo().setImageDimension(resampledDim);

            //Only resample/downsample if image is smaller than its intrinsic size
            //to make print file smaller
            boolean resample = resampledDim.width < renderedImage.getWidth()
                && resampledDim.height < renderedImage.getHeight();
            if (resample) {
                if (log.isDebugEnabled()) {
                    log.debug("Resample from " + intrinsicSize.getDimensionPx()
                            + " to " + resampledDim);
                }
                renderedImage = BitmapImageUtil.convertToMonochrome(renderedImage,
                        resampledDim, ditheringQuality);
                effIntrinsicSize = new ImageSize(
                        resampledDim.width, resampledDim.height, resolution);
            } else if (ditheringQuality >= 0.5f) {
                renderedImage = BitmapImageUtil.convertToMonochrome(renderedImage,
                        intrinsicSize.getDimensionPx(), ditheringQuality);
            }
        }

        imageObjectInfo.setDataHeightRes((int)Math.round(
                effIntrinsicSize.getDpiHorizontal() * 10));
        imageObjectInfo.setDataWidthRes((int)Math.round(
                effIntrinsicSize.getDpiVertical() * 10));

        int dataHeight = renderedImage.getHeight();
        imageObjectInfo.setDataHeight(dataHeight);

        int dataWidth = renderedImage.getWidth();
View Full Code Here

                + xObject.getName() + " Do\nQ\n");
    }

    private PDFXObject addRenderedImage(String key, RenderedImage img) {
        ImageInfo info = new ImageInfo(null, "image/unknown");
        ImageSize size = new ImageSize(img.getWidth(), img.getHeight(), 72);
        info.setSize(size);
        ImageRendered imgRend = new ImageRendered(info, img, null);
        ImageRenderedAdapter adapter = new ImageRenderedAdapter(imgRend, key);
        PDFXObject xObject = pdfDoc.addImage(resourceContext, adapter);
        flushPDFDocument();
View Full Code Here

        dataObjectInfo.setDataHeight(dataHeight);

        int dataWidth = rawStream.getSize().getWidthPx();
        dataObjectInfo.setDataWidth(dataWidth);

        ImageSize imageSize = rawStream.getSize();
        dataObjectInfo.setDataHeightRes((int) (imageSize.getDpiHorizontal() * 10));
        dataObjectInfo.setDataWidthRes((int) (imageSize.getDpiVertical() * 10));
    }
View Full Code Here

            .getProperty(PDFRendererContextConstants.PDF_DOCUMENT);
        PDFResourceContext resContext = (PDFResourceContext) context
            .getProperty(PDFRendererContextConstants.PDF_CONTEXT);

        ImageInfo imgInfo = new ImageInfo(null, null);
        ImageSize imgSize = new ImageSize();
        imgSize.setSizeInPixels(bi.getWidth(), bi.getHeight());
        imgSize.setResolution(72);
        imgInfo.setSize(imgSize);

        ImageBuffered img = new ImageBuffered(imgInfo, bi, null);
        PDFImage pdfimage = new ImageRenderedAdapter(img, resName);
        PDFXObject xobj = pdfDoc.addImage(resContext, pdfimage);
View Full Code Here

    protected void handleAlternativeImageOverlay(Element root,
            PDF3DAnnotation annot) {
        String uri = DOMUtil.getAttribute(root, "altsrc").trim();
        if (uri.length() > 0) {
            uri = URISpecification.getURL(uri);
            ImageSize imgSize = renderer.getImageSize(uri);

            String xFormKey = "3D_Overlay_XForm_" + uri;
            PDFFormXObject xForm = (PDFFormXObject) pdfi.pdfDoc
                .getXObject(xFormKey);
            if (xForm == null) {
                // Form XObject content stream
                PDFStream xFormStream = pdfi.factory.makeStream(
                    PDFFilterList.CONTENT_FILTER, false);

                // locate the image with the upper left corner
                Rectangle2D pos = new Rectangle2D.Double(0, 0, imgSize
                    .getWidthMpt(), imgSize.getHeightMpt());

                // Adds the image to the PDF document
                renderer.addImageXObject(uri, pos, xFormStream);

                // Resource context
                PDFResourceContext resContext = (PDFResourceContext) ctx
                    .getProperty(PDFRendererContextConstants.PDF_CONTEXT);

                // Try to get a already added image with the same key
                PDFXObject xObj = pdfi.pdfDoc.getXObject(uri);

                PDFReference xFormResRef = null;
                if (xObj != null) {
                    // e.g. Form XObject's resources aren't used for svg images
                    // (svg images are drawn directly to the stream)
                    PDFResources xFormRes = pdfi.factory.makeResources();
                    xFormRes.addXObject(xObj);
                    xFormResRef = xFormRes.makeReference();
                }

                // Build new Form XObject
                xForm = pdfi.pdfDoc.addFormXObject(resContext, xFormStream,
                    xFormResRef, xFormKey);

                // Setup bounding box for the Form XObject
                // We set this to the dimensions of the image overlay.
                xForm.setBBox(new Rectangle2D.Double(0.0d, 0.0d,
                    (double) imgSize.getWidthMpt() / 1000d, (double) imgSize
                        .getHeightMpt() / 1000d));
            }
            // Add the newly created Form XObject to the 3D annotation.
            // (as a "normal" appearance, used if the 3d artwork is disabled)
            annot.setNormalAppearance(xForm);
View Full Code Here

     * @return Size of the referenced image or null if any error
     *         occurs.
     */
    public ImageSize getImageSize(String uri) {
        ImageInfo info = getImageInfo(uri);
        ImageSize size = null;
        if (info != null) {
            size = info.getSize();
        }
        return size;
    }
View Full Code Here

TOP

Related Classes of org.apache.xmlgraphics.image.loader.ImageSize

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.