java 图片竖排_在JAVA里如何将三张同样的图片做成一张竖排的?

展开全部

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自己写就好了啊。只是路径而已。

4bf2e94b4ecb0e0a9101ca3362b78902.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值