本文整理汇总了Java中net.sf.jasperreports.engine.type.ImageTypeEnum.JPEG属性的典型用法代码示例。如果您正苦于以下问题:Java ImageTypeEnum.JPEG属性的具体用法?Java ImageTypeEnum.JPEG怎么用?Java ImageTypeEnum.JPEG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.sf.jasperreports.engine.type.ImageTypeEnum
的用法示例。
在下文中一共展示了ImageTypeEnum.JPEG属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRenderable
/**
*
*/
public Renderable getRenderable(Image img, OnErrorTypeEnum onErrorType) throws JRException
{
ImageTypeEnum type = ImageTypeEnum.JPEG;
if (img instanceof RenderedImage)
{
ColorModel colorModel = ((RenderedImage) img).getColorModel();
//if the image has transparency, encode as PNG
if (colorModel.hasAlpha()
&& colorModel.getTransparency() != Transparency.OPAQUE)
{
type = ImageTypeEnum.PNG;
}
}
return getRenderable(img, type, onErrorType);
}
示例2: getImageTypeValue
/**
*
*/
public static ImageTypeEnum getImageTypeValue(byte[] data)
{
if (JRTypeSniffer.isGIF(data))
{
return ImageTypeEnum.GIF;
}
else if (JRTypeSniffer.isJPEG(data))
{
return ImageTypeEnum.JPEG;
}
else if (JRTypeSniffer.isPNG(data))
{
return ImageTypeEnum.PNG;
}
else if (JRTypeSniffer.isTIFF(data))
{
return ImageTypeEnum.TIFF;
}
return ImageTypeEnum.UNKNOWN;
}
示例3: doSaveFile
protected void doSaveFile(String filename) {
if (filename != null) {
try {
WSClientHelper.getResource(new NullProgressMonitor(), AFileResourcePageContent.this.res, res.getValue(), filename);
File file = new File(filename);
int dotPos = filename.lastIndexOf("."); //$NON-NLS-1$
String strFilename = filename.substring(0, dotPos);
ImageTypeEnum itype = JRTypeSniffer.getImageTypeValue(FileUtils.getBytes(file));
if (itype == ImageTypeEnum.GIF) {
file = FileUtils.fileRenamed(file, strFilename, ".gif"); //$NON-NLS-1$
} else if (itype == ImageTypeEnum.JPEG) {
file = FileUtils.fileRenamed(file, strFilename, ".jpeg"); //$NON-NLS-1$
} else if (itype == ImageTypeEnum.PNG) {
file = FileUtils.fileRenamed(file, strFilename, ".png"); //$NON-NLS-1$
} else if (itype == ImageTypeEnum.TIFF) {
file = FileUtils.fileRenamed(file, strFilename, ".tiff"); //$NON-NLS-1$
}
((AFileResource) res).setFile(file);
} catch (Exception e1) {
UIUtils.showError(e1);
}
handleFileChange();
}
}
示例4: exportToIFile
@Override
public IFile exportToIFile(AFileResource res, ResourceDescriptor rd, String fkeyname, IProgressMonitor monitor) throws Exception {
IFile f = super.exportToIFile(res, rd, fkeyname, monitor);
if (path == null && f != null) {
String filename = f.getFullPath().toOSString();
int dotPos = filename.lastIndexOf(".");
if (dotPos >= 0)
filename = filename.substring(0, dotPos);
ImageTypeEnum itype = JRTypeSniffer.getImageTypeValue(FileUtils.getBytes(f));
if (itype == ImageTypeEnum.UNKNOWN)
itype = ImageTypeEnum.PNG;
if (itype == ImageTypeEnum.GIF) {
f = FileUtils.fileRenamed(f, filename, ".gif", false, monitor);
} else if (itype == ImageTypeEnum.JPEG) {
f = FileUtils.fileRenamed(f, filename, ".jpeg", false, monitor);
} else if (itype == ImageTypeEnum.PNG) {
f = FileUtils.fileRenamed(f, filename, ".png", false, monitor);
} else if (itype == ImageTypeEnum.TIFF) {
f = FileUtils.fileRenamed(f, filename, ".tiff", false, monitor);
}
fileurimap.put(fkeyname, f);
}
return f;
}