code: public static void changeAlpha(InputStream srcInput, OutputStream destOutput, byte alpha,
                                     AlphaFilter filter) throws IOException {
          //加载图片
          log.debug("开始加载图片");
          BufferedImage old = ImageIO.read(srcInput);
          log.debug("图片加载完毕，开始改变图片的alpha值");
  
          //使用32位深带alpha通道模式
          BufferedImage bufferedImage = new BufferedImage(old.getWidth(), old.getHeight(),
              BufferedImage.TYPE_4BYTE_ABGR);
  
          if (filter == null) {
              filter = (x, y, rgb) -> true;
          }
  
          // 循环每一个像素点，改变像素点的Alpha值
          for (int x = 0; x < bufferedImage.getWidth(); x++) {
              for (int y = 0; y < bufferedImage.getHeight(); y++) {
                  int rgb = old.getRGB(x, y);
                  if (filter.filter(x, y, rgb)) {
                      //设置alpha值
                      rgb = (alpha << 24) | (rgb & 0x00ffffff);
                  }
                  bufferedImage.setRGB(x, y, rgb);
              }
          }
          log.debug("图片aphasia值更改完毕");
          // 生成图片为PNG
          ImageIO.write(bufferedImage, "png", destOutput);
      }
docs: 更改alpha值
  
  @param srcInput   图像输入
  @param destOutput 图像输出
  @param alpha      要设置的alpha值
  @param filter     alpha filter
  @throws IOException IOException