Tk Source Code

View Ticket
Login
2004-12-03
10:38 Ticket [987107ff] alpha blending cannot transition transparency properly status still Closed with 4 other changes artifact: 3f995e15 user: mistachkin
2004-12-02
08:09 Closed ticket [987107ff]. artifact: 302f81b0 user: hobbs
2004-11-18
14:19 Ticket [987107ff]: 4 changes artifact: 2d772d4a user: mistachkin
02:20 Ticket [987107ff]: 4 changes artifact: 90eb7a35 user: hobbs
2004-11-17
09:48 Ticket [987107ff]: 4 changes artifact: 1c081612 user: hobbs
07:38 Ticket [987107ff]: 8 changes artifact: ef38044c user: mistachkin
2004-08-05
20:40 Ticket [987107ff]: 4 changes artifact: bdd7da33 user: mistachkin
16:12 Ticket [987107ff]: 6 changes artifact: db75ef55 user: dkf
16:03 Ticket [987107ff]: 4 changes artifact: 0136f890 user: dkf
2004-08-04
21:24 Ticket [987107ff]: 4 changes artifact: c81ce825 user: dkf
2004-07-16
11:24 Ticket [987107ff]: 4 changes artifact: 04e636fe user: mistachkin
2004-07-08
20:03 Ticket [987107ff]: 5 changes artifact: 64358b97 user: dkf
15:39 Ticket [987107ff]: 4 changes artifact: 1bc5a777 user: mistachkin
15:35 Ticket [987107ff]: 4 changes artifact: 502cd535 user: mistachkin
08:34 New ticket [987107ff]. artifact: 93893f3f user: mistachkin

Ticket UUID: 987107
Title: alpha blending cannot transition transparency properly
Type: Bug Version: obsolete: 8.4.8
Submitter: mistachkin Created on: 2004-07-08 08:34:34
Subsystem: 41. Photo Images Assigned To: hobbs
Priority: 7 High Severity:
Status: Closed Last Modified: 2004-12-03 10:38:01
Resolution: Fixed Closed By: hobbs
    Closed on: 2004-12-02 01:09:21
Description:
The alpha blending does not transition from partially
transparent to fully transparent correctly.

Currently, it creates an undesired "ghosting" effect
when using images whose transparency changes gradiently
from partially to fully transparent.

It appears that the result pixels near the boundary are
brighter than they should be (perhaps this is a corner
case?).

Dawson and I have come up with test images and a
special test script that fully illustrates the problem
(and the desired output).
User Comments: mistachkin added on 2004-12-03 10:38:01:
Logged In: YES 
user_id=113501


Unable to verify fix due to inability to compile Img on
Windows using VC++.

TkImg bug #1078099

hobbs added on 2004-12-02 08:09:21:
Logged In: YES 
user_id=72656

As suspected, this was an Img extension issue, in that it
used composite *overlay* instead of *set* form the source
image alpha.  Fixed in Img.

mistachkin added on 2004-11-18 14:19:19:
Logged In: YES 
user_id=113501

Further testing and research suggests that the current alpha
blending is not a complete implementation (misses
approximately 24 corner cases) and suffers from a loss of
precision.

ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf

hobbs added on 2004-11-18 02:20:39:
Logged In: YES 
user_id=72656

This needs to be examined in Img because we are using the
correct algorithms as noted in
http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture04/lecture4.pdf
and http://www.codeproject.com/cs/media/CsTranspTutorial1.asp.

hobbs added on 2004-11-17 09:48:36:
Logged In: YES 
user_id=72656

I've verified that it doesn't look right - you can simplify
by getting rid of your bg img and just using a white canvas.
 The images fade with grey in them - that's not right, but I
don't see an obvious reason.  The Img extension would be a
good place to check as well.

mistachkin added on 2004-11-17 07:38:41:
Logged In: YES 
user_id=113501

Compare the screen output to the output.png from the zip file.

The results are not quite correct.  Perhaps there is some
sort of rounding or precision problem.  Another alternative
is that the png image loader in the Img extension is not
handling alpha channels correctly?

http://www.cohortviii.com/temp/shadow-images.zip

mistachkin added on 2004-08-05 20:40:28:
Logged In: YES 
user_id=113501


I think we may be getting closer, however, it's still not
quite right (doesn't match the expected output).  I'm going
to be uploading some more images that demonstrate the problem.

dkf added on 2004-08-05 16:12:43:
Logged In: YES 
user_id=79902

A few comments on the fixes that I've applied:

The display compositing seems to be correct; I've looked up
the reference and done the math. :^)

The image overlaying compositing was wrong and was
historically wrong too.  It's not worked correctly for as
long as we had alpha channels in our images...

All compositing is done with the "Source Over" rule
described in Thomas Porter and Tom Duff, "Compositing
Digital Images", proceedings of SIGGRAPH 1984.  Basically
(taking alpha as a value in [0..1] for now):
  newpixel = alpha_source*fraction_source*pixel_source
        + alpha_dest*fraction_dest*pixel_dest
  newalpha = alpha_source*fraction_source
        + alpha_dest*fraction_dest
Where fraction_source==1, fraction_dest==(1-alpha_source)
and display is always rendering to a fully opaque surface
(alpha_dest==1) which simplifies the math a lot.

Please check whether things look OK now (I can't, alas)

dkf added on 2004-08-05 16:03:37:
Logged In: YES 
user_id=79902

Backported the compositing fixes to the 8.4 branch

dkf added on 2004-08-04 21:24:49:
Logged In: YES 
user_id=79902

I find it very hard to see how *exactly* that bug
corresponds with our problem.

I've looked this up and we're using the Source Over
compositing rule (see your friendly local Porter-Duff
reference) and we're using it pretty-much correctly (there
might be one-off errors, but we'll ignore those.)

Compositing of photo images with themselves (i.e. [$photo
put]  and Tk_PhotoPutBlock()) was wrong though.

mistachkin added on 2004-07-16 11:24:04:
Logged In: YES 
user_id=113501

We believe it may be similar to this bug:

http://www.mail-archive.com/[email protected]/msg01105.html

dkf added on 2004-07-08 20:03:50:
Logged In: YES 
user_id=79902

I don't know for sure what is wrong, but I suspect that the
problem is a wrong compositing rule. :^/

mistachkin added on 2004-07-08 15:39:25:

File Deleted - 93213: 

Logged In: YES 
user_id=113501


Could not attach the test image files (since when does SF
have a 256K upload limit per file?).

I have uploaded them to the following URL:

http://www.cohortviii.com/temp/shadow-images.zip

mistachkin added on 2004-07-08 15:35:53:

File Added - 93213: shadow-bug.zip