Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@wallacegibbon
Copy link

@wallacegibbon wallacegibbon commented Oct 20, 2025

The GetRed, GetBlue, GetGreen in wxWidgets return unsigned char, But the code in wxe_wrapper_4 is using char to receive the result and sign extending it into a int.

As a result, a pixel whose red is 250(16#FA) will be returned as 4294967290(16#FFFFFFFA) by wxImage:getRed/3.

This commit fixed this problem.

@github-actions
Copy link
Contributor

CT Test Results

Tests are running... https://github.com/erlang/otp/actions/runs/18640769744

Results for commit 25d6bb3

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

  • No CT logs found
  • No HTML docs found
  • No Windows Installer found

// Erlang/OTP Github Action Bot

The GetRed, GetBlue, GetGreen in wxWidgets return `unsigned char`,
But the code in wxe_wrapper_4.cpp is using `char` to receive the result
and sign extending it into a int.

As a result, a pixel whose red is `250`(`16#FA`) will be returned as
`4294967290`(`16#FFFFFFFA`) by `wxImage:getRed/3`.

This commit fixed this problem.
@rickard-green rickard-green added the team:PS Assigned to OTP team PS label Oct 20, 2025
@wallacegibbon
Copy link
Author

wallacegibbon commented Oct 21, 2025

Notes to test this feature.

We can use convert (or magick for newer version of imagemagick) to create a grey picture:

convert -size 128x128 xc:"rgb(250, 250, 250)" lightgrey.png

Then reading the red value of any pixel from this image should return 250 (0xFA)

I = wxImage:new("./lightgrey.png"),
P = wxImage:getRed(I, 0, 0),
io:format("first pixel: ~p (~.16B) ~n", [P, P]),

Before this commit:

first pixel: 4294967290 (FFFFFFFA) 

After this commit:

first pixel: 250 (FA) 

@dgud
Copy link
Contributor

dgud commented Oct 21, 2025

Thanks for the great PR, only a testcase missing :-)
Since the wx code is generated, I have updated the code generator to fix this (and some stuff that was lagging behind).
I also added a variant of the testcase you provided, thanks.

Replaced by #10314

@dgud dgud closed this Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team:PS Assigned to OTP team PS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants