Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/CorrectedSelectedItemsControlEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechKrysiak authored Sep 24, 2018
2 parents 57058f1 + 6df48f2 commit c3a1f62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Avalonia.Visuals/Matrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Matrix(
/// <summary>
/// Returns the multiplicative identity matrix.
/// </summary>
public static Matrix Identity => new Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
public static Matrix Identity { get; } = new Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0);

/// <summary>
/// Returns whether the matrix is the identity matrix.
Expand Down
13 changes: 8 additions & 5 deletions src/Windows/Avalonia.Direct2D1/Media/Imaging/WicBitmapImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace Avalonia.Direct2D1.Media
/// </summary>
public class WicBitmapImpl : BitmapImpl
{
private BitmapDecoder _decoder;

/// <summary>
/// Initializes a new instance of the <see cref="WicBitmapImpl"/> class.
/// </summary>
Expand All @@ -33,10 +35,10 @@ public WicBitmapImpl(string fileName)
/// <param name="stream">The stream to read the bitmap from.</param>
public WicBitmapImpl(Stream stream)
{
using (BitmapDecoder decoder = new BitmapDecoder(Direct2D1Platform.ImagingFactory, stream, DecodeOptions.CacheOnLoad))
{
WicImpl = new Bitmap(Direct2D1Platform.ImagingFactory, decoder.GetFrame(0), BitmapCreateCacheOption.CacheOnLoad);
}
// https://stackoverflow.com/questions/48982749/decoding-image-from-stream-using-wic/48982889#48982889
_decoder = new BitmapDecoder(Direct2D1Platform.ImagingFactory, stream, DecodeOptions.CacheOnLoad);

WicImpl = new Bitmap(Direct2D1Platform.ImagingFactory, _decoder.GetFrame(0), BitmapCreateCacheOption.CacheOnLoad);
}

/// <summary>
Expand Down Expand Up @@ -72,7 +74,7 @@ public WicBitmapImpl(APixelFormat format, IntPtr data, int width, int height, in
UnmanagedMethods.CopyMemory(
(l.Data.DataPointer + row * l.Stride),
(data + row * stride),
(UIntPtr) l.Data.Pitch);
(UIntPtr)l.Data.Pitch);
}
}
}
Expand All @@ -92,6 +94,7 @@ public WicBitmapImpl(APixelFormat format, IntPtr data, int width, int height, in
public override void Dispose()
{
WicImpl.Dispose();
_decoder?.Dispose();
}

/// <summary>
Expand Down

0 comments on commit c3a1f62

Please sign in to comment.