Exemplo n.º 1
0
 // Use the first argument for the output filename,
 // after that all the images to use in the animation.
 static void Main(string[] args)
 {
     if (args.Length > 2)
     {
         using (var output = File.Create(args[0]))
         {
             int x = 0, y = 0;
             using (Image firstImage = Image.FromFile(args[1]))
             {
                 x = firstImage.Width;
                 y = firstImage.Height;
             }
             using (CMK.AnimatedPngCreator creator = new CMK.AnimatedPngCreator(output, x, y))
             {
                 var imagePaths = args.Skip(1);
                 foreach (var imagePath in imagePaths)
                 {
                     using (Image image = Image.FromFile(imagePath))
                     {
                         creator.WriteFrame(image, 1000);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an APNG.
        /// </summary>
        /// <param name="outputFilePath">File path for the output file.</param>
        /// <param name="frames">Images and delays to combine to a apng.</param>
        /// <param name="config">Configuration.</param>
        /// <param name="repeat">Count to repeat the animation. 0 means infinit.</param>
        public static void Create(string outputFilePath, IEnumerable <AnimatedPng.Frame> frames, int repeat = 0, Config config = null)
        {
            var xMax = frames.Max(x => x.Image.Width);
            var yMax = frames.Max(x => x.Image.Height);

            using (var outpufFile = File.Create(outputFilePath))
            {
                using (var creator = new AnimatedPngCreator(outpufFile, xMax, yMax, config, 500, repeat))
                {
                    foreach (var image in frames)
                    {
                        creator.WriteFrame(image.Image, image.Delay);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an APNG.
        /// </summary>
        /// <param name="outputFilePath">File path for the output file.</param>
        /// <param name="images">Images to combine to a apng.</param>
        /// <param name="frameDelay">Frame delay for all images.</param>
        /// <param name="config">Configuration.</param>
        /// <param name="repeat">Count to repeat the animation. 0 means infinit.</param>
        public static void Create(string outputFilePath, IEnumerable <Image> images, short frameDelay, int repeat = 0, Config config = null)
        {
            var xMax = images.Max(x => x.Width);
            var yMax = images.Max(x => x.Height);

            using (var outpufFile = File.Create(outputFilePath))
            {
                using (var creator = new AnimatedPngCreator(outpufFile, xMax, yMax, config, frameDelay, repeat))
                {
                    foreach (var image in images)
                    {
                        creator.WriteFrame(image, frameDelay);
                    }
                }
            }
        }