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


Java GifEncoder类代码示例

本文整理汇总了Java中com.cburch.logisim.util.GifEncoder的典型用法代码示例。如果您正苦于以下问题:Java GifEncoder类的具体用法?Java GifEncoder怎么用?Java GifEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GifEncoder类属于com.cburch.logisim.util包,在下文中一共展示了GifEncoder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: export

import com.cburch.logisim.util.GifEncoder; //导入依赖的package包/类
private void export(Circuit circuit) {
	Bounds bds = circuit.getBounds(canvas.getGraphics()).expand(
			BORDER_SIZE);
	int width = (int) Math.round(bds.getWidth() * scale);
	int height = (int) Math.round(bds.getHeight() * scale);
	BufferedImage img = new BufferedImage(width, height,
			BufferedImage.TYPE_INT_RGB);
	Graphics base = img.getGraphics();
	Graphics g = base.create();
	g.setColor(Color.white);
	g.fillRect(0, 0, width, height);
	g.setColor(Color.black);
	if (g instanceof Graphics2D) {
		((Graphics2D) g).scale(scale, scale);
		((Graphics2D) g).translate(-bds.getX(), -bds.getY());
	} else {
		JOptionPane.showMessageDialog(frame,
				Strings.get("couldNotCreateImage"));
		monitor.close();
	}

	CircuitState circuitState = canvas.getProject().getCircuitState(
			circuit);
	ComponentDrawContext context = new ComponentDrawContext(canvas,
			circuit, circuitState, base, g, printerView);
	circuit.draw(context, null);

	File where;
	if (dest.isDirectory()) {
		where = new File(dest, circuit.getName() + filter.extensions[0]);
	} else if (filter.accept(dest)) {
		where = dest;
	} else {
		String newName = dest.getName() + filter.extensions[0];
		where = new File(dest.getParentFile(), newName);
	}
	try {
		switch (filter.type) {
		case FORMAT_GIF:
			GifEncoder.toFile(img, where, monitor);
			break;
		case FORMAT_PNG:
			ImageIO.write(img, "PNG", where);
			break;
		case FORMAT_JPG:
			ImageIO.write(img, "JPEG", where);
			break;
		}
	} catch (Exception e) {
		JOptionPane.showMessageDialog(frame,
				Strings.get("couldNotCreateFile"));
		monitor.close();
		return;
	}
	g.dispose();
	monitor.close();
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:58,代码来源:ExportImage.java

示例2: export

import com.cburch.logisim.util.GifEncoder; //导入依赖的package包/类
private void export(Circuit circuit) {
	Bounds bds = circuit.getBounds(canvas.getGraphics())
		.expand(BORDER_SIZE);
	int width = (int) Math.round(bds.getWidth() * scale);
	int height = (int) Math.round(bds.getHeight() * scale);
	BufferedImage img = new BufferedImage(width, height,
			BufferedImage.TYPE_INT_RGB);
	Graphics base = img.getGraphics();
	Graphics g = base.create();
	g.setColor(Color.white);
	g.fillRect(0, 0, width, height);
	g.setColor(Color.black);
	if (g instanceof Graphics2D) {
		((Graphics2D) g).scale(scale, scale);
		((Graphics2D) g).translate(-bds.getX(), -bds.getY());
	} else {
		JOptionPane.showMessageDialog(frame,
				Strings.get("couldNotCreateImage"));
		monitor.close();
	}

	CircuitState circuitState = canvas.getProject().getCircuitState(circuit);
	ComponentDrawContext context = new ComponentDrawContext(canvas,
			circuit, circuitState, base, g, printerView);
	circuit.draw(context, null);

	File where;
	if (dest.isDirectory()) {
		where = new File(dest, circuit.getName() + filter.extensions[0]);
	} else if (filter.accept(dest)) {
		where = dest;
	} else {
		String newName = dest.getName() + filter.extensions[0];
		where = new File(dest.getParentFile(), newName);
	}
	try {
		switch (filter.type) {
		case FORMAT_GIF: GifEncoder.toFile(img, where, monitor); break;
		case FORMAT_PNG: ImageIO.write(img, "PNG", where); break;
		case FORMAT_JPG: ImageIO.write(img, "JPEG", where); break;
		}
	} catch (Exception e) {
		JOptionPane.showMessageDialog(frame,
				Strings.get("couldNotCreateFile"));
		monitor.close();
		return;
	}
	g.dispose();
	monitor.close();
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:51,代码来源:ExportImage.java


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