当前位置: 首页>>代码示例>>Java>>正文


Java ImageTypeEnum.GIF属性代码示例

本文整理汇总了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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:24,代码来源:JRTypeSniffer.java

示例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();
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:24,代码来源:AFileResourcePageContent.java

示例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;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:24,代码来源:ImageExporter.java

示例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);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:34,代码来源:JRAbstractImageEncoder.java

示例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());
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:46,代码来源:JRAbstractSvgRenderer.java


注:本文中的net.sf.jasperreports.engine.type.ImageTypeEnum.GIF属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。