Premultiplied alpha handle for driver

Huang, FrankR FrankR.Huang at amd.com
Sun Jun 6 23:22:55 PDT 2010


Morton,

	Thanks. In geode driver, there is a condition that the source format is RGB565 and the mask format is A8. The driver use its function to transfer it to ARGB32, then does the regular OVER operation. The result is correct.


Thanks,
Frank

-----Original Message-----
From: Jonathan Morton [mailto:jonathan.morton at movial.com] 
Sent: 2010年6月4日 17:40
To: Huang, FrankR
Cc: Alex Deucher; Siarhei Siamashka; xorg-devel at lists.x.org
Subject: Re: Premultiplied alpha handle for driver

> If the screen depth is 16bit(for geode, RGB565). I think there must be some color lose in ARGB32 format to RGB565. So the result is a little color distortion. In general, how do you handle it?

It is not difficult to convert between RGB565 and ARGB8888.  In
principle the key thing is to keep the highest representable value in
each channel as equivalent to 1.0, and the lowest as 0.0.  The missing
alpha channel is treated as 1.0 (opaque).

The usual technique is to repeat the bits received from a smaller format:

a = 255;
r = (r << 3) | (r >> 2);
g = (g << 2) | (g >> 4);
b = (b << 3) | (b >> 2);

When converting to the smaller format, drop the alpha channel and
truncate the other components to fit.

 - Jonathan Morton




More information about the xorg-devel mailing list