[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[udig-devel] [jira] Created: (UDIG-1443) Corrupt images using Export to Image Wizard
|
Corrupt images using Export to Image Wizard
-------------------------------------------
Key: UDIG-1443
URL: http://jira.codehaus.org/browse/UDIG-1443
Project: uDIG
Issue Type: Bug
Components: image
Affects Versions: UDIG 1.2.M0
Reporter: Jody Garnett
Assignee: Jesse Eichar
The Export Map to Image wizard got a couple of fixes for the uDig 1.1.0 stream; when I went to update the code on trunk I found that structure of the code was different - rather than a single ImageExportPage.write(BufferedIMage,File) method that does everything ...
there are a bunch of Helper Classes.
I have ported the solution (namely skipping over ImageWriters that are not "standard") to the WorldImageExportFormat utility class.
{code}
//ImageIO.write(image, getName(), destination);
ImageOutputStream stream = null;
try {
destination.delete();
stream = ImageIO.createImageOutputStream(destination);
} catch (IOException e) {
throw new IIOException("Can't create output stream!", e);
}
try {
ImageWriter writer = null;
ImageTypeSpecifier type = ImageTypeSpecifier.createFromRenderedImage(image);
Iterator<ImageWriter> iter = ImageIO.getImageWriters(type, formatName);
while (iter.hasNext()) {
writer = (ImageWriter) iter.next();
String description = writer.getOriginatingProvider().getDescription(null);
if( !description.contains("Standard") ){
break;
}
}
if (writer == null) {
throw new IOException("Could not find writer for this image in " + formatName);
}
writer.setOutput(stream);
try {
writer.write(image);
} finally {
writer.dispose();
stream.flush();
}
} finally {
stream.close();
}
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira