0
2次元カラーリストを実際のイメージに変換してエクスポートしようとしていますが、使用しようとすると色が歪みます)javafx2からイメージを作成するbufferImageを使用して2dカラーリストを作成する
import javafx.scene.paint.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.imageio.ImageIO;
public class ImageAction {
public static void fromColorGrid(List<List<Color>> colorGrid) {
int width = colorGrid.size();
int height = colorGrid.get(0).size();
BufferedImage buffImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// Set each pixel of the BufferedImage to the color from the Color[][].
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
String colorStr = colorGrid.get(x).get(y).toString().replace("0x", "");
int rgb = Integer.parseInt(colorStr, 16);
System.out.println(colorStr + " " + rgb);
buffImage.setRGB(x, y, rgb);
}
}
try {
File outputfile = new File("saved.png");
ImageIO.write(buffImage, "png", outputfile);
} catch (IOException e) {
System.out.println("Ups");
}
}
}
どこが間違っていますか?