展开全部
package test;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class CompositeImage {
public static void main(String[] args) throws IOException {
String filePath = "D:\\a.jpg";
BufferedImage bimage = ImageIO.read(new File(filePath));
int width = bimage.getWidth();
int height = bimage.getHeight();
int imageNum = 3; //三个汉堡
//不一定是TYPE_INT_RGB,可以看API自己需要哪种格式
BufferedImage outImage = new BufferedImage(width, height * imageNum, BufferedImage.TYPE_INT_RGB);
Graphics g = outImage.getGraphics();
Graphics2D g2d = (Graphics2D) g;
for(int i=0; i
{
g2d.drawImage(bimage, 0, height * i, null);
//需要改变颜色的话在这里绘上颜色。可能会用到AlphaComposite类
}
String outPath = "D:\\b.jpg";
String format = "JPG";
ImageIO.write(outImage, format, new File(outPath));
}
}
不知道我理解的对32313133353236313431303231363533e59b9ee7ad9431333239303933不对。。。
不需要改变颜色的话不就是这个效果吗?FileChooser自己写就好了啊。只是路径而已。