Added better error handling for reading the bitmap [skip ci]

This commit is contained in:
Robin Krom 2022-03-29 20:35:43 +02:00
parent 9ae5598ab8
commit 78cbb055cb
No known key found for this signature in database
GPG key ID: BCC01364F1371490

View file

@ -86,11 +86,19 @@ namespace Greenshot.Editor.FileFormatHandlers
bitmapStream.Write(fileHeaderBytes, 0, fileHeaderSize);
bitmapStream.Write(dibBuffer, 0, dibBuffer.Length);
bitmapStream.Seek(0, SeekOrigin.Begin);
// TODO: Replace with a FileFormatHandler
try
{
using var beforeCloneImage = Image.FromStream(bitmapStream);
bitmap = ImageHelper.Clone(beforeCloneImage) as Bitmap;
return bitmap != null;
}
catch (Exception ex)
{
Log.Error("Problem retrieving Format17 from clipboard.", ex);
bitmap = null;
return false;
}
}
Log.Info("Using special DIBV5 / Format17 format reader");
// CF_DIBV5
IntPtr gcHandle = IntPtr.Zero;