GraphicImportExportpublic class GraphicImportExport extends Object
Fields Summary |
---|
Button | exportButton | Frame | frame | GraphicsImporter | importer | static final int[] | imagetypes |
Constructors Summary |
---|
public GraphicImportExport()
try {
QTSessionCheck.check();
QTFile inFile = QTFile.standardGetFilePreview (imagetypes);
importer = new GraphicsImporter (inFile);
// put image onscreen
QTComponent qtc = QTFactory.makeQTComponent (importer);
java.awt.Component c = qtc.asComponent();
frame = new Frame ("Imported image");
frame.setLayout (new BorderLayout());
frame.add (c, BorderLayout.CENTER);
exportButton = new Button ("Export");
exportButton.addActionListener (new ActionListener() {
public void actionPerformed (ActionEvent ae) {
try {
doExport();
} catch (QTException qte) {
qte.printStackTrace();
}
}
});
frame.add (exportButton, BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
} catch (QTException qte) {
qte.printStackTrace();
}
|
Methods Summary |
---|
public void | doExport()
// build list of GraphicExporters
Vector choices = new Vector();
ComponentDescription cd =
new ComponentDescription (
StdQTConstants.graphicsExporterComponentType);
ComponentIdentifier ci = null;
while ( (ci = ComponentIdentifier.find(ci, cd)) != null) {
choices.add (new ExportChoice (ci.getInfo().getName(),
ci.getInfo().getSubType()));
}
// offer a choice of movie exporters
JComboBox exportCombo = new JComboBox (choices);
JOptionPane.showMessageDialog (frame,
exportCombo,
"Choose exporter",
JOptionPane.PLAIN_MESSAGE);
ExportChoice choice =
(ExportChoice) exportCombo.getSelectedItem();
System.out.println ("chose " + choice.name);
// build a GE, wire up to the GraphicsImporter
GraphicsExporter exporter =
new GraphicsExporter (choice.subtype);
exporter.setInputGraphicsImporter (importer);
// ask for destination, settings
FileDialog fd =
new FileDialog (frame, "Save As",
FileDialog.SAVE);
fd.setVisible(true);
String filename = fd.getFile();
if (filename.indexOf('.") == -1)
filename = filename + "." +
exporter.getDefaultFileNameExtension();
File file = new File (fd.getDirectory(), filename);
exporter.setOutputFile (new QTFile(file));
exporter.requestSettings();
// export
exporter.doExport();
// need to explicitly quit (since awt is running)
System.exit(0);
| public static void | main(java.lang.String[] args)
/* other interesting values:
StdQTConstants.kQTFileTypeGIF,
StdQTConstants.kQTFileTypeJPEG,
StdQTConstants4.kQTFileTypePNG,
StdQTConstants4.kQTFileTypeTIFF
StdQTConstants.kQTFileTypeMacPaint,
StdQTConstants.kQTFileTypePhotoShop,
StdQTConstants.kQTFileTypePICS,
StdQTConstants.kQTFileTypePicture,
*/
new GraphicImportExport();
|
|