varias una presionar poner mostrar manejo insertar imagenes imagen imageio how handling fondo example como codigo clase cargar boton java jpeg gif bufferedimage

una - mostrar varias imagenes en java



¿Hay una manera de crear una imagen Gif de varias imágenes en Java? (1)

Estoy tratando de configurar un programa Java simple que crea un único gif animado a partir de muchas otras imágenes (jpg). ¿Alguien me puede dar un gancho sobre cómo lograr esto en Java? Ya busqué en Google pero no pude encontrar nada realmente útil.

¡Gracias chicos!


Aquí tienes un ejemplo de una clase que crea un gif animado de diferentes imágenes:

Link

La clase proporciona estos métodos:

class GifSequenceWriter { public GifSequenceWriter( ImageOutputStream outputStream, int imageType, int timeBetweenFramesMS, boolean loopContinuously); public void writeToSequence(RenderedImage img); public void close(); }

Y también un pequeño ejemplo:

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]"); } }

Apoyos a Elliot Kroo para este código.