Skip to content

[USER32_APTEST][USER32] CopyImage improve regression test and function. #7524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 24, 2024

Conversation

Doug-Lyons
Copy link
Contributor

@Doug-Lyons Doug-Lyons commented Nov 24, 2024

Purpose

Improve CopyImage funciton by adding fast return when HANDLE is NULL and remove previous HACK.

JIRA issue: CORE-19806
CORE-17902

Proposed changes

Test for HANDLE == NULL and set LastError and do fast return if true.
Improve previous HACK in PR #6886 and commit d3ec7cd.

@github-actions github-actions bot added ROSTESTS Label for ROS testcases PRs. Win32SS For Win32 subsystem (Win32k, GDI/USER DLLs, etc.) related components PRs. labels Nov 24, 2024
@binarymaster binarymaster added the enhancement For PRs with an enhancement/new feature. label Nov 24, 2024
ZeroMemory(&bmi, sizeof(bmi));
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);

hDC = GetDC(NULL); // Screen hdc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle this call shouldn't fail, but....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But does it matter for DIB_RGB_COLORS? It might be a palette thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HBelusca, I did a non-exhaustive search of the ReactOS code base and in most cases where we use this code:

GetDC(NULL);

there is no error checking, but since you pointed this out, now I check if hDC is NULL.
If so, we will output an error message and skip the GetDIBits call that used this value.
We needed to free the iconinfo items, so we could not return here, but eventually after the failing "IF" test below, we will return "NULL".

@whindsaks, Sorry I do not understand your question about DIB_RGB_COLORS. Can you be more specific. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My question was, does GetDIBits need a hdc with DIB_RGB_COLORS or is it only really needed for DIB_PAL_COLORS (palette).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whindsaks, I do not really know the answer to your question, but it was a good one. In researching it, I found a much simpler way to get the width and height from an HBITMAP. So instead of using GetDIBits, I now use GetObject. So there is no longer any use of the DIB_PAL_COLORS of DIB_RGB_COLORS involved here. Thanks.

@Doug-Lyons Doug-Lyons requested a review from whindsaks December 7, 2024 06:19
@Doug-Lyons Doug-Lyons merged commit 1c55924 into reactos:master Dec 24, 2024
34 checks passed
@Doug-Lyons
Copy link
Contributor Author

Thanks for everyone's help with this and for approvals from @HBelusca, @oleg-dubinskiy and @DarkFire01.

@Doug-Lyons Doug-Lyons deleted the CopyImage-improve branch December 25, 2024 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For PRs with an enhancement/new feature. ROSTESTS Label for ROS testcases PRs. Win32SS For Win32 subsystem (Win32k, GDI/USER DLLs, etc.) related components PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants