Remove use of Bitmap pool in TransformationUtils to fix gainmap issues. #5505
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request modifies the fitCenter and centerCrop methods, located in TransformationUtils, to address gain map handling. The previous implementation used applyMatrix with the Canvas API, which dropped gain map data.
This PR replaces applyMatrix with createBitmap APIs to ensure proper gain map handling in fitCenter and centerCrop. This change avoids using the bitmap pool.
Motivation and Context
The original fitCenter and centerCrop implementation lost gain map information, which is crucial for HDR images.
The applyMatrix method's use of the Canvas API caused this issue, as Canvas doesn't preserve gain maps. We now use createBitmap, which retains this data. The bitmap pool was avoided because, The BitmapPool is keyed off of three attributes, 1) width, 2) height and 3) config (bit depth). The usages of the BitmapPool do not strive to override other properties of the Bitmap like the color space before the bitmap is reused. This ensures correct fitCenter and centerCrop behavior with gain maps.