Skip to content
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

Fix reading pixel values from single channel 16 bit image #439

Merged
merged 4 commits into from
Sep 22, 2022

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Sep 20, 2022

Signed-off-by: Ian Chen [email protected]

🦟 Bug fix

Summary

Currently the Image class calls FreeImage_GetPixelIndex to access pixel values of a single channel image. However, this function does not support reading values from 16 bit images. This PR fixes the issue by implement our own PixelIndex function that includes logic for accessing the pixel value of 16 bit image types.

Additional info: This is needed for loading 16 bit heightmaps. Currently it floods the console with Image: Coordinates out of range error msgs. This happens when the Image::MaxColor call is looping through the image pixels and calling FreeImage_GetPixelIndex function that fails on every iteration.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@iche033 iche033 requested a review from mjcarroll as a code owner September 20, 2022 22:47
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Sep 20, 2022
@codecov
Copy link

codecov bot commented Sep 20, 2022

Codecov Report

Merging #439 (ea4289c) into gz-common5 (2542907) will increase coverage by 0.14%.
The diff coverage is 78.26%.

@@              Coverage Diff               @@
##           gz-common5     #439      +/-   ##
==============================================
+ Coverage       80.31%   80.45%   +0.14%     
==============================================
  Files              85       85              
  Lines            9987    10004      +17     
==============================================
+ Hits             8021     8049      +28     
+ Misses           1966     1955      -11     
Impacted Files Coverage Δ
graphics/src/Image.cc 81.00% <78.26%> (+4.44%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

graphics/src/Image.cc Show resolved Hide resolved
@nkoenig nkoenig requested a review from ahcorde September 21, 2022 21:37
Signed-off-by: Nate Koenig <[email protected]>
@ahcorde ahcorde merged commit 26b1ac3 into gz-common5 Sep 22, 2022
@ahcorde ahcorde deleted the pixel_index_16 branch September 22, 2022 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants