fixed #758
This commit is contained in:
1 parent
152d3decf3
commit
bf26f268bd
1 file changed
+25
-3
@@ -21,6 +21,8 @@ namespace HandyControl.Controls
|
||||
{
|
||||
private static readonly Guid GifGuid = new Guid("{b96b3caa-0728-11d3-9d7b-0000f81ef32e}");
|
||||
|
||||
private static readonly Guid GifSingleFrameGuid = new Guid("{b96b3cb0-0728-11d3-9d7b-0000f81ef32e}");
|
||||
|
||||
internal IntPtr NativeImage;
|
||||
|
||||
private byte[] _rawData;
|
||||
@@ -204,8 +206,12 @@ namespace HandyControl.Controls
|
||||
streamInfo = Application.GetContentStream(uri) ?? Application.GetResourceStream(uri);
|
||||
}
|
||||
}
|
||||
|
||||
if (streamInfo == null)
|
||||
{
|
||||
throw new FileNotFoundException("Resource not found.", uri.ToString());
|
||||
}
|
||||
|
||||
CreateSourceFromStream(streamInfo.Stream);
|
||||
}
|
||||
catch
|
||||
@@ -214,20 +220,36 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void SwitchToCommonImage()
|
||||
{
|
||||
if (Source == null && Uri != null)
|
||||
{
|
||||
SetCurrentValue(SourceProperty, new BitmapImage(Uri));
|
||||
}
|
||||
}
|
||||
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
|
||||
internal static void EnsureSave(GifImage image, string filename, Stream dataStream)
|
||||
{
|
||||
if (!image.RawGuid.Equals(GifGuid)) return;
|
||||
var animatedGif = false;
|
||||
if (!image.RawGuid.Equals(GifGuid) && !image.RawGuid.Equals(GifSingleFrameGuid))
|
||||
{
|
||||
image.SwitchToCommonImage();
|
||||
return;
|
||||
}
|
||||
|
||||
var animatedGif = false;
|
||||
var dimensions = image.FrameDimensionsList;
|
||||
if (dimensions.Select(guid => new GifFrameDimension(guid)).Contains(GifFrameDimension.Time))
|
||||
{
|
||||
animatedGif = image.GetFrameCount(GifFrameDimension.Time) > 1;
|
||||
}
|
||||
|
||||
if (!animatedGif) return;
|
||||
if (!animatedGif)
|
||||
{
|
||||
image.SwitchToCommonImage();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user