STR #3489

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

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:

Receive EMails Don't Receive EMails

Trouble Report Files:

Post File ]

No files


Trouble Report Comments:

Post Text ]
Name/Time/Date Text top right image
 
#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.
 
bottom left image   bottom right image

Return to Bugs & Features | Post Text | Post File ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2020 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.