给上传图片加个图片水印,文字水印的功能1

  1. import java.awt.Color;   
  2. import java.awt.Graphics2D;   
  3. import java.awt.image.BufferedImage;   
  4.   
  5. public class TwoGif {   
  6.     public static void main(String[] args) {   
  7.         String mainGif = args[0];   
  8.         String secondGif = args[1];   
  9.         int xPosition = Integer.valueOf(args[2]);   
  10.         int yPosition = Integer.valueOf(args[3]);   
  11.         String outputGif = args[4];   
  12.   
  13.         GifDecoder mainDecoder = new GifDecoder();   
  14.         mainDecoder.read(mainGif);   
  15.         BufferedImage mainFrame = mainDecoder.getFrame(0);   
  16.   
  17.         GifDecoder secondDecoder = new GifDecoder();   
  18.         secondDecoder.read(secondGif);   
  19.         BufferedImage secondFrame = secondDecoder.getFrame(0);   
  20.   
  21.         int flag = secondFrame.getRGB(11);   
  22.         int alpha=new Color(255,0,0,0).getRGB();   
  23.   
  24.         AnimatedGifEncoder e = new AnimatedGifEncoder();   
  25.         e.start(outputGif);   
  26.            
  27.         for (int i = 0; i < secondFrame.getWidth(); i++) {   
  28.             for (int j = 0; j < secondFrame.getHeight(); j++) {   
  29.                 if (secondFrame.getRGB(i, j) == flag) {   
  30.                     secondFrame.setRGB(i, j, alpha);   
  31.                 }   
  32.             }   
  33.         }   
  34.            
  35.         Graphics2D g = mainFrame.createGraphics();   
  36.         g.drawImage(secondFrame, null, xPosition, yPosition);   
  37.         g.dispose();   
  38.   
  39.         e.addFrame(mainFrame);   
  40.         e.finish();   
  41.     }   
  42. }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值