Пример #1
0
        bool TryAddFrame(CGImageDestination dest, int frame)
        {
            try
            {
                var corrupted = imageSource != null && imageSource.GetPropertiesSafe(frame) == null;
                if (frame != currentFrame && imageSource != null && !corrupted)
                {
                    InitializeImageFrame(frame);
                }

                if (!corrupted)
                {
                    dest.AddImage(NativeCGImage, (NSDictionary)null);
                }

                return(true);
            }
            catch (Exception e)
            {
                Debug.Assert(false, "Failed adding destination: " + e.ToString());
                return(false);
            }
        }
Пример #2
0
        private void Save(CGImageDestination dest)
        {
            if (NativeCGImage == null)
            {
                throw new ObjectDisposedException("cgimage");
            }

            int framesSaved = 0;
            int savedFrame  = currentFrame;

            for (int frame = 0; frame < frameCount; frame++)
            {
                var corrupted = imageSource != null && imageSource.GetPropertiesSafe(frame) == null;
                if (frame != currentFrame && imageSource != null && !corrupted)
                {
                    InitializeImageFrame(frame);
                }

                if (!corrupted)
                {
                    dest.AddImage(NativeCGImage, (NSDictionary)null);
                    ++framesSaved;
                }
            }
            if (currentFrame != savedFrame)
            {
                InitializeImageFrame(savedFrame);
            }

            if (framesSaved == 0)
            {
                throw new ArgumentException("no frame could be saved");
            }

            dest.Close();
        }