Skip to content

Commit cc849d5

Browse files
author
n9
committed
Draft for dotnet#10397
1 parent afc6ff7 commit cc849d5

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
@@ -387,11 +387,22 @@ internal override void FinalizeCreation()
387387
if (_sizeOptions.DoesScale)
388388
{
389389
Debug.Assert(_sizeOptions.Rotation == Rotation.Rotate0);
390-
uint width, height;
391390

391+
uint sourceWidth, sourceHeight;
392+
if (!_sourceRect.IsEmpty)
393+
{
394+
sourceWidth = (uint)_sourceRect.Width;
395+
sourceHeight = (uint)_sourceRect.Height;
396+
}
397+
else
398+
{
399+
HRESULT.Check(UnsafeNativeMethods.WICBitmapSource.GetSize(_unmanagedSource, out sourceWidth, out sourceHeight));
400+
}
401+
402+
uint width, height;
392403
_sizeOptions.GetScaledWidthAndHeight(
393-
(uint)_sizeOptions.PixelWidth,
394-
(uint)_sizeOptions.PixelHeight,
404+
sourceWidth,
405+
sourceHeight,
395406
out width,
396407
out height);
397408

0 commit comments

Comments
 (0)