[Java 2D] problème de composition d'images
Bonjour !
J'ai une classe Java qui créer une image jpeg à partir de la superposition d'images png. J'utilise la classe ImageIO et le problème est que j'obtiens en sortie une image noire. De plus, si j'essaye de créer une image png, la composition est égale à la dernière image superposée.
Pour info, ma JVM est la JDK 1.5.
Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| /* buffered image destination */
public BufferedImage biDest;
/* tableau des buffered image sources créés à partir d'images png */
private BufferedImage[] biSrc;
public void composeImage(HttpServletRequest request) {
int heightInt = (new Integer(this.height)).intValue();
int widthInt = (new Integer(this.width)).intValue();
this.biDest = new BufferedImage(widthInt, heightInt, BufferedImage.TYPE_INT_ARGB);
int[] rgbs = new int[widthInt*heightInt];
for(int i=0;i<this.biSrc.length;i++) {
this.biSrc[i].getRGB(0, 0, widthInt, heightInt, rgbs, 0, widthInt);
this.biDest.setRGB(0, 0, widthInt, heightInt, rgbs, 0, widthInt);
}
try {
File destFile = new File(request.getRealPath("/temp/image.png"));
ImageIO.write(this.biDest, "png", destFile);
}
catch (Exception e) {
e.printStackTrace();
}
} |