The ImageIO class can be used to write an image as a JPEG encoded stream.If you write that stream to a ByteArrayOutputStream then you will end up with a byte array that contains the JPEG encoded image.
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(image, "JPEG", out);
byte[] imageBytes = out.toByteArray();
written by objects
\\ tags: image, jpeg, stream
The ImageIO class provides a number of methods for reading images from different sources.
URL imageUrl = new URL("http://www.objects.com.au/logo.jpg");
BufferedImage image = ImageIO.read(imageUrl);
written by objects
\\ tags: image, url
The ImageIO class provides a number of methods for reading images from different sources.
// Get the input stream to read the image from
// NB. getImageStream() is an arbitrary method
// thats returns the input stream to read the
// image from
InputStream in = getImageStream();
// load the image from the stream
BufferedImage image = ImageIO.read(in);
written by objects
\\ tags: image, stream
Recent Comments