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
newImage.SetResolution(sourceImage.HorizontalResolution, sourceImage.VerticalResolution);
using Graphics graphics = Graphics.FromImage(newImage);
if (fromTransparentToNon)
{
// Rule 2: Make sure the background color is white
graphics.Clear(Color.White);
}
// decide fastest copy method
if (isAreaEqual)
{
graphics.DrawImageUnscaled(sourceImage, 0, 0);
}
else
{
graphics.DrawImage(sourceImage, 0, 0, sourceRect, GraphicsUnit.Pixel);
}
}
using Graphics graphics = Graphics.FromImage(newImage);
if (fromTransparentToNon)
{
// Rule 2: Make sure the background color is white
graphics.Clear(Color.White);
}
// decide fastest copy method
if (isAreaEqual)
{
graphics.DrawImageUnscaled(sourceImage, 0, 0);
}
else
{
graphics.DrawImage(sourceImage, 0, 0, sourceRect, GraphicsUnit.Pixel);
}
}
else
{
// 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
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);
}
catch (Exception ex)
{
Log.Warn("Problem cloning a propertyItem.", ex);
try
{
newImage.SetPropertyItem(propertyItem);
}
catch (Exception innerEx)
{
Log.Warn("Problem cloning a propertyItem.", innerEx);
}
}
}
catch (Exception ex)
{
Log.Warn("Problem cloning a propertyItem.", ex);
}
return newImage;
}