Skip to content

Add ImageIOBase::GetComponentTypeFromTypeTraits(isFloatingPoint, isUnsigned, numberOfBits)#5449

Merged
hjmjohnson merged 2 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:ImageIOBase-GetComponentTypeFromTypeTraits
Jul 10, 2025
Merged

Add ImageIOBase::GetComponentTypeFromTypeTraits(isFloatingPoint, isUnsigned, numberOfBits)#5449
hjmjohnson merged 2 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:ImageIOBase-GetComponentTypeFromTypeTraits

Conversation

@N-Dekker
Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker commented Jul 3, 2025

Added a static member function, ImageIOBase::GetComponentTypeFromTypeTraits(bool isFloatingPoint, bool isUnsigned, size_t numberOfBits), to ease retrieving the appropriate pixel component type.

Used this member function to clean up MetaImageIO::ReadImageInformation(), by removing the 48 this->SetComponentType calls from its switch.

Aims to ease retrieving the appropriate pixel component type, by calling
`GetComponentTypeFromTypeTraits(isFloatingPoint, isUnsigned, numberOfBits)`
(possibly at compile-time).
@github-actions github-actions bot added type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:IO Issues affecting the IO module labels Jul 3, 2025
@blowekamp
Copy link
Copy Markdown
Member

As explained in the discourse post, I believe the "CHAR" enum type should be considered signed, and the cases there it is system dependent on the C "char" type should be considered a bug.

Reduced code redundancy in `MetaImageIO::ReadImageInformation()`, by removing
the 48 `this->SetComponentType` calls from its `switch`.
@N-Dekker N-Dekker force-pushed the ImageIOBase-GetComponentTypeFromTypeTraits branch from 789fda9 to 2d05d9e Compare July 3, 2025 15:24
@N-Dekker N-Dekker marked this pull request as ready for review July 3, 2025 19:03
Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Looks good on a glance.

@hjmjohnson hjmjohnson merged commit a1e3c8e into InsightSoftwareConsortium:main Jul 10, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:IO Issues affecting the IO module type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants