public static bool LoadFromFile(string path, out Printscreen printscreen) { printscreen = null; try { IFormatter formatter = new BinaryFormatter(); using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) printscreen = formatter.Deserialize(stream) as Printscreen; } catch (Exception ex) { MessageBox.Show(string.Format("Unable to load {0}!\nError: {1}", Path.GetFileNameWithoutExtension(path), ex.Message)); File.Delete(path); File.Delete(path.Replace(".qImg", "")); return(false); } return(printscreen != null); }
public static bool LoadFromFile(string path, out Printscreen printscreen) { printscreen = null; try { IFormatter formatter = new BinaryFormatter(); using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) printscreen = formatter.Deserialize(stream) as Printscreen; } catch (Exception ex) { MessageBox.Show(string.Format("Unable to load {0}!\nError: {1}", Path.GetFileNameWithoutExtension(path), ex.Message)); File.Delete(path); File.Delete(path.Replace(".qImg", "")); return false; } return printscreen != null; }
private static Printscreen Capture(Image img, string process) { Printscreen printscreen = new Printscreen(); switch (Options.Type) { case Options.ImageType.PNG: img.Save(printscreen.filePath, ImageFormat.Png); break; case Options.ImageType.JPEG: SaveJPEG(printscreen.filePath, img); break; } printscreen.Resolution = string.Format("{0}x{1}", img.Width, img.Height); printscreen.Size = BytesToString(new FileInfo(printscreen.filePath).Length); printscreen.Thumb = img.GetThumbnailImage(200, 112, null, IntPtr.Zero); printscreen.Process = process; printscreen.Save(); return printscreen; }
private static Printscreen Capture(Image img, string process) { Printscreen printscreen = new Printscreen(); switch (Options.Type) { case Options.ImageType.PNG: img.Save(printscreen.filePath, ImageFormat.Png); break; case Options.ImageType.JPEG: SaveJPEG(printscreen.filePath, img); break; } printscreen.Resolution = string.Format("{0}x{1}", img.Width, img.Height); printscreen.Size = BytesToString(new FileInfo(printscreen.filePath).Length); printscreen.Thumb = img.GetThumbnailImage(200, 112, null, IntPtr.Zero); printscreen.Process = process; printscreen.Save(); return(printscreen); }