Package org.apache.fop.image

Examples of org.apache.fop.image.FopImage


  int w = area.getContentWidth();
  int h = area.getHeight();

  this.currentYPosition -= h*1000;

  FopImage img = area.getImage();

  int xObjectNum = this.pdfDoc.addImage(img);

  currentStream.add("ET\nq\n" + (img.getWidth()/1000f) + " 0 0 " +
        (img.getHeight()/1000f) + " " +
        ((x + img.getX())/1000f) + " " +
        (((y - h) - img.getY())/1000f) + " cm\n" +
        "/Im" + xObjectNum + " Do\nQ\nBT\n");
    }
View Full Code Here


                drawBackground(back, sx, sy, paddRectWidth, paddRectHeight);
            }

            // background image
            if (back.getFopImage() != null) {
                FopImage fopimage = back.getFopImage();
                if (fopimage != null && fopimage.load(FopImage.DIMENSIONS)) {
                    clip(sx, sy, paddRectWidth, paddRectHeight);
                    int horzCount = (int) ((paddRectWidth * 1000 / fopimage
                            .getIntrinsicWidth()) + 1.0f);
                    int vertCount = (int) ((paddRectHeight * 1000 / fopimage
                            .getIntrinsicHeight()) + 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;
                            pos = new Rectangle2D.Float(sx
                                    + (x * fopimage.getIntrinsicWidth()), sy
                                    + (y * fopimage.getIntrinsicHeight()),
                                    fopimage.getIntrinsicWidth(), fopimage
                                            .getIntrinsicHeight());
                            putImage(back.getURL(), pos); // TODO test
                        }
                    }

View Full Code Here

        int x = currentIPPosition; // TODO + area.getXOffset();
        int y = currentBPPosition;
        String url = ImageFactory.getURL(pUrl);

        ImageFactory fact = ImageFactory.getInstance();
        FopImage fopimage = fact.getImage(url, userAgent);

        if (fopimage == null) {
            return;
        }
        if (!fopimage.load(FopImage.DIMENSIONS)) {
            return;
        }
        int w = fopimage.getWidth();
        int h = fopimage.getHeight();
        String mime = fopimage.getMimeType();
        if ("text/xml".equals(mime)) {
            if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
                return;
            }
            Document doc = ((XMLImage) fopimage).getDocument();
            String ns = ((XMLImage) fopimage).getNameSpace();
            renderDocument(doc, ns, pos);

        } else if ("image/svg+xml".equals(mime)) {
            if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
                return;
            }
            Document doc = ((XMLImage) fopimage).getDocument();
            String ns = ((XMLImage) fopimage).getNameSpace();

            renderDocument(doc, ns, pos);
        } else if ("image/eps".equals(mime)) {
            log.warn("EPS images are not supported by this renderer");
            currentBPPosition += (h * 1000);
        } else if ("image/jpeg".equals(mime)) {
            if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
                return;
            }

            // TODO Load JPEGs rather through fopimage.load(FopImage.BITMAP),
            // but JpegImage will need to be extended for that

            // url = url.substring(7);
            // url = "C:/eclipse/myWorkbenches/fop4/xml-fop/examples/fo" + url;
            java.awt.Image awtImage = new javax.swing.ImageIcon(url).getImage();

            state.getGraph().drawImage(awtImage,
                    (int)(x / 1000f), (int)(y / 1000f),
                    (int)(pos.getWidth() / 1000f), (int)(pos.getHeight() / 1000f), null);
            currentBPPosition += (h * 1000);
        } else {
            if (!fopimage.load(FopImage.BITMAP)) {
                log.warn("Loading of bitmap failed: " + url);
                return;
            }

            byte[] raw = fopimage.getBitmaps();

            // TODO Hardcoded color and sample models, FIX ME!
            ColorModel cm = new ComponentColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB),
                    new int[] {8, 8, 8},
View Full Code Here

            if (back.getColor() != null) {
                updateColor(back.getColor(), true);
                fillRect(sx, sy, paddRectWidth, paddRectHeight);
            }
            if (back.getFopImage() != null) {
                FopImage fopimage = back.getFopImage();
                if (fopimage != null && fopimage.load(FopImage.DIMENSIONS)) {
                    saveGraphicsState();
                    clipRect(sx, sy, paddRectWidth, paddRectHeight);
                    int horzCount = (int)((paddRectWidth
                            * 1000 / fopimage.getIntrinsicWidth()) + 1.0f);
                    int vertCount = (int)((paddRectHeight
                            * 1000 / fopimage.getIntrinsicHeight()) + 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 * fopimage.getIntrinsicWidth()),
                                                        sy - currentBPPosition
                                                            + (y * fopimage.getIntrinsicHeight()),
                                                        fopimage.getIntrinsicWidth(),
                                                        fopimage.getIntrinsicHeight());
                            drawImage(back.getURL(), pos);
                        }
                    }
                   
                    restoreGraphicsState();
