本文整理汇总了Java中net.sf.jasperreports.engine.type.ImageTypeEnum.GIF属性的典型用法代码示例。如果您正苦于以下问题:Java ImageTypeEnum.GIF属性的具体用法?Java ImageTypeEnum.GIF怎么用?Java ImageTypeEnum.GIF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.sf.jasperreports.engine.type.ImageTypeEnum
的用法示例。
在下文中一共展示了ImageTypeEnum.GIF属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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();
}
}
示例3: 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;
}
示例4: encode
@Override
public byte[] encode(Image image, ImageTypeEnum imageType) throws JRException
{
BufferedImage bi = null;
if (image instanceof BufferedImage)
{
bi = (BufferedImage)image;
}
else
{
bi =
new BufferedImage(
image.getWidth(null),
image.getHeight(null),
// avoid creating JPEG images with transparency that would result
// in invalid image files for some viewers (browsers)
(imageType == ImageTypeEnum.GIF || imageType == ImageTypeEnum.PNG)
? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB
);
Graphics g = bi.createGraphics();
try
{
g.drawImage(image, 0, 0, null);
}
finally
{
g.dispose();
}
}
return encode(bi, imageType);
}
示例5: getImageData
@Override
public byte[] getImageData(JasperReportsContext jasperReportsContext) throws JRException
{
Dimension2D dimension = getDimension(jasperReportsContext);
if (dimension == null)
{
throw
new JRException(
EXCEPTION_MESSAGE_KEY_DIMENSION_NULL_NOT_ALLOWED,
(Object[])null
);
}
int dpi = getImageDataDPI(jasperReportsContext);
double scale = dpi/72d;
ImageTypeEnum imageType = getImageTypeValue();
BufferedImage bi =
new BufferedImage(
(int) (scale * dimension.getWidth()),
(int) (scale * dimension.getHeight()),
// avoid creating JPEG images with transparency that would result
// in invalid image files for some viewers (browsers)
(imageType == ImageTypeEnum.GIF || imageType == ImageTypeEnum.PNG)
? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB
);
Graphics2D g = createGraphics(bi);
try
{
g.scale(scale, scale);
Color backcolor = getBackcolor();
if (backcolor != null)
{
g.setColor(backcolor);
g.fillRect(0, 0, (int)dimension.getWidth(), (int)dimension.getHeight());
}
render(jasperReportsContext, g, new Rectangle((int)dimension.getWidth(), (int)dimension.getHeight()));
}
finally
{
g.dispose();
}
return JRImageLoader.getInstance(jasperReportsContext).loadBytesFromAwtImage(bi, getImageTypeValue());
}