mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #27981 from sturkmen72:fix_alpha_handling
Fix alpha handling for blending in PNG format #27981 ### Pull Request Readiness Checklist closes #27974 See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -715,7 +715,7 @@ void PngDecoder::compose_frame(std::vector<png_bytep>& rows_dst, const std::vect
|
||||
|
||||
// Blending mode
|
||||
for (unsigned int i = 0; i < w; i++, sp += channels, dp += channels) {
|
||||
uint16_t alpha = sp[3];
|
||||
uint16_t alpha = channels < 4 ? 0 : sp[3];
|
||||
|
||||
if (channels < 4 || alpha == 65535 || dp[3] == 0) {
|
||||
// Fully opaque OR destination fully transparent: direct copy
|
||||
@@ -745,7 +745,7 @@ void PngDecoder::compose_frame(std::vector<png_bytep>& rows_dst, const std::vect
|
||||
|
||||
// Blending mode
|
||||
for (unsigned int i = 0; i < w; i++, sp += channels, dp += channels) {
|
||||
uint8_t alpha = sp[3];
|
||||
uint8_t alpha = channels < 4 ? 0 : sp[3];
|
||||
|
||||
if (channels < 4 || alpha == 255 || dp[3] == 0) {
|
||||
// Fully opaque OR destination fully transparent: direct copy
|
||||
|
||||
Reference in New Issue
Block a user