THis fixes an exception when Greenshot is used via wine.

This commit is contained in:
Robin Krom 2021-01-02 21:53:47 +01:00 committed by Robin Krom
commit 633b31ec29

View file

@ -1351,22 +1351,22 @@ namespace GreenshotPlugin.Core {
// Make sure both images have the same resolution // Make sure both images have the same resolution
newImage.SetResolution(sourceImage.HorizontalResolution, sourceImage.VerticalResolution); newImage.SetResolution(sourceImage.HorizontalResolution, sourceImage.VerticalResolution);
using Graphics graphics = Graphics.FromImage(newImage); using Graphics graphics = Graphics.FromImage(newImage);
if (fromTransparentToNon) if (fromTransparentToNon)
{ {
// Rule 2: Make sure the background color is white // Rule 2: Make sure the background color is white
graphics.Clear(Color.White); graphics.Clear(Color.White);
} }
// decide fastest copy method // decide fastest copy method
if (isAreaEqual) if (isAreaEqual)
{ {
graphics.DrawImageUnscaled(sourceImage, 0, 0); graphics.DrawImageUnscaled(sourceImage, 0, 0);
} }
else else
{ {
graphics.DrawImage(sourceImage, 0, 0, sourceRect, GraphicsUnit.Pixel); graphics.DrawImage(sourceImage, 0, 0, sourceRect, GraphicsUnit.Pixel);
} }
} }
else else
{ {
// Let GDI+ decide how to convert, need to test what is quicker... // Let GDI+ decide how to convert, need to test what is quicker...
@ -1374,18 +1374,27 @@ namespace GreenshotPlugin.Core {
// Make sure both images have the same resolution // Make sure both images have the same resolution
newImage.SetResolution(sourceImage.HorizontalResolution, sourceImage.VerticalResolution); newImage.SetResolution(sourceImage.HorizontalResolution, sourceImage.VerticalResolution);
} }
// Clone property items (EXIF information etc)
foreach (var propertyItem in sourceImage.PropertyItems) // In WINE someone getting the PropertyItems doesn't work
try
{ {
try // Clone property items (EXIF information etc)
foreach (var propertyItem in sourceImage.PropertyItems)
{ {
newImage.SetPropertyItem(propertyItem); try
} {
catch (Exception ex) newImage.SetPropertyItem(propertyItem);
{ }
Log.Warn("Problem cloning a propertyItem.", ex); catch (Exception innerEx)
{
Log.Warn("Problem cloning a propertyItem.", innerEx);
}
} }
} }
catch (Exception ex)
{
Log.Warn("Problem cloning a propertyItem.", ex);
}
return newImage; return newImage;
} }