How to resize an animated gif image using C#?

Took me a while to find this, but finally found a solution: Install Magick.NET via NuGet, license can be found here: https://magick.codeplex.com/license Example code: var newWidth = 100; using (var collection = new MagickImageCollection(new FileInfo(@”C:\test.gif”))) { collection.Coalesce(); foreach (var image in collection) { image.Resize(newWidth, 0); } collection.Write(@”c:\resized.gif”); } From my tests, this works with alpha … Read more

Can a PictureBox show animated GIF in Windows Application?

Put a PictureBox on a form and then specify a picture file with a Gif extension. Or: Programatically animate a gif Image loading frames into a PictureBox with code, here’s the Gif class: VB.NET Imports System.Drawing.Imaging Imports System.Drawing Public Class GifImage Private gifImage As Image Private dimension As FrameDimension Private frameCount As Integer Private currentFrame … Read more

.gif image doesn’t moves on adding it to the JTabbed pane

Let me demonstrate the hole you are digging yourself into You could do… BufferedImage img = ImageIO.read(this.getClass().getResource(“anigif.gif”)); ImageIcon icon = new ImageIcon(img); JLabel label = new JLabel(icon); add(label); Or you could do… Now, this is woefully inadequate and is designed for example purposes only. It does not support disposal methods or optimized Gifs…so you can … Read more

Show animated GIF

Using Swing you could simply use a JLabel: public static void main(String[] args) throws MalformedURLException { URL url = new URL(“<url_to_animated_gif>”); Icon icon = new ImageIcon(url); JLabel label = new JLabel(icon); JFrame f = new JFrame(“Animation”); f.getContentPane().add(label); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }