protected static ImageManager getImageManager() { if (imageManagerInstance == null) { synchronized(imageManagerMutex) { if (imageManagerInstance == null) { imageManagerInstance = new ImageManager(new DefaultImageContext()); } } } return imageManagerInstance; }
getImageManager().getImageContext(), null); ImageInfo info = getImageManager().getImageInfo(url.toString(), sessionContext);
getImageManager().getCache().clearCache(); try {
ImageInfo info = imageManager.getImageInfo(uri, userAgent.getImageSessionContext()); log.trace("Subimage: " + tempURI.toASCIIString()); ImageInfo subinfo = imageManager.getImageInfo( tempURI.toASCIIString(), userAgent.getImageSessionContext());
ImageSessionContext sessionContext = bridgeCtx.getImageSessionContext(); try { ImageInfo info = manager.getImageInfo(purl.toString(), sessionContext); ImageFlavor[] supportedFlavors = getSupportedFlavours(); Image image = manager.getImage(info, supportedFlavors, sessionContext); } else { image = manager.convertImage(xmlImage, new ImageFlavor[] {ImageFlavor.GRAPHICS2D});
ImageSessionContext session) throws ImageException, IOException { hints = prepareHints(hints, session); ImageProviderPipeline[] candidates = getPipelineFactory().determineCandidatePipelines( info, flavors); ImageProviderPipeline pipeline = choosePipeline(candidates);
try { ImageSessionContext sessionContext = userAgent.getImageSessionContext(); info = manager.getImageInfo(uri, sessionContext); org.apache.xmlgraphics.image.loader.Image img = manager.getImage( info, flavors, hints, sessionContext);
/** * Returns an ImageInfo object containing its intrinsic size for a given URI. The ImageInfo * is retrieved from an image cache if it has been requested before. * @param uri the URI of the image * @param session the session context through which to resolve the URI if the image is not in * the cache * @return the ImageInfo object created from the image * @throws ImageException If no suitable ImagePreloader can be found to load the image or * if an error occurred while preloading the image. * @throws IOException If an I/O error occurs while preloading the image */ public ImageInfo getImageInfo(String uri, ImageSessionContext session) throws ImageException, IOException { if (getCache() != null) { return getCache().needImageInfo(uri, session, this); } else { return preloadImage(uri, session); } }
ImageManager manager = renderingContext.getUserAgent().getImageManager(); ImageProviderPipeline[] inlineCandidates = manager.getPipelineFactory().determineCandidatePipelines( info, inlineFlavors); ImageProviderPipeline inlineChoice = manager.choosePipeline(inlineCandidates); ImageFlavor inlineFlavor = (inlineChoice != null ? inlineChoice.getTargetFlavor() : null); = manager.getPipelineFactory().determineCandidatePipelines( info, formFlavors); ImageProviderPipeline formChoice = manager.choosePipeline(formCandidates); ImageFlavor formFlavor = (formChoice != null ? formChoice.getTargetFlavor() : null);
ImageInfo imageInfo, ImageFlavor targetFlavor) { String originalMime = imageInfo.getMimeType(); ImageImplRegistry registry = manager.getRegistry(); List candidates = new java.util.ArrayList(); ImageProviderPipeline pipeline = new ImageProviderPipeline(manager.getCache(), loader); candidates.add(pipeline); } else {
/** * Converts an image with no hints. See * {@link #convertImage(Image, ImageFlavor[], Map)} for more * information. * @param image the image to convert * @param flavors the requested image flavors (in preferred order). * @return the fully loaded image * @throws ImageException If no suitable loader/converter combination is available to fulfill * the request or if an error occurred while loading the image. * @throws IOException If an I/O error occurs */ public Image convertImage(Image image, ImageFlavor[] flavors) throws ImageException, IOException { return convertImage(image, flavors, null); }
/** * Loads an image with no hints. See * {@link #getImage(ImageInfo, ImageFlavor, Map, ImageSessionContext)} for more * information. * @param info the ImageInfo instance for the image (obtained by * {@link #getImageInfo(String, ImageSessionContext)}) * @param flavor the requested image flavor. * @param session the session context * @return the fully loaded image * @throws ImageException If no suitable loader/converter combination is available to fulfill * the request or if an error occurred while loading the image. * @throws IOException If an I/O error occurs */ public Image getImage(ImageInfo info, ImageFlavor flavor, ImageSessionContext session) throws ImageException, IOException { return getImage(info, flavor, ImageUtil.getDefaultHints(session), session); }
/** * Finds and returns an array of {@link ImageProviderPipeline} instances which can handle * the given MIME type and return one of the given {@link ImageFlavor}s. * @param imageInfo the image info object * @param flavors the possible target flavors * @return an array of pipelines */ public ImageProviderPipeline[] determineCandidatePipelines(ImageInfo imageInfo, ImageFlavor[] flavors) { List candidates = new java.util.ArrayList(); for (ImageFlavor flavor : flavors) { //Find the best pipeline for each flavor ImageProviderPipeline pipeline = newImageConverterPipeline(imageInfo, flavor); if (pipeline == null) { continue; //No suitable pipeline found for flavor } Penalty p = pipeline.getConversionPenalty(this.manager.getRegistry()); if (!p.isInfinitePenalty()) { candidates.add(pipeline); } } return (ImageProviderPipeline[])candidates.toArray( new ImageProviderPipeline[candidates.size()]); }
/** * Preloads an image, i.e. the format of the image is identified and some basic information * (MIME type, intrinsic size and possibly other values) are loaded and returned as an * ImageInfo object. Note that the image is not fully loaded normally. Only with certain formats * the image is already fully loaded and references added to the ImageInfo's custom objects * (see {@link ImageInfo#getOriginalImage()}). * <p> * The reason for the preloading: Apache FOP, for example, only needs the image's intrinsic * size during layout. Only when the document is rendered to the final format does FOP need * to load the full image. Like this a lot of memory can be saved. * @param uri the original URI of the image * @param session the session context through which to resolve the URI * @return the ImageInfo object created from the image * @throws ImageException If no suitable ImagePreloader can be found to load the image or * if an error occurred while preloading the image. * @throws IOException If an I/O error occurs while preloading the image */ public ImageInfo preloadImage(String uri, ImageSessionContext session) throws ImageException, IOException { Source src = session.needSource(uri); ImageInfo info = preloadImage(uri, src); session.returnSource(uri, src); return info; }
ImageSessionContext session) throws ImageException, IOException { hints = prepareHints(hints, session); ImageProviderPipeline pipeline = getPipelineFactory().newImageConverterPipeline( info, flavor); if (pipeline != null) {
ImageSessionContext sessionContext = userAgent.getImageSessionContext(); ImageInfo info = manager.getImageInfo(uri, sessionContext); bkg.setImageInfo(info); } catch (ImageException e) {
hints = prepareHints(hints, null); ImageInfo info = image.getInfo(); ImageProviderPipeline[] candidates = getPipelineFactory().determineCandidatePipelines( image, flavors); ImageProviderPipeline pipeline = choosePipeline(candidates);
try { ImageSessionContext sessionContext = getUserAgent().getImageSessionContext(); info = manager.getImageInfo(uri, sessionContext); Map hints = ImageUtil.getDefaultHints(sessionContext); org.apache.xmlgraphics.image.loader.Image img = manager.getImage( info, FLAVOURS, hints, sessionContext); if (img instanceof ImageGraphics2D) {
hints.putAll(additionalHints); effImage = manager.convertImage(image, imageHandlerRegistry.getSupportedFlavors(context), hints); } else {
/** * Loads an image with no hints. See * {@link #getImage(ImageInfo, ImageFlavor[], Map, ImageSessionContext)} for more * information. * @param info the ImageInfo instance for the image (obtained by * {@link #getImageInfo(String, ImageSessionContext)}) * @param flavors the requested image flavors (in preferred order). * @param session the session context * @return the fully loaded image * @throws ImageException If no suitable loader/converter combination is available to fulfill * the request or if an error occurred while loading the image. * @throws IOException If an I/O error occurs */ public Image getImage(ImageInfo info, ImageFlavor[] flavors, ImageSessionContext session) throws ImageException, IOException { return getImage(info, flavors, ImageUtil.getDefaultHints(session), session); }