K
Kurt M Peters
When I try to use the code below on a machine the software was developed on,
the code cannot find the following file (which should be a "standard" java
color profile in the local cmm directory. Does anyone have a clue what I'm
doing wrong?
Regards,
Kurt
::::::::::::::: Code to save JPEG ::::::::::::::::::::::
public void writejpeg(BufferedImage outIm) {//BufferedImage bi) {
if (outIm == null) {
JOptionPane.showMessageDialog(this, "Cannot write file.\nThere
is no image to save.","File Write Problem",JOptionPane.WARNING_MESSAGE);
return;
}
jFCchooser.setDialogTitle("Save Image");
ImageOutputStream ios = null;
int returnVal = jFCchooser.showSaveDialog(this);
Iterator writers = ImageIO.getImageWritersByFormatName("jpg");
ImageWriter writer = (ImageWriter)writers.next();
ImageWriteParam param = writer.getDefaultWriteParam();
Float quality = new Float(1.0);
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionQuality(1.0f);
// ImageIO.write(myImage, "jpg", imageFile);
if(returnVal == JFileChooser.APPROVE_OPTION) {
IIOParamController controller = param.getController();
if (controller != null) {
controller.activate(param);
}
try {
ios =
ImageIO.createImageOutputStream(jFCchooser.getSelectedFile());
} catch (IllegalArgumentException ia){
System.err.println("IllegalArgumentException - if output is
null. ");
} catch (IOException IOe) {
System.err.println("a cache file is needed but cannot be
created.");
}
writer.setOutput(ios);
try {
writer.write(null, new IIOImage(outIm,null,null), param);
} catch (IllegalStateException IE) {
System.err.println("The output has not been set.");
} catch (IllegalArgumentException IAE){
System.err.println("Image is null.");
} catch (IOException IOe){
System.err.println("An error occured during writing.");
}
writer.dispose();
try {
ios.close();
} catch (IOException e){
}
}
}
the code cannot find the following file (which should be a "standard" java
color profile in the local cmm directory. Does anyone have a clue what I'm
doing wrong?
Regards,
Kurt
::::::::::::::: Code to save JPEG ::::::::::::::::::::::
public void writejpeg(BufferedImage outIm) {//BufferedImage bi) {
if (outIm == null) {
JOptionPane.showMessageDialog(this, "Cannot write file.\nThere
is no image to save.","File Write Problem",JOptionPane.WARNING_MESSAGE);
return;
}
jFCchooser.setDialogTitle("Save Image");
ImageOutputStream ios = null;
int returnVal = jFCchooser.showSaveDialog(this);
Iterator writers = ImageIO.getImageWritersByFormatName("jpg");
ImageWriter writer = (ImageWriter)writers.next();
ImageWriteParam param = writer.getDefaultWriteParam();
Float quality = new Float(1.0);
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionQuality(1.0f);
// ImageIO.write(myImage, "jpg", imageFile);
if(returnVal == JFileChooser.APPROVE_OPTION) {
IIOParamController controller = param.getController();
if (controller != null) {
controller.activate(param);
}
try {
ios =
ImageIO.createImageOutputStream(jFCchooser.getSelectedFile());
} catch (IllegalArgumentException ia){
System.err.println("IllegalArgumentException - if output is
null. ");
} catch (IOException IOe) {
System.err.println("a cache file is needed but cannot be
created.");
}
writer.setOutput(ios);
try {
writer.write(null, new IIOImage(outIm,null,null), param);
} catch (IllegalStateException IE) {
System.err.println("The output has not been set.");
} catch (IllegalArgumentException IAE){
System.err.println("Image is null.");
} catch (IOException IOe){
System.err.println("An error occured during writing.");
}
writer.dispose();
try {
ios.close();
} catch (IOException e){
}
}
}