예제 #1
0
 public IEnumerable<Image> GetImageEnumerator()
 {
     if (!isWorking && File.Exists(CachePath) && indexList != null && indexList.Count > 0)
     {
         using (FileStream fsCache = new FileStream(CachePath, FileMode.Open, FileAccess.Read, FileShare.Read))
         {
             foreach (LocationInfo index in indexList)
             {
                 using (MemoryStream ms = new MemoryStream())
                 {
                     fsCache.CopyStreamTo(ms, (int)index.Location, (int)index.Length);
                     yield return Image.FromStream(ms);
                 }
             }
         }
     }
 }
예제 #2
0
        public IEnumerable<Image> GetImageEnumerator()
        {
            if (!IsWorking && File.Exists(Options.OutputPath) && indexList != null && indexList.Count > 0)
            {
                using (FileStream fsCache = new FileStream(Options.OutputPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    foreach (LocationInfo index in indexList)
                    {
                        if (index.Location > int.MaxValue || index.Length > int.MaxValue)
                        {
                            MessageBox.Show(string.Format("Cache file size cannot exceed {0} Bytes.\r\nPlease use FFmpeg screen recording instead of GIF.", int.MaxValue), "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            yield break;
                        }

                        using (MemoryStream ms = new MemoryStream())
                        {
                            fsCache.CopyStreamTo(ms, (int)index.Location, (int)index.Length);
                            yield return Image.FromStream(ms);
                        }
                    }
                }
            }
        }
예제 #3
0
 private Stream PrepareDataFromFile(string fp)
 {
     Stream data = null;
     using (var fs = new FileStream(fp, FileMode.Open, FileAccess.Read, FileShare.Read))
     {
         data = new MemoryStream();
         fs.CopyStreamTo(data);
     }
     return data;
 }