Vips.Image.premultiply (original) (raw)
Method
VipsImagepremultiply
Declaration [src]
int
vips_premultiply (
VipsImage* in,
VipsImage** out,
...
)
Description [src]
Premultiplies any alpha channel.
The final band is taken to be the alpha and the bands are transformed as:
alpha = clip(0, in[in.bands - 1], max_alpha) norm = alpha / max_alpha out = [in[0] * norm, ..., in[in.bands - 1] * norm, alpha]
So for an N-band image, the first N - 1 bands are multiplied by the clipped and normalised final band, the final band is clipped. If there is only a single band, the image is passed through unaltered.
The result isVIPS_FORMAT_FLOAT unless the input format isVIPS_FORMAT_DOUBLE, in which case the output is double as well.
max_alpha has the default value 255, or 65535 for images tagged asVIPS_INTERPRETATION_RGB16 or VIPS_INTERPRETATION_GREY16, and 1.0 for images tagged as VIPS_INTERPRETATION_scRGB.
Non-complex images only.
Optional arguments
max_alpha:gdouble, maximum value for alpha
This method is not directly available to language bindings.
Parameters
out
Type: VipsImage
Output image.
| The argument will be set by the function. |
|---|
| The caller of the method takes ownership of the returned data, and is responsible for freeing it. |
...
Type: ``
NULL-terminated list of optional named arguments.
Return value
Type: int
0 on success, -1 on error.