Skip to content

Fix ArgumentException with FromWidth/Height options in InteropBitmap - #10706

Open
h3xds1nz wants to merge 1 commit into
dotnet:mainfrom
h3xds1nz:fix-interopbitmap-srcrect
Open

h3xds1nz wants to merge 1 commit into
dotnet:mainfrom
h3xds1nz:fix-interopbitmap-srcrect

Conversation

@h3xds1nz

@h3xds1nz h3xds1nz commented Apr 4, 2025 •

Copy link
Copy Markdown
Member

Fixes #10397

Description

Fixes an ArgumentException that would occur in any case the sizing options passed would be created via FromHeight and FromWidth factory methods due to invalid arguments passed to GetScaledWidthAndHeight (self).

Instead the correct values to pass are the source bitmap dimensions. In case there's no clip rect provided, we must retrieve the width/height as we don't have it yet available during initialization, otherwise pass the clip rect.

Customer Impact

Customers will be able to scale InteropBitmap without any exceptions upon creation.

Regression

It is the case in NetFX as well.

Testing

Tests are included.

Risk

Low, from non-working to working properly.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz
h3xds1nz requested review from a team as code owners April 4, 2025 18:03
@dotnet-policy-service dotnet-policy-service Bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Apr 4, 2025
@codecov

codecov Bot commented Apr 4, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 11.39672%. Comparing base (3cc9d57) to head (e84ca6e).
⚠️ Report is 406 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #10706         +/-   ##
===================================================
+ Coverage   11.17950%   11.39672%   +0.21721%     
===================================================
  Files           3314        3315          +1     
  Lines         665182      665437        +255     
  Branches       74668       74669          +1     
===================================================
+ Hits           74364       75838       +1474     
+ Misses        589525      588296       -1229     
- Partials        1293        1303         +10     
Flag Coverage Δ
Debug 11.39672% <100.00000%> (+0.21721%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Imaging.CreateBitmapSourceFromHIcon crash: Value does not fall within the expected range.

1 participant