View Full Code Here

            return;
        }

        url = ImageFactory.getURL(url);
        ImageFactory fact = ImageFactory.getInstance();
        FopImage fopimage = fact.getImage(url, userAgent);
        if (fopimage == null) {
            return;
        }
        if (!fopimage.load(FopImage.DIMENSIONS)) {
            return;
        }
        String mime = fopimage.getMimeType();
        if ("text/xml".equals(mime)) {
            if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
                return;
            }
            Document doc = ((XMLImage) fopimage).getDocument();
            String ns = ((XMLImage) fopimage).getNameSpace();

            renderDocument(doc, ns, pos);
        } else if ("image/svg+xml".equals(mime)) {
            if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
                return;
            }
            Document doc = ((XMLImage) fopimage).getDocument();
            String ns = ((XMLImage) fopimage).getNameSpace();

            renderDocument(doc, ns, pos);
        } else if ("image/eps".equals(mime)) {
            FopPDFImage pdfimage = new FopPDFImage(fopimage, url);
            int xobj = pdfDoc.addImage(currentContext, pdfimage).getXNumber();
            fact.releaseImage(url, userAgent);
        } else if ("image/jpeg".equals(mime) || "image/tiff".equals(mime)) {
            FopPDFImage pdfimage = new FopPDFImage(fopimage, url);
            int xobj = pdfDoc.addImage(currentContext, pdfimage).getXNumber();
            fact.releaseImage(url, userAgent);

            float w = (float)pos.getWidth() / 1000f;
            float h = (float)pos.getHeight() / 1000f;
            placeImage((float) pos.getX() / 1000,
                       (float) pos.getY() / 1000, w, h, xobj);
        } else {
            if (!fopimage.load(FopImage.BITMAP)) {
                return;
            }
            FopPDFImage pdfimage = new FopPDFImage(fopimage, url);
            int xobj = pdfDoc.addImage(currentContext, pdfimage).getXNumber();
            fact.releaseImage(url, userAgent);
View Full Code Here

            // error
            break;
        }

        try {
            FopImage fopimg = new TempImage(width, height, result, null);
            AffineTransform at = getTransform();
            gen.saveGraphicsState();
            gen.concatMatrix(at);
            Shape imclip = getClip();
            writeClip(imclip);
View Full Code Here

    /** @see org.apache.fop.render.AbstractPathOrientedRenderer */
    protected void drawImage(String url, Rectangle2D pos) {
        endTextObject();
        url = ImageFactory.getURL(url);
        ImageFactory fact = ImageFactory.getInstance();
        FopImage fopimage = fact.getImage(url, userAgent);
        if (fopimage == null) {
            return;
        }
        if (!fopimage.load(FopImage.DIMENSIONS)) {
            return;
        }
        float x = (float)pos.getX() / 1000f;
        x += currentIPPosition / 1000f;
        float y = (float)pos.getY() / 1000f;
        y += currentBPPosition / 1000f;
        float w = (float)pos.getWidth() / 1000f;
        float h = (float)pos.getHeight() / 1000f;
        try {
            String mime = fopimage.getMimeType();
            if ("text/xml".equals(mime)) {
                if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
                    return;
                }
                Document doc = ((XMLImage) fopimage).getDocument();
                String ns = ((XMLImage) fopimage).getNameSpace();

                renderDocument(doc, ns, pos);
            } else if ("image/svg+xml".equals(mime)) {
                if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
                    return;
                }
                Document doc = ((XMLImage) fopimage).getDocument();
                String ns = ((XMLImage) fopimage).getNameSpace();

View Full Code Here

            String url = eg.getURL();
            newGraphic.setURL(url);

            //set image data
            ImageFactory fact = ImageFactory.getInstance();
            FopImage fopimage = fact.getImage(url, eg.getUserAgent());
            fopimage.load(FopImage.ORIGINAL_DATA);

            newGraphic.setImageData(fopimage.getRessourceBytes());

            //set scaling
            if (eg.getScaling() == Constants.EN_UNIFORM) {
                newGraphic.setScaling ("uniform");
            }

            //get width
            int width = 0;
            if (eg.getWidth().getEnum() == Constants.EN_AUTO) {
                width = fopimage.getIntrinsicWidth();
            } else {
                width = eg.getWidth().getValue();
            }

            //get height
            int height = 0;
            if (eg.getWidth().getEnum() == Constants.EN_AUTO) {
                height = fopimage.getIntrinsicHeight();
            } else {
                height = eg.getHeight().getValue();
            }

            //get content-width
            int contentwidth = 0;
            if (eg.getContentWidth().getEnum()
                    == Constants.EN_AUTO) {
                contentwidth = fopimage.getIntrinsicWidth();
            } else if (eg.getContentWidth().getEnum()
                    == Constants.EN_SCALE_TO_FIT) {
                contentwidth = width;
            } else {
                //TODO: check, if the value is a percent value
                contentwidth = eg.getContentWidth().getValue();
            }

            //get content-width
            int contentheight = 0;
            if (eg.getContentHeight().getEnum()
                    == Constants.EN_AUTO) {

                contentheight = fopimage.getIntrinsicHeight();

            } else if (eg.getContentHeight().getEnum()
                    == Constants.EN_SCALE_TO_FIT) {

                contentheight = height;
View Full Code Here

TOP

Related Classes of org.apache.fop.image.FopImage

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.