/** {@inheritDoc} */ public int getWidth() { return image.getSize().getWidthPx(); }
/** {@inheritDoc} */ public int getHeight() { return image.getSize().getHeightPx(); }
int numColumns = image.getSize().getWidthPx(); InflaterInputStream infStream = new InflaterInputStream(in, new Inflater()); DataInputStream dataStream = new DataInputStream(infStream);
/** {@inheritDoc} */ public Image convert(Image src, Map hints) throws ImageException, IOException { checkSourceFlavor(src); assert src instanceof ImageRendered; ImageRendered rendered = (ImageRendered)src; ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(MimeConstants.MIME_PNG); if (writer == null) { throw new ImageException("Cannot convert image to PNG. No suitable ImageWriter found."); } ByteArrayOutputStream baout = new ByteArrayOutputStream(); ImageWriterParams params = new ImageWriterParams(); params.setResolution((int)Math.round(src.getSize().getDpiHorizontal())); writer.writeImage(rendered.getRenderedImage(), baout, params); return new ImageRawStream(src.getInfo(), getTargetFlavor(), new java.io.ByteArrayInputStream(baout.toByteArray())); }
/** {@inheritDoc} */ public void primitivePaint(Graphics2D g2d) { if (g2d instanceof NativeImageHandler) { NativeImageHandler nativeImageHandler = (NativeImageHandler) g2d; float x = 0; float y = 0; try { float width = image.getSize().getWidthPx(); float height = image.getSize().getHeightPx(); nativeImageHandler.addNativeImage(image, x, y, width, height); } catch (Exception e) { ctx.getUserAgent().displayError(e); } } else { // Not going directly into PDF so use // original implementation so filters etc work. if (origGraphicsNode == null) { // Haven't constructed base class Graphics Node, // so do so now. origGraphicsNode = superCreateGraphicsNode(ctx, imageElement, purl); } origGraphicsNode.primitivePaint(g2d); } }
flate.setColumns(image.getSize().getWidthPx()); flate.setBitsPerComponent(this.getBitsPerComponent()); } catch (PDFFilterException e) { int numColumns = image.getSize().getWidthPx(); int bytesPerRow = numberOfInterleavedComponents * numColumns; int filter; transFlate.setPredictor(FlateFilter.PREDICTION_PNG_OPT); transFlate.setColors(1); transFlate.setColumns(image.getSize().getWidthPx()); transFlate.setBitsPerComponent(this.getBitsPerComponent()); } catch (PDFFilterException e) { throw new RuntimeException("FlateFilter configuration error", e); BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(), image.getSize().getHeightPx(), baos.toByteArray(), null); alphaMask.setPDFFilter(transFlate); alphaMask.disallowMultipleFilters();
/** {@inheritDoc} */ public Image convert(Image src, Map hints) throws ImageException { checkSourceFlavor(src); ImageGraphics2D g2dImage = (ImageGraphics2D)src; DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); // Create an instance of org.w3c.dom.Document Document document = domImpl.createDocument( SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null); Element root = document.getDocumentElement(); // Create an SVGGeneratorContext to customize SVG generation SVGGeneratorContext genCtx = SVGGeneratorContext.createDefault(document); 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, new Rectangle2D.Float(0, 0, dim.width, dim.height)); //Populate the document root with the generated SVG content. g2d.getRoot(root); //Return the generated SVG image ImageXMLDOM svgImage = new ImageXMLDOM(src.getInfo(), document, BatikImageFlavors.SVG_DOM); g2d.dispose(); return svgImage; }
/** {@inheritDoc} */ public void setup(PDFDocument doc) { pdfFilter = new CCFFilter(); pdfFilter.setApplied(true); PDFDictionary dict = new PDFDictionary(); dict.put("Columns", this.image.getSize().getWidthPx()); int compression = getImage().getCompression(); switch (compression) { case TIFFImage.COMP_FAX_G3_1D : dict.put("K", 0); break; case TIFFImage.COMP_FAX_G3_2D : dict.put("K", 1); break; case TIFFImage.COMP_FAX_G4_2D : dict.put("K", -1); break; default: throw new IllegalStateException("Invalid compression scheme: " + compression); } ((CCFFilter)pdfFilter).setDecodeParms(dict); super.setup(doc); }
float w = image.getSize().getWidthMpt(); float h = image.getSize().getHeightMpt(); log.trace("source res: " + uaResolution + ", targetRes: " + deviceResolution + " --> target scaling: " + targetScale); log.trace(image.getSize()); log.trace("sx: " + sx + ", sy: " + sy); log.trace("scaling: " + scaling);
updateIntrinsicSize(imageObjectInfo, paintingState, image.getSize());
Dimension imageSize = image.getSize().getDimensionMpt(); Graphics2DImagePainter painter = new Graphics2DImagePainterImpl( root, bridgeContext, imageSize);