'\" te .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved .TH mlib_ImageZoomTranslateTableBlend 3MLIB "2 Mar 2007" "SunOS 5.11" "mediaLib Library Functions" .SH NAME mlib_ImageZoomTranslateTableBlend \- image scaling using interpolation table, combined with alpha blending .SH SYNOPSIS .LP .nf cc [ \fIflag\fR... ] \fIfile\fR... \fB-lmlib\fR [ \fIlibrary\fR... ] #include \fBmlib_status\fR \fBmlib_ImageZoomTranslateTableBlend\fR(\fBmlib_image *\fR\fIdst\fR, \fBconst mlib_image *\fR\fIsrc\fR, \fBmlib_d64\fR \fIzoomx\fR, \fBmlib_d64\fR \fIzoomy\fR, \fBmlib_d64\fR \fItx\fR, \fBmlib_d64\fR \fIty\fR, \fBconst void *\fR\fItable\fR, \fBmlib_edge\fR \fIedge\fR, \fBmlib_blend\fR \fIblend\fR, \fBmlib_s32\fR \fIcmask\fR); .fi .SH DESCRIPTION .sp .LP The \fBmlib_ImageZoomTranslateTableBlend()\fR function will enlarge or minify the source image by the X and Y zoom factors, with translation, and blend it with the destination image. .sp .LP It uses the following equation for coordinate mapping: .sp .in +2 .nf xd = zoomx*xs + tx yd = zoomy*ys + ty .fi .in -2 .sp .LP where a point with coordinates \fB(xs, ys)\fR in the source image is mapped to a point with coordinates \fB(xd, yd)\fR in the destination image. .sp .LP The center of the upper-left corner pixel of an image is located at \fB(0.5, 0.5)\fR. .sp .LP It is assumed that the overall alpha for controlling the blending between the source image and the destination image has been pre-multiplied to the interpolation table for better performance. .sp .LP The alpha blending is closely combined with the interpolation to achieve better performance. Part of alpha blending has to be performed before or together with the interpolation if the source image has an alpha channel. In that case, the color components of each neighboring source pixel which participates in the interpolation (\fBsrc_r\fR and etc.) have to be pre-multiplied by the alpha component of the same source pixel (\fBsrc_a\fR). After the interpolation, the interpolated alpha (\fBinterp_a\fR, which has been multiplied by the overall alpha because of the pre-multiplied interpolation table) and the destination pixel's original alpha (\fBdst_a\fR, if any) are used to blend the interpolated source pixel (with components \fBinterp_r\fR and etc.) with the destination pixel (with components \fBdst_r\fR and etc.). .sp .LP The \fBMLIB_BLEND_GTK_SRC\fR blending is similar to the \fBSRC\fR rule of the Porter-Duff rules for image compositing. It is defined by .sp .in +2 .nf Cd = Cs Ad = As .fi .in -2 .sp .LP in general, and by the following formula for this function: .sp .in +2 .nf if (interp_a != 0.0) { if (dst_has_alpha) { dst_r = interp_r/interp_a; dst_g = interp_g/interp_a; dst_b = interp_b/interp_a; dst_a = interp_a; } else { dst_r = interp_r; dst_g = interp_g; dst_b = interp_b; dst_a = 1.0; // implied } } else { dst_r = 0; dst_g = 0; dst_b = 0; dst_a = 0; } .fi .in -2 .sp .LP The \fBMLIB_BLEND_GTK_SRC_OVER\fR or \fBMLIB_BLEND_GTK_SRC_OVER2\fR blending is similar to the \fBSRC_OVER\fR rule of the Porter-Duff rules for image compositing. It is defined by .sp .in +2 .nf Cd = Cs + Cd*(1 - As) Ad = As + Ad*(1 - As) .fi .in -2 .sp .LP in general, and by the following formula for this function: .sp .in +2 .nf w = interp_a + (1 - interp_a)*dst_a; if (w != 0.0) { dst_r = (interp_r + (1 - interp_a)*dst_a*dst_r)/w; dst_g = (interp_g + (1 - interp_a)*dst_a*dst_g)/w; dst_b = (interp_b + (1 - interp_a)*dst_a*dst_b)/w; dst_a = w; } else if (MLIB_BLEND_GTK_SRC_OVER) { dst_r = 0; dst_g = 0; dst_b = 0; dst_a = 0; } .fi .in -2 .sp .LP where \fBsrc_a\fR, \fBinterp_a\fR and \fBdst_a\fR are assumed to be in the range of \fB[0.0, 1.0]\fR. .sp .LP For an image with 4 channels, the first or the fourth channel is considered the alpha channel if \fIcmask\fR equals 8 or 1, respectively. An image with 3 channels is considered to have no alpha channel, which is equivalent to having an alpha channel filled with all \fB1.0\fR, or \fB0xff\fR in case of \fBMLIB_BYTE\fR, if the general formulas for blending shown above are used. .sp .LP Both \fIsrc\fR and \fIdst\fR must be of type \fBMLIB_BYTE\fR. They can have either 3 or 4 channels. .sp .LP The \fIsrc\fR image cannot have width or height larger than 32767. .SH PARAMETERS .sp .LP The function takes the following arguments: .sp .ne 2 .mk .na \fB\fIdst\fR\fR .ad .RS 9n .rt Pointer to destination image. .RE .sp .ne 2 .mk .na \fB\fIsrc\fR\fR .ad .RS 9n .rt Pointer to first source image. .RE .sp .ne 2 .mk .na \fB\fIzoomx\fR\fR .ad .RS 9n .rt X zoom factor. \fBzoomx > 0.0\fR. .RE .sp .ne 2 .mk .na \fB\fIzoomy\fR\fR .ad .RS 9n .rt Y zoom factor. \fBzoomy > 0.0\fR. .RE .sp .ne 2 .mk .na \fB\fItx\fR\fR .ad .RS 9n .rt X translation. .RE .sp .ne 2 .mk .na \fB\fIty\fR\fR .ad .RS 9n .rt Y translation. .RE .sp .ne 2 .mk .na \fB\fItable\fR\fR .ad .RS 9n .rt Pointer to interpolation table structure. .RE .sp .ne 2 .mk .na \fB\fIedge\fR\fR .ad .RS 9n .rt Type of edge condition. It can be one of the following: .sp .in +2 .nf MLIB_EDGE_DST_NO_WRITE MLIB_EDGE_DST_FILL_ZERO MLIB_EDGE_OP_NEAREST MLIB_EDGE_SRC_EXTEND MLIB_EDGE_SRC_EXTEND_INDEF MLIB_EDGE_SRC_PADDED .fi .in -2 .RE .sp .ne 2 .mk .na \fB\fIblend\fR\fR .ad .RS 9n .rt Type of alpha blending. It can be one of the following: .sp .in +2 .nf MLIB_BLEND_GTK_SRC MLIB_BLEND_GTK_SRC_OVER MLIB_BLEND_GTK_SRC_OVER2 .fi .in -2 .RE .sp .ne 2 .mk .na \fB\fIcmask\fR\fR .ad .RS 9n .rt Channel mask to indicate the alpha channel. .RE .SH RETURN VALUES .sp .LP The function returns \fBMLIB_SUCCESS\fR if successful. Otherwise it returns \fBMLIB_FAILURE\fR. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelMT-Safe .TE .SH SEE ALSO .sp .LP \fBmlib_ImageZoomBlend\fR(3MLIB), \fBmlib_ImageZoomTranslateBlend\fR(3MLIB), \fBmlib_ImageInterpTableCreate\fR(3MLIB), \fBattributes\fR(5)