Skip to content

Commit 623fc97

Browse files
author
n9
committed
Draft for dotnet#10397
1 parent 43f4bc5 commit 623fc97

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/InteropBitmapSource.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,22 @@ internal override void FinalizeCreation()
373373
if (_sizeOptions.DoesScale)
374374
{
375375
Debug.Assert(_sizeOptions.Rotation == Rotation.Rotate0);
376-
uint width, height;
377376

377+
uint sourceWidth, sourceHeight;
378+
if (!_sourceRect.IsEmpty)
379+
{
380+
sourceWidth = _sourceRect.Width;
381+
sourceHeight = _sourceRect.Height;
382+
}
383+
else
384+
{
385+
HRESULT.Check(UnsafeNativeMethods.WICBitmapSource.GetSize(_unmanagedSource, out sourceWidth, out sourceHeight));
386+
}
387+
388+
uint width, height;
378389
_sizeOptions.GetScaledWidthAndHeight(
379-
(uint)_sizeOptions.PixelWidth,
380-
(uint)_sizeOptions.PixelHeight,
390+
sourceWidth,
391+
sourceHeight,
381392
out width,
382393
out height);
383394

0 commit comments

Comments
 (0)