Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Updated javadocs for warning on target encoding format potential errors.

lucfc3294382e8d
diff --git a/source/net/yacy/peers/graphics/EncodedImage.java b/source/net/yacy/peers/graphics/EncodedImage.java
index 43f212396..ac4afbf82 100644
--- a/source/net/yacy/peers/graphics/EncodedImage.java
+++ b/source/net/yacy/peers/graphics/EncodedImage.java
@@ -35,7 +35,8 @@ public class EncodedImage {
private boolean isStatic;
/**
- * set an encoded image; prefer this over methods with Image-source objects because png generation is faster when done from RasterPlotter sources
+ * set an encoded image; prefer this over methods with Image-source objects because png generation is faster when done from RasterPlotter sources.
+ * Image ByteBuffer will be empty when encoding format is not supported.
* @param sourceImage the image
* @param targetExt the target extension of the image when converted into a file
* @param isStatic shall be true if the image will never change, false if not
@@ -47,7 +48,7 @@ public class EncodedImage {
}
/**
- * set an encoded image from a buffered image
+ * set an encoded image from a buffered image. Image ByteBuffer will be empty when encoding format is not supported.
* @param sourceImage the image
* @param targetExt the target extension of the image when converted into a file
* @param isStatic shall be true if the image will never change, false if not
@@ -60,7 +61,7 @@ public class EncodedImage {
}
/**
- * set an encoded image from a buffered image
+ * set an encoded image from a buffered image. Image ByteBuffer will be empty when encoding format is not supported.
* @param sourceImage the image
* @param targetExt the target extension of the image when converted into a file
* @param isStatic shall be true if the image will never change, false if not
@@ -101,7 +102,7 @@ public class EncodedImage {
}
/**
- * get the encoded image
+ * get the encoded image data (empty when encoding format is not supported)
* @return the bytes of the image encoded into the target extension format
*/
public ByteBuffer getImage() {
diff --git a/source/net/yacy/visualization/RasterPlotter.java b/source/net/yacy/visualization/RasterPlotter.java
index 9ccae13e8..2134188bc 100644
--- a/source/net/yacy/visualization/RasterPlotter.java
+++ b/source/net/yacy/visualization/RasterPlotter.java
@@ -906,11 +906,18 @@ public class RasterPlotter {
return dest;
}
+ /**
+ * Encode buffered image using specified format to a new ByteBuffer
+ * @param image image to encode
+ * @param targetExt format name. For example "png".
+ * @return a ByteBuffer instance containing encoded data, or empty if an error occured or target format is not supported.
+ */
public static ByteBuffer exportImage(final BufferedImage image, final String targetExt) {
// generate an byte array from the given image
final ByteBuffer baos = new ByteBuffer();
ImageIO.setUseCache(false); // because we write into ram here
try {
+ /* When no ImageIO writer is found image might no be written*/
ImageIO.write(image, targetExt, baos);
return baos;
} catch (final IOException e) {