| [ Return to Bugs & Features | Roadmap 1.3 | Post Text | Post File | Prev | Next ]
STR #3489
Application: | FLTK Library |
Status: | 5 - New |
Priority: | 3 - Moderate, e.g. unable to compile the software |
Scope: | 3 - Applies to all machines and operating systems |
Subsystem: | Image Support |
Summary: | alpha blending does not work correctly in Fl_Image.cxx |
Version: | 1.3.4 |
Created By: | meixner |
Assigned To: | Unassigned |
Fix Version: | Unassigned |
Update Notification: | |
Trouble Report Files:
[ Post File ]No files
Trouble Report Comments:
[ Post Text ]
|
#1 | meixner 05:44 Aug 20, 2018 |
| The math behind the alpha blending is not correct, as a result colors may be slightly off.
Alpha is in the range 0..255 and the calculation is as follows:
*dstptr++ = (srcg * srca + dstr * dsta) >> 8;
assume srcg==255, srca==255 (->dsta=0)
*dstptr++=(255*255+dstr*0)>>8; // (=>254)
So white becomes light grey although using a completeley opaque color.
To fix the issue in alpha_blend(): - change srca and dsta from unsigned char to unsigned - add "srca+=srca>>7" after "srca=*srcptr++" - change "dsta=255-srca" to "dsta=256-srca"
The changes have to be performed for both grayscale + alpha and RGBA. | |
[ Return to Bugs & Features | Post Text | Post File ]
|
| |