Converting transparent gif / png to jpeg using java

前端 未结 7 800
南笙
南笙 2020-11-29 02:27

I\'d like to convert gif images to jpeg using Java. It works great for most images, but I have a simple transparent gif image:

Input gif image http://img292.imagesha

相关标签:
7条回答
  • 2020-11-29 03:06

    For Java 6 (and 5 too, I think):

    BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
    g = bufferedImage.createGraphics();
    //Color.WHITE estes the background to white. You can use any other color
    g.drawImage(image, 0, 0, bufferedImage.getWidth(), bufferedImage.getHeight(), Color.WHITE, null);
    
    0 讨论(0)
提交回复
热议问题