Here are my two implementations. Would both give the same result? I know that BufferedImage
is the child class of the Image.
First implementation:
writeImage
takes anImage
Object and usesRenderedImage
in theImageIO.write
method.public void writeImage(Image img, String outputFile) { try { ImageIO.write((RenderedImage) img, "jpg", new File(outputFile)); } catch (IOException e) { } ...
Second Implementation:
writeImage
takes aBufferedImage`` object and uses the BufferedImage
object in theImageIO.write
method.public void writeImage(BufferedImage img, String outputFile){ try { ImageIO.write(img, "jpg", new File(outputFile)); } catch (IOException e) { } ... ...
Also, try to tell what's the difference between the two ways of writing an image.