1
0
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:
Suleyman TURKMEN
2025-11-09 18:23:13 +03:00
committed by GitHub
parent 87436149a5
commit 386be68f93
+2 -2
View File
@@ -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