0

I wonder if there is a way in java to put a gif image over png image at particular location (say at particular value of x,y). If so please help me through this.

This is the case :

I have a base Image which is of png type. and I have gif images of size 62*62. I wanted to put several such gif images on png image and I need to render the png image on front end at every 5 seconds..

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Vijay Karchi
  • 13
  • 1
  • 5
  • Essentially yes, I'd recommend having a look at [Reading/Loading an Image](https://docs.oracle.com/javase/tutorial/2d/images/loadimage.html) and [2D Graphics](https://docs.oracle.com/javase/tutorial/2d/) have the core details you will need as well [as a conpetual idea](http://stackoverflow.com/questions/26746732/how-to-blend-two-image/26746827#26746827) – MadProgrammer Apr 19 '17 at 07:03
  • @MadProgrammer - Thanks for the post. I will go through the links. If any doubts I will comment.. – Vijay Karchi Apr 19 '17 at 07:07
  • You are try to extract a particular image from GIF file? – gifpif Apr 19 '17 at 07:28
  • Are the GIFs animated? That adds a level of complexity.. – Andrew Thompson Apr 20 '17 at 05:37

1 Answers1

0

To extract image from GIF file.. This save the first image into png file from GIF.

    try {
        ImageReader reader = ImageIO.getImageReadersByFormatName("gif").next();
        ImageInputStream stream = ImageIO.createImageInputStream(new File("c:/aaa.gif");
        reader.setInput(stream);

        int count = reader.getNumImages(true);
        if(count>0){
            BufferedImage frame = reader.read(0);
            ImageIO.write(frame, "png", new File(filePath+fileName+".png"));
            System.out.println("Donesss");
        }
    } catch (IOException ex) {

    }
gifpif
  • 4,507
  • 4
  • 31
  • 45