More Bitmap usage

This commit is contained in:
Jaex 2020-03-23 22:33:26 +03:00
parent 0137f60a0d
commit 335972455a
19 changed files with 97 additions and 100 deletions

View file

@ -26,7 +26,6 @@
using ShareX.HelpersLib.Properties; using ShareX.HelpersLib.Properties;
using System; using System;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
namespace ShareX.HelpersLib namespace ShareX.HelpersLib
@ -62,15 +61,15 @@ private bool CheckClipboardContents()
if (Clipboard.ContainsImage()) if (Clipboard.ContainsImage())
{ {
using (Image img = ClipboardHelpers.GetImage()) using (Bitmap bmp = ClipboardHelpers.GetImage())
{ {
if (img != null) if (bmp != null)
{ {
ClipboardContentType = EClipboardContentType.Image; ClipboardContentType = EClipboardContentType.Image;
ClipboardContent = img.Clone(); ClipboardContent = bmp.Clone();
pbClipboard.LoadImage(img); pbClipboard.LoadImage(bmp);
pbClipboard.Visible = true; pbClipboard.Visible = true;
lblQuestion.Text = string.Format(Resources.ClipboardContentViewer_ClipboardContentViewer_Load_Clipboard_content__Image__Size___0_x_1__, img.Width, img.Height); lblQuestion.Text = string.Format(Resources.ClipboardContentViewer_ClipboardContentViewer_Load_Clipboard_content__Image__Size___0_x_1__, bmp.Width, bmp.Height);
return true; return true;
} }
} }

View file

@ -25,7 +25,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
namespace ShareX.HelpersLib namespace ShareX.HelpersLib

View file

@ -235,7 +235,7 @@ public static bool CopyTextFromFile(string path)
return false; return false;
} }
public static Image GetImage(bool checkContainsImage = false) public static Bitmap GetImage(bool checkContainsImage = false)
{ {
try try
{ {
@ -243,7 +243,7 @@ public static Image GetImage(bool checkContainsImage = false)
{ {
if (!checkContainsImage || Clipboard.ContainsImage()) if (!checkContainsImage || Clipboard.ContainsImage())
{ {
return Clipboard.GetImage(); return (Bitmap)Clipboard.GetImage();
} }
} }
} }

View file

@ -35,7 +35,7 @@ namespace ShareX.ImageEffectsLib
{ {
public partial class ImageEffectsForm : Form public partial class ImageEffectsForm : Form
{ {
public event Action<Image> ImageProcessRequested; public event Action<Bitmap> ImageProcessRequested;
public bool AutoGeneratePreviewImage { get; set; } public bool AutoGeneratePreviewImage { get; set; }
public Bitmap PreviewImage { get; private set; } public Bitmap PreviewImage { get; private set; }
@ -68,7 +68,7 @@ public ImageEffectsForm(Bitmap bmp, List<ImageEffectPreset> presets, int selecte
AddAllEffectsToContextMenu(); AddAllEffectsToContextMenu();
} }
public void EnableToolMode(Action<Image> imageProcessRequested, string filePath = null) public void EnableToolMode(Action<Bitmap> imageProcessRequested, string filePath = null)
{ {
FilePath = filePath; FilePath = filePath;
ImageProcessRequested += imageProcessRequested; ImageProcessRequested += imageProcessRequested;
@ -84,11 +84,11 @@ public void EditorMode()
btnClose.Text = Resources.ImageEffectsForm_EditorMode_Cancel; btnClose.Text = Resources.ImageEffectsForm_EditorMode_Cancel;
} }
protected void OnImageProcessRequested(Image img) protected void OnImageProcessRequested(Bitmap bmp)
{ {
if (ImageProcessRequested != null) if (ImageProcessRequested != null)
{ {
ImageProcessRequested(img); ImageProcessRequested(bmp);
} }
} }
@ -310,7 +310,7 @@ private void GeneratePreviewImage(int padding)
} }
} }
private Image ApplyEffects() private Bitmap ApplyEffects()
{ {
ImageEffectPreset preset = GetSelectedPreset(); ImageEffectPreset preset = GetSelectedPreset();
@ -614,7 +614,7 @@ private void tsmiLoadImageFromFile_Click(object sender, EventArgs e)
private void tsmiLoadImageFromClipboard_Click(object sender, EventArgs e) private void tsmiLoadImageFromClipboard_Click(object sender, EventArgs e)
{ {
Bitmap bmp = (Bitmap)ClipboardHelpers.GetImage(); Bitmap bmp = ClipboardHelpers.GetImage();
if (bmp != null) if (bmp != null)
{ {
@ -648,11 +648,11 @@ private void btnUploadImage_Click(object sender, EventArgs e)
{ {
if (PreviewImage != null) if (PreviewImage != null)
{ {
Image img = ApplyEffects(); Bitmap bmp = ApplyEffects();
if (img != null) if (bmp != null)
{ {
OnImageProcessRequested(img); OnImageProcessRequested(bmp);
} }
} }
} }

View file

@ -34,7 +34,7 @@ namespace ShareX.MediaLib
{ {
public partial class ImageCombinerForm : Form public partial class ImageCombinerForm : Form
{ {
public event Action<Image> ProcessRequested; public event Action<Bitmap> ProcessRequested;
public ImageCombinerOptions Options { get; private set; } public ImageCombinerOptions Options { get; private set; }
@ -136,7 +136,7 @@ private void btnCombine_Click(object sender, EventArgs e)
if (images.Count > 1) if (images.Count > 1)
{ {
Image output = ImageHelpers.CombineImages(images, Options.Orientation, Options.Space); Bitmap output = ImageHelpers.CombineImages(images, Options.Orientation, Options.Space);
OnProcessRequested(output); OnProcessRequested(output);
} }
@ -162,11 +162,11 @@ private void btnCombine_Click(object sender, EventArgs e)
} }
} }
protected void OnProcessRequested(Image image) protected void OnProcessRequested(Bitmap bmp)
{ {
if (ProcessRequested != null) if (ProcessRequested != null)
{ {
ProcessRequested(image); ProcessRequested(bmp);
} }
} }

View file

@ -71,7 +71,7 @@ private void btnLoadImageFromClipboard_Click(object sender, EventArgs e)
{ {
if (Clipboard.ContainsImage()) if (Clipboard.ContainsImage())
{ {
Image = (Bitmap)ClipboardHelpers.GetImage(); Image = ClipboardHelpers.GetImage();
if (Image != null) if (Image != null)
{ {

View file

@ -40,11 +40,11 @@ public sealed class RegionCaptureForm : Form
{ {
public static GraphicsPath LastRegionFillPath { get; private set; } public static GraphicsPath LastRegionFillPath { get; private set; }
public event Func<Image, string, string> SaveImageRequested; public event Func<Bitmap, string, string> SaveImageRequested;
public event Func<Image, string, string> SaveImageAsRequested; public event Func<Bitmap, string, string> SaveImageAsRequested;
public event Action<Image> CopyImageRequested; public event Action<Bitmap> CopyImageRequested;
public event Action<Image> UploadImageRequested; public event Action<Bitmap> UploadImageRequested;
public event Action<Image> PrintImageRequested; public event Action<Bitmap> PrintImageRequested;
public RegionCaptureOptions Options { get; set; } public RegionCaptureOptions Options { get; set; }
public Rectangle ClientArea { get; private set; } public Rectangle ClientArea { get; private set; }
@ -1341,9 +1341,9 @@ public Bitmap GetResultImage()
return null; return null;
} }
private Image ReceiveImageForTask() private Bitmap ReceiveImageForTask()
{ {
Image img = GetResultImage(); Bitmap bmp = GetResultImage();
ShapeManager.IsModified = false; ShapeManager.IsModified = false;
@ -1352,16 +1352,16 @@ private Image ReceiveImageForTask()
CloseWindow(); CloseWindow();
} }
return img; return bmp;
} }
internal void OnSaveImageRequested() internal void OnSaveImageRequested()
{ {
if (SaveImageRequested != null) if (SaveImageRequested != null)
{ {
Image img = ReceiveImageForTask(); Bitmap bmp = ReceiveImageForTask();
string imageFilePath = SaveImageRequested(img, ImageFilePath); string imageFilePath = SaveImageRequested(bmp, ImageFilePath);
if (!string.IsNullOrEmpty(imageFilePath)) if (!string.IsNullOrEmpty(imageFilePath))
{ {
@ -1375,9 +1375,9 @@ internal void OnSaveImageAsRequested()
{ {
if (SaveImageAsRequested != null) if (SaveImageAsRequested != null)
{ {
Image img = ReceiveImageForTask(); Bitmap bmp = ReceiveImageForTask();
string imageFilePath = SaveImageAsRequested(img, ImageFilePath); string imageFilePath = SaveImageAsRequested(bmp, ImageFilePath);
if (!string.IsNullOrEmpty(imageFilePath)) if (!string.IsNullOrEmpty(imageFilePath))
{ {
@ -1391,9 +1391,9 @@ internal void OnCopyImageRequested()
{ {
if (CopyImageRequested != null) if (CopyImageRequested != null)
{ {
Image img = ReceiveImageForTask(); Bitmap bmp = ReceiveImageForTask();
CopyImageRequested(img); CopyImageRequested(bmp);
} }
} }
@ -1401,9 +1401,9 @@ internal void OnUploadImageRequested()
{ {
if (UploadImageRequested != null) if (UploadImageRequested != null)
{ {
Image img = ReceiveImageForTask(); Bitmap bmp = ReceiveImageForTask();
UploadImageRequested(img); UploadImageRequested(bmp);
} }
} }
@ -1411,9 +1411,9 @@ internal void OnPrintImageRequested()
{ {
if (PrintImageRequested != null) if (PrintImageRequested != null)
{ {
Image img = ReceiveImageForTask(); Bitmap bmp = ReceiveImageForTask();
PrintImageRequested(img); PrintImageRequested(bmp);
} }
} }

View file

@ -157,7 +157,7 @@ private void RectangleTransparent_MouseUp(object sender, MouseEventArgs e)
} }
} }
public Image GetAreaImage(Screenshot screenshot) public Bitmap GetAreaImage(Screenshot screenshot)
{ {
Rectangle rect = SelectionRectangle0Based; Rectangle rect = SelectionRectangle0Based;

View file

@ -37,11 +37,11 @@ namespace ShareX.ScreenCaptureLib
{ {
public partial class ScrollingCaptureForm : Form public partial class ScrollingCaptureForm : Form
{ {
public event Action<Image> ImageProcessRequested; public event Action<Bitmap> ImageProcessRequested;
public ScrollingCaptureOptions Options { get; private set; } public ScrollingCaptureOptions Options { get; private set; }
public RegionCaptureOptions RegionCaptureOptions { get; private set; } public RegionCaptureOptions RegionCaptureOptions { get; private set; }
public Image Result { get; private set; } public Bitmap Result { get; private set; }
private WindowInfo selectedWindow; private WindowInfo selectedWindow;
private Rectangle selectedRectangle; private Rectangle selectedRectangle;
@ -98,11 +98,11 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing); base.Dispose(disposing);
} }
protected void OnImageProcessRequested(Image img) protected void OnImageProcessRequested(Bitmap bmp)
{ {
if (ImageProcessRequested != null) if (ImageProcessRequested != null)
{ {
ImageProcessRequested(img); ImageProcessRequested(bmp);
} }
} }
@ -522,7 +522,7 @@ private void StartProcess()
{ {
if (Result != null) if (Result != null)
{ {
OnImageProcessRequested((Image)Result.Clone()); OnImageProcessRequested((Bitmap)Result.Clone());
} }
} }
@ -562,7 +562,7 @@ private void CombineAndPreviewImages()
pbOutput.Image = Result; pbOutput.Image = Result;
} }
private Image CombineImages() private Bitmap CombineImages()
{ {
if (images == null || images.Count == 0) if (images == null || images.Count == 0)
{ {
@ -613,7 +613,7 @@ private Image CombineImages()
output.Add(newImage); output.Add(newImage);
} }
Image result = ImageHelpers.CombineImages(output); Bitmap bmpResult = ImageHelpers.CombineImages(output);
foreach (Bitmap image in output) foreach (Bitmap image in output)
{ {
@ -625,7 +625,7 @@ private Image CombineImages()
output.Clear(); output.Clear();
return result; return bmpResult;
} }
private void GuessEdges() private void GuessEdges()

View file

@ -35,7 +35,7 @@ namespace ShareX.ScreenCaptureLib
{ {
public partial class Screenshot public partial class Screenshot
{ {
public Image CaptureWindowTransparent(IntPtr handle) public Bitmap CaptureWindowTransparent(IntPtr handle)
{ {
if (handle.ToInt32() > 0) if (handle.ToInt32() > 0)
{ {
@ -154,7 +154,7 @@ public Image CaptureWindowTransparent(IntPtr handle)
return null; return null;
} }
public Image CaptureActiveWindowTransparent() public Bitmap CaptureActiveWindowTransparent()
{ {
IntPtr handle = NativeMethods.GetForegroundWindow(); IntPtr handle = NativeMethods.GetForegroundWindow();

View file

@ -1595,8 +1595,8 @@ private void PasteFromClipboard(bool insertMousePosition)
{ {
if (Clipboard.ContainsImage()) if (Clipboard.ContainsImage())
{ {
Image img = ClipboardHelpers.GetImage(); Bitmap bmp = ClipboardHelpers.GetImage();
InsertImage(img); InsertImage(bmp);
} }
else if (Clipboard.ContainsFileDropList()) else if (Clipboard.ContainsFileDropList())
{ {

View file

@ -138,22 +138,22 @@ protected ImageInfo ExecuteRegionCaptureLight(TaskSettings taskSettings)
protected ImageInfo ExecuteRegionCaptureTransparent(TaskSettings taskSettings) protected ImageInfo ExecuteRegionCaptureTransparent(TaskSettings taskSettings)
{ {
Image img = null; Bitmap bmp = null;
using (RegionCaptureTransparentForm rectangleTransparent = new RegionCaptureTransparentForm()) using (RegionCaptureTransparentForm rectangleTransparent = new RegionCaptureTransparentForm())
{ {
if (rectangleTransparent.ShowDialog() == DialogResult.OK) if (rectangleTransparent.ShowDialog() == DialogResult.OK)
{ {
img = rectangleTransparent.GetAreaImage(TaskHelpers.GetScreenshot(taskSettings)); bmp = rectangleTransparent.GetAreaImage(TaskHelpers.GetScreenshot(taskSettings));
if (img != null) if (bmp != null)
{ {
lastRegionCaptureType = RegionCaptureType.Transparent; lastRegionCaptureType = RegionCaptureType.Transparent;
} }
} }
} }
return new ImageInfo(img); return new ImageInfo(bmp);
} }
} }
} }

View file

@ -108,16 +108,16 @@ private void TakeScreenshot()
if (!rect.IsEmpty) if (!rect.IsEmpty)
{ {
Image img = TaskHelpers.GetScreenshot(TaskSettings).CaptureRectangle(rect); Bitmap bmp = TaskHelpers.GetScreenshot(TaskSettings).CaptureRectangle(rect);
if (img != null) if (bmp != null)
{ {
TaskSettings.UseDefaultAfterCaptureJob = false; TaskSettings.UseDefaultAfterCaptureJob = false;
TaskSettings.AfterCaptureJob = TaskSettings.AfterCaptureJob.Remove(AfterCaptureTasks.AnnotateImage); TaskSettings.AfterCaptureJob = TaskSettings.AfterCaptureJob.Remove(AfterCaptureTasks.AnnotateImage);
TaskSettings.UseDefaultAdvancedSettings = false; TaskSettings.UseDefaultAdvancedSettings = false;
TaskSettings.AdvancedSettings.DisableNotifications = true; TaskSettings.AdvancedSettings.DisableNotifications = true;
UploadManager.RunImageTask(img, TaskSettings, true, true); UploadManager.RunImageTask(bmp, TaskSettings, true, true);
} }
} }
} }

View file

@ -194,8 +194,8 @@ private void tsmiUpload_Click(object sender, EventArgs e)
{ {
if (pbQRCode.Image != null) if (pbQRCode.Image != null)
{ {
Image img = (Image)pbQRCode.Image.Clone(); Bitmap bmp = (Bitmap)pbQRCode.Image.Clone();
UploadManager.UploadImage(img); UploadManager.UploadImage(bmp);
} }
} }

View file

@ -31,7 +31,7 @@ namespace ShareX
{ {
public class ImageInfo : IDisposable public class ImageInfo : IDisposable
{ {
public Image Image { get; set; } public Bitmap Image { get; set; }
public string WindowTitle { get; set; } public string WindowTitle { get; set; }
public string ProcessName { get; set; } public string ProcessName { get; set; }
@ -39,7 +39,7 @@ public ImageInfo()
{ {
} }
public ImageInfo(Image image) public ImageInfo(Bitmap image)
{ {
Image = image; Image = image;
} }

View file

@ -442,11 +442,11 @@ private static void SaveImageAsJPEGStream(Image img, Stream stream, int jpegQual
} }
} }
public static void SaveImageAsFile(Image img, TaskSettings taskSettings, bool overwriteFile = false) public static void SaveImageAsFile(Bitmap bmp, TaskSettings taskSettings, bool overwriteFile = false)
{ {
using (ImageData imageData = PrepareImage(img, taskSettings)) using (ImageData imageData = PrepareImage(bmp, taskSettings))
{ {
string fileName = GetFilename(taskSettings, imageData.ImageFormat.GetDescription(), img); string fileName = GetFilename(taskSettings, imageData.ImageFormat.GetDescription(), bmp);
string filePath = Path.Combine(taskSettings.CaptureFolder, fileName); string filePath = Path.Combine(taskSettings.CaptureFolder, fileName);
if (!overwriteFile) if (!overwriteFile)
@ -462,9 +462,9 @@ public static void SaveImageAsFile(Image img, TaskSettings taskSettings, bool ov
} }
} }
public static string GetFilename(TaskSettings taskSettings, string extension, Image image) public static string GetFilename(TaskSettings taskSettings, string extension, Bitmap bmp)
{ {
ImageInfo imageInfo = new ImageInfo(image); ImageInfo imageInfo = new ImageInfo(bmp);
return GetFilename(taskSettings, extension, imageInfo); return GetFilename(taskSettings, extension, imageInfo);
} }
@ -829,7 +829,7 @@ public static void OpenImageCombiner(TaskSettings taskSettings = null, IEnumerab
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings(); if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
ImageCombinerForm imageCombinerForm = new ImageCombinerForm(taskSettings.ToolsSettingsReference.ImageCombinerOptions, imageFiles); ImageCombinerForm imageCombinerForm = new ImageCombinerForm(taskSettings.ToolsSettingsReference.ImageCombinerOptions, imageFiles);
imageCombinerForm.ProcessRequested += img => UploadManager.RunImageTask(img, taskSettings); imageCombinerForm.ProcessRequested += bmp => UploadManager.RunImageTask(bmp, taskSettings);
imageCombinerForm.Show(); imageCombinerForm.Show();
} }

View file

@ -148,7 +148,7 @@ private static void Task_StatusChanged(WorkerTask task)
UpdateProgressUI(); UpdateProgressUI();
} }
private static void Task_ImageReady(WorkerTask task, Image image) private static void Task_ImageReady(WorkerTask task, Bitmap image)
{ {
TaskThumbnailPanel panel = TaskThumbnailView.FindPanel(task); TaskThumbnailPanel panel = TaskThumbnailView.FindPanel(task);
@ -158,7 +158,7 @@ private static void Task_ImageReady(WorkerTask task, Image image)
if (Program.Settings.TaskViewMode == TaskViewMode.ThumbnailView) if (Program.Settings.TaskViewMode == TaskViewMode.ThumbnailView)
{ {
panel.UpdateThumbnail((Bitmap)image); panel.UpdateThumbnail(image);
} }
} }
} }
@ -390,7 +390,7 @@ private static void Task_TaskCompleted(WorkerTask task)
RightClickAction = info.TaskSettings.AdvancedSettings.ToastWindowRightClickAction, RightClickAction = info.TaskSettings.AdvancedSettings.ToastWindowRightClickAction,
MiddleClickAction = info.TaskSettings.AdvancedSettings.ToastWindowMiddleClickAction, MiddleClickAction = info.TaskSettings.AdvancedSettings.ToastWindowMiddleClickAction,
FilePath = info.FilePath, FilePath = info.FilePath,
Image = (Bitmap)task.Image, Image = task.Image,
Text = "ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed + "\r\n" + result, Text = "ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed + "\r\n" + result,
URL = result URL = result
}; };

View file

@ -30,7 +30,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
using System.Windows.Forms; using System.Windows.Forms;
@ -143,16 +142,16 @@ public static void UploadFolder(TaskSettings taskSettings = null)
} }
} }
private static void ProcessImageUpload(Image img, TaskSettings taskSettings) private static void ProcessImageUpload(Bitmap bmp, TaskSettings taskSettings)
{ {
if (img != null) if (bmp != null)
{ {
if (!taskSettings.AdvancedSettings.ProcessImagesDuringClipboardUpload) if (!taskSettings.AdvancedSettings.ProcessImagesDuringClipboardUpload)
{ {
taskSettings.AfterCaptureJob = AfterCaptureTasks.UploadImageToHost; taskSettings.AfterCaptureJob = AfterCaptureTasks.UploadImageToHost;
} }
RunImageTask(img, taskSettings); RunImageTask(bmp, taskSettings);
} }
} }
@ -208,9 +207,9 @@ public static void ClipboardUpload(TaskSettings taskSettings = null)
if (Clipboard.ContainsImage()) if (Clipboard.ContainsImage())
{ {
Image img = ClipboardHelpers.GetImage(); Bitmap bmp = ClipboardHelpers.GetImage();
ProcessImageUpload(img, taskSettings); ProcessImageUpload(bmp, taskSettings);
} }
else if (Clipboard.ContainsText()) else if (Clipboard.ContainsText())
{ {
@ -232,9 +231,9 @@ private static void ClipboardUploadCached(ClipboardContentViewer ccv, TaskSettin
if (ccv.ClipboardContentType == EClipboardContentType.Image) if (ccv.ClipboardContentType == EClipboardContentType.Image)
{ {
Image img = (Image)ccv.ClipboardContent; Bitmap bmp = (Bitmap)ccv.ClipboardContent;
ProcessImageUpload(img, taskSettings); ProcessImageUpload(bmp, taskSettings);
} }
else if (ccv.ClipboardContentType == EClipboardContentType.Text) else if (ccv.ClipboardContentType == EClipboardContentType.Text)
{ {
@ -267,7 +266,7 @@ private static void ProcessClipboardContentViewerDialog(ClipboardContentViewer c
} }
else if (ccv.ClipboardContentType == EClipboardContentType.Image) else if (ccv.ClipboardContentType == EClipboardContentType.Image)
{ {
((Image)ccv.ClipboardContent).Dispose(); ((Bitmap)ccv.ClipboardContent).Dispose();
} }
} }
@ -329,8 +328,8 @@ public static void DragDropUpload(IDataObject data, TaskSettings taskSettings =
} }
else if (data.GetDataPresent(DataFormats.Bitmap, false)) else if (data.GetDataPresent(DataFormats.Bitmap, false))
{ {
Image img = data.GetData(DataFormats.Bitmap, false) as Image; Bitmap bmp = data.GetData(DataFormats.Bitmap, false) as Bitmap;
RunImageTask(img, taskSettings); RunImageTask(bmp, taskSettings);
} }
else if (data.GetDataPresent(DataFormats.Text, false)) else if (data.GetDataPresent(DataFormats.Text, false))
{ {
@ -382,9 +381,9 @@ public static void ShowShortenURLDialog(TaskSettings taskSettings = null)
} }
} }
public static void RunImageTask(Image img, TaskSettings taskSettings, bool skipQuickTaskMenu = false, bool skipAfterCaptureWindow = false) public static void RunImageTask(Bitmap bmp, TaskSettings taskSettings, bool skipQuickTaskMenu = false, bool skipAfterCaptureWindow = false)
{ {
ImageInfo imageInfo = new ImageInfo(img); ImageInfo imageInfo = new ImageInfo(bmp);
RunImageTask(imageInfo, taskSettings, skipQuickTaskMenu, skipAfterCaptureWindow); RunImageTask(imageInfo, taskSettings, skipQuickTaskMenu, skipAfterCaptureWindow);
} }
@ -429,21 +428,21 @@ public static void RunImageTask(ImageInfo imageInfo, TaskSettings taskSettings,
} }
} }
public static void UploadImage(Image img) public static void UploadImage(Bitmap bmp)
{ {
if (img != null) if (bmp != null)
{ {
TaskSettings taskSettings = TaskSettings.GetDefaultTaskSettings(); TaskSettings taskSettings = TaskSettings.GetDefaultTaskSettings();
taskSettings.UseDefaultAfterCaptureJob = false; taskSettings.UseDefaultAfterCaptureJob = false;
taskSettings.AfterCaptureJob = AfterCaptureTasks.UploadImageToHost; taskSettings.AfterCaptureJob = AfterCaptureTasks.UploadImageToHost;
RunImageTask(img, taskSettings); RunImageTask(bmp, taskSettings);
} }
} }
public static void UploadImage(Image img, ImageDestination imageDestination, FileDestination imageFileDestination) public static void UploadImage(Bitmap bmp, ImageDestination imageDestination, FileDestination imageFileDestination)
{ {
if (img != null) if (bmp != null)
{ {
TaskSettings taskSettings = TaskSettings.GetDefaultTaskSettings(); TaskSettings taskSettings = TaskSettings.GetDefaultTaskSettings();
taskSettings.UseDefaultAfterCaptureJob = false; taskSettings.UseDefaultAfterCaptureJob = false;
@ -452,7 +451,7 @@ public static void UploadImage(Image img, ImageDestination imageDestination, Fil
taskSettings.ImageDestination = imageDestination; taskSettings.ImageDestination = imageDestination;
taskSettings.ImageFileDestination = imageFileDestination; taskSettings.ImageFileDestination = imageFileDestination;
RunImageTask(img, taskSettings); RunImageTask(bmp, taskSettings);
} }
} }

View file

@ -42,7 +42,7 @@ namespace ShareX
public class WorkerTask : IDisposable public class WorkerTask : IDisposable
{ {
public delegate void TaskEventHandler(WorkerTask task); public delegate void TaskEventHandler(WorkerTask task);
public delegate void TaskImageEventHandler(WorkerTask task, Image image); public delegate void TaskImageEventHandler(WorkerTask task, Bitmap image);
public delegate void UploaderServiceEventHandler(IUploaderService uploaderService); public delegate void UploaderServiceEventHandler(IUploaderService uploaderService);
public event TaskEventHandler StatusChanged, UploadStarted, UploadProgressChanged, UploadCompleted, TaskCompleted; public event TaskEventHandler StatusChanged, UploadStarted, UploadProgressChanged, UploadCompleted, TaskCompleted;
@ -57,7 +57,7 @@ public class WorkerTask : IDisposable
public bool RequestSettingUpdate { get; private set; } public bool RequestSettingUpdate { get; private set; }
public bool EarlyURLCopied { get; private set; } public bool EarlyURLCopied { get; private set; }
public Stream Data { get; private set; } public Stream Data { get; private set; }
public Image Image { get; private set; } public Bitmap Image { get; private set; }
public bool KeepImage { get; set; } public bool KeepImage { get; set; }
public string Text { get; private set; } public string Text { get; private set; }
@ -575,7 +575,7 @@ private bool DoAfterCaptureJobs()
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddImageEffects)) if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddImageEffects))
{ {
Image = TaskHelpers.AddImageEffects((Bitmap)Image, Info.TaskSettings.ImageSettingsReference); Image = TaskHelpers.AddImageEffects(Image, Info.TaskSettings.ImageSettingsReference);
if (Image == null) if (Image == null)
{ {
@ -586,7 +586,7 @@ private bool DoAfterCaptureJobs()
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AnnotateImage)) if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AnnotateImage))
{ {
Image = TaskHelpers.AnnotateImage((Bitmap)Image, null, Info.TaskSettings, true); Image = TaskHelpers.AnnotateImage(Image, null, Info.TaskSettings, true);
if (Image == null) if (Image == null)
{ {
@ -683,7 +683,7 @@ private bool DoAfterCaptureJobs()
thumbnailFolder = Info.TaskSettings.CaptureFolder; thumbnailFolder = Info.TaskSettings.CaptureFolder;
} }
Info.ThumbnailFilePath = TaskHelpers.CreateThumbnail((Bitmap)Image, thumbnailFolder, thumbnailFilename, Info.TaskSettings); Info.ThumbnailFilePath = TaskHelpers.CreateThumbnail(Image, thumbnailFolder, thumbnailFilename, Info.TaskSettings);
if (!string.IsNullOrEmpty(Info.ThumbnailFilePath)) if (!string.IsNullOrEmpty(Info.ThumbnailFilePath))
{ {
@ -1071,11 +1071,11 @@ private void OnImageReady()
{ {
if (ImageReady != null) if (ImageReady != null)
{ {
Image image = null; Bitmap image = null;
if (Program.Settings.TaskViewMode == TaskViewMode.ThumbnailView && Image != null) if (Program.Settings.TaskViewMode == TaskViewMode.ThumbnailView && Image != null)
{ {
image = (Image)Image.Clone(); image = (Bitmap)Image.Clone();
} }
threadWorker.InvokeAsync(() => threadWorker.InvokeAsync(() =>