我正在使用 drawImage() 将大量面部图像 (face_50xx.png) 粘贴到一个大画布 (Faces.png) 上,
但每张脸都变成了全黑。
这是我的源代码:
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.Color;
public class maa{
static BufferedImage in;
static BufferedImage out;
public static void main(String[] args) {
String A = "face_";
String B = "png";
int j = 0;
try{
in = ImageIO.read(new File(A + 5001 + "." + B));
}
catch(java.io.IOException e){
}
out = new BufferedImage(1920, 14592, in.getType());
for(int i = 1; i < 760; i++){
String num;
j = i + 5000;
num = Integer.toString(j);
try{
in = ImageIO.read(new File("face_" + num + "." + "png"));
Graphics g = in.getGraphics();
g.drawImage(out, (i%10)*192, (i/10)*192, null);
}
catch(java.io.IOException e){
continue;
}
}
try{
ImageIO.write(out,"png",new File("Faces." + B));
}
catch(java.io.IOException e){
}
}
}
请教我有什么问题。谢谢。