Czy istnieje sposób na utworzenie jednego obrazu Gif z wielu obrazów w Javie? [zamknięte]

Próbuję skonfigurować prosty program Java, który tworzy jeden animowany gif z wielu innych obrazów (jpg). Czy ktoś może mi podać jak to osiągnąć w Javie? Już przeszukałem Google, ale nie mogłem znaleźć niczego naprawdę pomocnego.

Dziękuję wam!

Author: Freek de Bruijn, 2013-05-20

1 answers

Tutaj masz przykład klasy, która tworzy animowany gif z różnych obrazów:

Link

Klasa udostępnia następujące metody:

class GifSequenceWriter {
    public GifSequenceWriter(
        ImageOutputStream outputStream,
        int imageType,
        int timeBetweenFramesMS,
        boolean loopContinuously);

    public void writeToSequence(RenderedImage img);

    public void close();
}

I jeszcze mały przykład:

public static void main(String[] args) throws Exception {
  if (args.length > 1) {
    // grab the output image type from the first image in the sequence
    BufferedImage firstImage = ImageIO.read(new File(args[0]));

    // create a new BufferedOutputStream with the last argument
    ImageOutputStream output = 
      new FileImageOutputStream(new File(args[args.length - 1]));

    // create a gif sequence with the type of the first image, 1 second
    // between frames, which loops continuously
    GifSequenceWriter writer = 
      new GifSequenceWriter(output, firstImage.getType(), 1, false);

    // write out the first image to our sequence...
    writer.writeToSequence(firstImage);
    for(int i=1; i<args.length-1; i++) {
      BufferedImage nextImage = ImageIO.read(new File(args[i]));
      writer.writeToSequence(nextImage);
    }

    writer.close();
    output.close();
  } else {
    System.out.println(
      "Usage: java GifSequenceWriter [list of gif files] [output file]");
  }
}
 27
Author: Asier Aranbarri,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-07-23 10:10:25