FLTK logo

STR #3489

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   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 | SVN ⇄ GIT ]

STR #3489

Application:FLTK Library
Status:1 - Closed w/Resolution
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:matt
Fix Version:1.4-current
Fix Commit:b3e1df35848003952369f8cbf05cdd41ae62d839
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

No files


Trouble Report Comments:


Name/Time/Date 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.
 
 
#2 matt
12:20 Mar 15, 2024
Fixed in Git repository.

Thanks for the code recommendation. I added some optimization as well, so we should have nice, correct, and fast code now.
 
     

Return to Bugs & Features ]

 
 

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