Exemplo n.º 1
0
        internal Animation(SmartImage Smart_Image, int AnimationToCopy, int DegreesOfRotation)
        {
            //We create a new animation number for this new animation
            AnimationID = Smart_Image.AnimationCount;

            GraphicsUnit tUnit = GraphicsUnit.Pixel;
            Animation    One   = Smart_Image.getAnimation(AnimationToCopy);
            Image        MeImage;

            for (int i = 0; i < One.Frames.Count; i++)
            {
                AnimationFrame       AF  = Smart_Image.GetAnimationFrame(AnimationToCopy, i);
                AnimationSingleFrame ASF = Smart_Image.GetSingleFrame(AnimationToCopy, i);
                MeImage = ASF.Frame;
                TimeSpan Duration     = AF.Duration;
                Image    rotatedImage = new Bitmap(MeImage.Width, MeImage.Height);
                using (Graphics g = Graphics.FromImage(rotatedImage))
                {
                    g.TranslateTransform(MeImage.Width / 2, MeImage.Height / 2);                                  //set the rotation point as the center into the matrix
                    g.RotateTransform(DegreesOfRotation * -1);                                                    //rotate.  The rotation direction we use is opposite of what they use
                    g.TranslateTransform(-MeImage.Width / 2, -MeImage.Height / 2);                                //restore rotation point into the matrix
                    g.DrawImage(MeImage, MeImage.GetBounds(ref tUnit), rotatedImage.GetBounds(ref tUnit), tUnit); //draw the image on the new bitmap
                }
                //GC.Collect();
                MeImage = rotatedImage;

                AnimationSingleFrame newSingle = new AnimationSingleFrame(MeImage, Smart_Image.FrameCount);
                AnimationFrame       newFrame  = new AnimationFrame(Smart_Image.FrameCount, Duration);
                Frames.Add(newFrame);
                Smart_Image.AddFrame(newSingle);
            }
        }
Exemplo n.º 2
0
        internal Animation(SmartImage Smart_Image, int AnimationToCopy, bool MirrorHorizontally, bool MirrorVertically)
        {
            //We create a new animation number for this new animation
            AnimationID = Smart_Image.AnimationCount;

            Animation One = Smart_Image.getAnimation(AnimationToCopy);
            Image     MeImage;

            for (int i = 0; i < One.Frames.Count; i++)
            {
                AnimationFrame       AF  = Smart_Image.GetAnimationFrame(AnimationToCopy, i);
                AnimationSingleFrame ASF = Smart_Image.GetSingleFrame(AnimationToCopy, i);
                MeImage = ASF.Frame;
                TimeSpan Duration    = AF.Duration;
                Image    MirrorImage = new Bitmap(MeImage);
                if (MirrorHorizontally)
                {
                    MirrorImage.RotateFlip(RotateFlipType.RotateNoneFlipX);
                }
                if (MirrorVertically)
                {
                    MirrorImage.RotateFlip(RotateFlipType.RotateNoneFlipY);
                }
                //GC.Collect();
                MeImage = MirrorImage;

                AnimationSingleFrame newSingle = new AnimationSingleFrame(MeImage, Smart_Image.FrameCount);
                AnimationFrame       newFrame  = new AnimationFrame(Smart_Image.FrameCount, Duration);
                Frames.Add(newFrame);
                Smart_Image.AddFrame(newSingle);
            }
        }