本文整理汇总了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();
}
示例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();
}