Here is my snippet. My original array is a[3][][]
and the rgb values are stored in there I want to create a new image from them. The last line of the following code results in symbol not found.
BufferedImage img=newBufferedImage(bi.getWidth(),bi.getHeight(),BufferedImage.TYPE_INT_RGB);
for(int r=0; r<bi.getHeight(); r++)
for(int c=0; c<bi.getWidth(); c++)
{
int red=a[0][r][c];
int green=a[1][r][c];
int blue=a[2][r][c];
int rgb = (red << 16) | (green << 8) | blue;
img.setRGB(c, r, rgb);
}
ImageIO.write(img,"jpg", "abc.jpg");
Any suggestions?
You are passing the wrong arguments to ImageIO.write()
. From the docs , here are the 3 possibilities:
write(RenderedImage im, String formatName, File output)
write(RenderedImage im, String formatName, ImageOutputStream output)
write(RenderedImage im, String formatName, OutputStream output)
If you want to write the image to a file called abc.jpg
, maybe try:
ImageIO.write(img, "jpg", new File("abc.jpg");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.