private void InitBlendCache() { m_currentImage?.Dispose(); m_currentGraphics?.Dispose(); m_drawImage?.Dispose(); using (var image = Image.FromFile(m_images[m_index])) m_currentImage = Util.FixedSize(image, pbImage.Width, pbImage.Height, Color.Black); m_drawImage = new Bitmap(m_currentImage.Width, m_currentImage.Height); m_currentGraphics = Graphics.FromImage(m_drawImage); }
private static string CreateThumbnail(IFileData screenshot) { string file = Path.Combine(DataCache.Instance.AppConfiguration.ScreenshotDirectory.GetFullPath(), screenshot.FileName); if (!File.Exists(file)) { return(null); } Image image = Image.FromFile(file); Image thumb = Util.FixedSize(image, GameFileTile.ImageWidth, GameFileTile.ImageHeight, Color.Black); string filename = Guid.NewGuid().ToString() + ".png"; thumb.Save(Path.Combine(DataCache.Instance.AppConfiguration.ThumbnailDirectory.GetFullPath(), filename), ImageFormat.Png); return(filename); }
private void SetImages() { lock (m_pictureBoxes) { List <PictureItem> .Enumerator enumerator = m_pictureBoxes.GetEnumerator(); foreach (var screen in m_screenshots) { enumerator.MoveNext(); if (m_ct.IsCancellationRequested || enumerator.Current == null) { break; } if (enumerator.Current.Skip) { continue; } PictureBox pbScreen = enumerator.Current.PictureBox; string file = Path.Combine(DataDirectory.GetFullPath(), screen.FileName); try { using (var image = Image.FromFile(file)) pbScreen.Image = Util.FixedSize(image, pbScreen.Width, pbScreen.Height, Color.Black); } catch { // Most likely file doesn't exist... // Can also be out of memory exception } enumerator.Current.CurrentFile = screen; } enumerator.MoveNext(); while (enumerator.Current != null) { enumerator.Current.CurrentFile = null; enumerator.MoveNext(); } m_imageWorkerComplete = true; } }