本文整理汇总了Java中org.xhtmlrenderer.util.ImageUtil类的典型用法代码示例。如果您正苦于以下问题:Java ImageUtil类的具体用法?Java ImageUtil怎么用?Java ImageUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageUtil类属于org.xhtmlrenderer.util包,在下文中一共展示了ImageUtil类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImageResource
import org.xhtmlrenderer.util.ImageUtil; //导入依赖的package包/类
@Override
public ImageResource getImageResource(String uri) {
if (ImageUtil.isEmbeddedBase64Image(uri)) {
return loadEmbeddedBase64ImageResource(uri);
} else {
uri = resolveURI(uri);
try {
Texture tex = ToolKit.get().getApplication().getAssetManager().loadTexture(new TextureKey(uri));
return new ImageResource(uri, new XHTMLFSImage(tex.getImage(), this, uri));
} catch (AssetNotFoundException anfe) {
XRLog.exception(String.format("Image at URI %s not found", uri));
} catch (Exception e) {
XRLog.exception(String.format("Failed to load %s", uri), e);
}
return new ImageResource(uri, new XHTMLFSImage(getMissingImage(), this, uri));
}
}
示例2: prepareLayout
import org.xhtmlrenderer.util.ImageUtil; //导入依赖的package包/类
private void prepareLayout() {
outputImage = ImageUtil.createCompatibleBufferedImage(DEFAULT_DOTS_PER_POINT, DEFAULT_DOTS_PER_POINT);
outputDevice = new Java2DOutputDevice(outputImage);
sharedContext = getSharedContext();
setDocument(doc, null, new XhtmlNamespaceHandler());
layout(this.width);
}
示例3: loadEmbeddedBase64ImageResource
import org.xhtmlrenderer.util.ImageUtil; //导入依赖的package包/类
private ImageResource loadEmbeddedBase64ImageResource(final String uri) {
byte[] image = ImageUtil.getEmbeddedBase64Image(uri);
if (image != null) {
return createImageResource(null, new ByteArrayInputStream(image));
}
return new ImageResource(null, null);
}
示例4: loadEmbeddedBase64ImageResource
import org.xhtmlrenderer.util.ImageUtil; //导入依赖的package包/类
private ImageResource loadEmbeddedBase64ImageResource(final String uri) {
byte[] image = ImageUtil.getEmbeddedBase64Image(uri);
if (image != null) {
return createImageResource(null, new ByteArrayInputStream(image));
}
return new ImageResource(null, null);
}
示例5: run
import org.xhtmlrenderer.util.ImageUtil; //导入依赖的package包/类
public void run() {
try {
while (true) {
final ImageLoadItem loadItem = queue.getTask();
if (ImageLoadQueue.isKillSwitch(loadItem)) {
break;
}
final ImageResource ir = ImageResourceLoader.loadImageResourceFromUri(loadItem._uri);
FSImage awtfsImage = ir.getImage();
BufferedImage newImg = (BufferedImage) ((AWTFSImage) awtfsImage).getImage();
XRLog.load(Level.FINE, this + ", loaded " + loadItem._uri);
loadItem._imageResourceLoader.loaded(ir, newImg.getWidth(), newImg.getHeight());
final boolean wasScaled;
if (loadItem.haveTargetDimensions() && !ir.hasDimensions(loadItem._targetWidth, loadItem._targetHeight)) {
XRLog.load(Level.FINE, this + ", scaling " + loadItem._uri + " to " + loadItem._targetWidth + ", " + loadItem._targetHeight);
newImg = ImageUtil.getScaledInstance(newImg, loadItem._targetWidth, loadItem._targetHeight);
ImageResource sir = new ImageResource(ir.getImageUri(), AWTFSImage.createImage(newImg));
loadItem._imageResourceLoader.loaded(sir, newImg.getWidth(), newImg.getHeight());
wasScaled = true;
} else {
wasScaled = false;
}
// msfImage belongs to the Swing AWT thread
final BufferedImage newImg1 = newImg;
EventQueue.invokeLater(new Runnable() {
public void run() {
loadItem._mfsImage.setImage(loadItem._uri, newImg1, wasScaled);
}
});
}
} catch (InterruptedException e) {
//
}
}
示例6: loadEmbeddedBase64ImageResource
import org.xhtmlrenderer.util.ImageUtil; //导入依赖的package包/类
public static ImageResource loadEmbeddedBase64ImageResource(final String uri) {
BufferedImage bufferedImage = ImageUtil.loadEmbeddedBase64Image(uri);
if (bufferedImage != null) {
FSImage image = AWTFSImage.createImage(bufferedImage);
return new ImageResource(null, image);
} else {
return new ImageResource(null, null);
}
}
示例7: createImageResource
import org.xhtmlrenderer.util.ImageUtil; //导入依赖的package包/类
public static ImageResource createImageResource(final String uri, final BufferedImage img) {
if (img == null) {
return new ImageResource(uri, AWTFSImage.createImage(ImageUtil.createTransparentImage(10, 10)));
} else {
return new ImageResource(uri, AWTFSImage.createImage(ImageUtil.makeCompatible(img)));
}
}