- import java.awt.Color;
- import java.awt.Graphics2D;
- import java.awt.image.BufferedImage;
- public class TwoGif {
- public static void main(String[] args) {
- String mainGif = args[0];
- String secondGif = args[1];
- int xPosition = Integer.valueOf(args[2]);
- int yPosition = Integer.valueOf(args[3]);
- String outputGif = args[4];
- GifDecoder mainDecoder = new GifDecoder();
- mainDecoder.read(mainGif);
- BufferedImage mainFrame = mainDecoder.getFrame(0);
- GifDecoder secondDecoder = new GifDecoder();
- secondDecoder.read(secondGif);
- BufferedImage secondFrame = secondDecoder.getFrame(0);
- int flag = secondFrame.getRGB(1, 1);
- int alpha=new Color(255,0,0,0).getRGB();
- AnimatedGifEncoder e = new AnimatedGifEncoder();
- e.start(outputGif);
- for (int i = 0; i < secondFrame.getWidth(); i++) {
- for (int j = 0; j < secondFrame.getHeight(); j++) {
- if (secondFrame.getRGB(i, j) == flag) {
- secondFrame.setRGB(i, j, alpha);
- }
- }
- }
- Graphics2D g = mainFrame.createGraphics();
- g.drawImage(secondFrame, null, xPosition, yPosition);
- g.dispose();
- e.addFrame(mainFrame);
- e.finish();
- }
- }
给上传图片加个图片水印,文字水印的功能1
最新推荐文章于 2024-06-21 11:21:30 发布