Classes | Static Public Member Functions

gfxAlphaRecovery Class Reference

#include <gfxAlphaRecovery.h>

List of all members.

Classes

struct  Analysis

Static Public Member Functions

static PRBool RecoverAlpha (gfxImageSurface *blackSurface, const gfxImageSurface *whiteSurface, Analysis *analysis=0L)
static PRUint32 RecoverPixel (PRUint32 black, PRUint32 white)
 from cairo-xlib-utils.c, modified

Member Function Documentation

static PRBool gfxAlphaRecovery::RecoverAlpha ( gfxImageSurface blackSurface,
const gfxImageSurface whiteSurface,
Analysis analysis = 0L 
) [static]
static PRUint32 gfxAlphaRecovery::RecoverPixel ( PRUint32  black,
PRUint32  white 
) [inline, static]

from cairo-xlib-utils.c, modified

Given the RGB data for two image surfaces, one a source image composited with OVER onto a black background, and one a source image composited with OVER onto a white background, reconstruct the original image data into black_data.

Consider a single color channel and a given pixel. Suppose the original premultiplied color value was C and the alpha value was A. Let the final on-black color be B and the final on-white color be W. All values range over 0-255.

Then B=C and W=(255*(255 - A) + C*255)/255. Solving for A, we get A=255 - (W - C). Therefore it suffices to leave the black_data color data alone and set the alpha values using that simple formula. It shouldn't matter what color channel we pick for the alpha computation, but we'll pick green because if we went through a color channel downsample the green bits are likely to be the most accurate.

This function needs to be in the header file since it's used by both gfxRecoverAlpha.cpp and gfxRecoverAlphaSSE2.cpp.


The documentation for this class was generated from the following file: