protected static ImageManager getImageManager() { if (imageManagerInstance == null) { synchronized(imageManagerMutex) { if (imageManagerInstance == null) { imageManagerInstance = new ImageManager(new DefaultImageContext()); } } } return imageManagerInstance; }
public static CxCy scale(ImageInfo imageInfo, double xEmu, double yEmu) { ImageSize size = imageInfo.getSize(); double iwEmu = toEmu(size.getWidthPx(), size.getDpiHorizontal()); double ihEmu = toEmu(size.getHeightPx(), size.getDpiVertical()); return scaleToFit(iwEmu, ihEmu, xEmu, yEmu); }
public static void displayImageInfo(ImageInfo info) { ImageSize size = info.getSize(); Dimension2D dPt = size.getDimensionPt(); Dimension dPx = size.getDimensionPx(); log.debug(info.getOriginalURI() + " " + info.getMimeType() + " " + Math.round(dPx.getWidth()) + "x" + Math.round(dPx.getHeight())); log.debug("Resolution:" + Math.round(size.getDpiHorizontal()) + "x" + Math.round(size.getDpiVertical())); log.debug("Print size: " + Math.round(dPt.getWidth() / 72) + "\" x" + Math.round(dPt.getHeight() / 72) + "\""); }
ImageSize size = imagePart.getImageInfo().getSize(); double ratio = (double) size.getHeightPx() / (double) size.getWidthPx(); log.debug("fit ratio: " + ratio); if (ratio > 1) {
/** * Create a <wp:inline> element suitable for this image, * which can be _embedded_ in w:p/w:r/w:drawing. * @param filenameHint Any text, for example the original filename * @param altText Like HTML's alt text * @param id1 An id unique in the document * @param id2 Another id unique in the document * @param cx Image width in twip * @param link true if this is to be linked not embedded * None of these things seem to be exposed in Word 2007's * user interface, but Word won't open the document if * any of the attributes these go in (except @ desc) aren't present! * @throws Exception */ public Inline createImageInline(String filenameHint, String altText, int id1, int id2, long cx, boolean link) throws Exception { ImageSize size = imageInfo.getSize(); Dimension2D dPt = size.getDimensionPt(); double imageWidthTwips = dPt.getWidth() * 20; log.debug("imageWidthTwips: " + imageWidthTwips); long cy; log.debug("Scaling image height to retain aspect ratio"); cy = UnitsOfMeasurement.twipToEMU(dPt.getHeight() * 20 * cx / imageWidthTwips); // Now convert cx to EMU cx = UnitsOfMeasurement.twipToEMU(cx); log.debug("cx=" + cx + "; cy=" + cy); return createImageInline(filenameHint, altText, id1, id2, cx, cy, link); }
String ext = info.getMimeType().substring(info.getMimeType().indexOf("/") + 1); info.getMimeType(), createImageName(opcPackage, sourcePart, proposedRelId, ext), null);
&& (info.getMimeType().equals(ContentTypes.IMAGE_TIFF) || info.getMimeType().equals(ContentTypes.IMAGE_EMF2) // ImageInfo || info.getMimeType().equals(ContentTypes.IMAGE_WMF) || info.getMimeType().equals(ContentTypes.IMAGE_PNG) || info.getMimeType().equals(ContentTypes.IMAGE_JPEG) || info.getMimeType().equals(ContentTypes.IMAGE_GIF) || info.getMimeType().equals(ContentTypes.IMAGE_BMP))) { getImageManager().getCache().clearCache(); try {
ImageSize size = imageInfo.getSize(); Dimension2D dpx = size.getDimensionPx();
/** {@inheritDoc} */ public int getWidth() { return image.getSize().getWidthPx(); }
/** {@inheritDoc} */ public int getHeight() { return image.getSize().getHeightPx(); }
ImageSessionContext sessionContext = new DefaultImageSessionContext( getImageManager().getImageContext(), null); ImageInfo info = getImageManager().getImageInfo(url.toString(), sessionContext);
/** {@inheritDoc} */ public boolean isCompatible(ImageFlavor flavor) { return getParentFlavor().isCompatible(flavor) || super.isCompatible(flavor); }
/** * Indicates whether a particular image flavor is compatible with this one. * @param flavor the other image flavor * @return true if the two are compatible */ public boolean isCompatible(ImageFlavor flavor) { return this.equals(flavor); }
/** * Constructs a new image flavor. * @param parentFlavor the parent image flavor * @param namespace an XML namespace URI refining the parent image flavor */ public XMLNamespaceEnabledImageFlavor(ImageFlavor parentFlavor, String namespace) { super(parentFlavor.getName() + ";namespace=" + namespace, parentFlavor); this.namespace = namespace; }
public static CxCy scale(ImageInfo imageInfo, double xEmu, double yEmu) { ImageSize size = imageInfo.getSize(); double iwEmu = toEmu(size.getWidthPx(), size.getDpiHorizontal()); double ihEmu = toEmu(size.getHeightPx(), size.getDpiVertical()); return scaleToFit(iwEmu, ihEmu, xEmu, yEmu); }
ImageSize size = imagePart.getImageInfo().getSize(); double ratio = (double) size.getHeightPx() / (double) size.getWidthPx(); log.debug("fit ratio: " + ratio); if (ratio > 1) {
String ext = info.getMimeType().substring(info.getMimeType().indexOf("/") + 1); info.getMimeType(), createImageName(opcPackage, sourcePart, proposedRelId, ext), null);
/** * Constructs a new image flavor. * @param parentFlavor the parent image flavor */ protected RefinedImageFlavor(ImageFlavor parentFlavor) { this(parentFlavor.getName(), parentFlavor); }
String ext = info.getMimeType().substring(info.getMimeType().indexOf("/") + 1); info.getMimeType(), createImageName(opcPackage, sourcePart, proposedRelId, ext), null);
/** * Constructs a new image flavor. * @param parentFlavor the parent image flavor * @param mime a MIME type refining the parent image flavor */ public MimeEnabledImageFlavor(ImageFlavor parentFlavor, String mime) { super(mime + ";" + parentFlavor.getName(), parentFlavor); this.mime = mime; }