1mlib_ImageZoomTranslateTablmeeBdlieanLdi(b3MLLiIbBrm)alriyb_FIumnacgteiZoonosmTranslateTableBlend(3MLIB)
2
3
4

NAME

6       mlib_ImageZoomTranslateTableBlend  -  image scaling using interpolation
7       table, combined with alpha blending
8

SYNOPSIS

10       cc [ flag... ] file... -lmlib [ library... ]
11       #include <mlib.h>
12
13       mlib_status mlib_ImageZoomTranslateTableBlend(mlib_image *dst,
14            const mlib_image *src, mlib_d64 zoomx, mlib_d64 zoomy,
15            mlib_d64 tx, mlib_d64 ty, const void *table, mlib_edge edge,
16            mlib_blend blend, mlib_s32 cmask);
17
18

DESCRIPTION

20       The mlib_ImageZoomTranslateTableBlend() function will enlarge or minify
21       the  source  image  by  the X and Y zoom factors, with translation, and
22       blend it with the destination image.
23
24
25       It uses the following equation for coordinate mapping:
26
27         xd = zoomx*xs + tx
28         yd = zoomy*ys + ty
29
30
31
32       where a point with coordinates (xs, ys) in the source image  is  mapped
33       to a point with coordinates (xd, yd) in the destination image.
34
35
36       The  center  of  the  upper-left corner pixel of an image is located at
37       (0.5, 0.5).
38
39
40       It is assumed that the  overall  alpha  for  controlling  the  blending
41       between  the source image and the destination image has been pre-multi‐
42       plied to the interpolation table for better performance.
43
44
45       The alpha blending  is  closely  combined  with  the  interpolation  to
46       achieve better performance.  Part of alpha blending has to be performed
47       before or together with the interpolation if the source  image  has  an
48       alpha  channel.  In that case, the color components of each neighboring
49       source pixel which participates in the interpolation (src_r  and  etc.)
50       have  to  be  pre-multiplied  by the alpha component of the same source
51       pixel  (src_a).   After  the  interpolation,  the  interpolated   alpha
52       (interp_a,  which  has  been multiplied by the overall alpha because of
53       the pre-multiplied interpolation table)  and  the  destination  pixel's
54       original  alpha  (dst_a,  if  any)  are  used to blend the interpolated
55       source pixel (with components interp_r and etc.) with  the  destination
56       pixel (with components dst_r and etc.).
57
58
59       The  MLIB_BLEND_GTK_SRC  blending  is  similar  to  the SRC rule of the
60       Porter-Duff rules for image compositing. It is defined by
61
62         Cd = Cs
63         Ad = As
64
65
66
67       in general, and by the following formula for this function:
68
69         if (interp_a != 0.0) {
70              if (dst_has_alpha) {
71                   dst_r = interp_r/interp_a;
72                   dst_g = interp_g/interp_a;
73                   dst_b = interp_b/interp_a;
74                   dst_a = interp_a;
75              } else {
76                   dst_r = interp_r;
77                   dst_g = interp_g;
78                   dst_b = interp_b;
79                   dst_a = 1.0; // implied
80              }
81         } else {
82              dst_r = 0;
83              dst_g = 0;
84              dst_b = 0;
85              dst_a = 0;
86         }
87
88
89
90       The MLIB_BLEND_GTK_SRC_OVER  or  MLIB_BLEND_GTK_SRC_OVER2  blending  is
91       similar  to  the  SRC_OVER rule of the Porter-Duff rules for image com‐
92       positing.  It is defined by
93
94         Cd = Cs + Cd*(1 - As)
95         Ad = As + Ad*(1 - As)
96
97
98
99       in general, and by the following formula for this function:
100
101         w = interp_a + (1 - interp_a)*dst_a;
102         if (w != 0.0) {
103              dst_r = (interp_r + (1 - interp_a)*dst_a*dst_r)/w;
104              dst_g = (interp_g + (1 - interp_a)*dst_a*dst_g)/w;
105              dst_b = (interp_b + (1 - interp_a)*dst_a*dst_b)/w;
106              dst_a = w;
107         } else if (MLIB_BLEND_GTK_SRC_OVER) {
108              dst_r = 0;
109              dst_g = 0;
110              dst_b = 0;
111              dst_a = 0;
112         }
113
114
115
116       where src_a, interp_a and dst_a are assumed to be in the range of [0.0,
117       1.0].
118
119
120       For  an  image with 4 channels, the first or the fourth channel is con‐
121       sidered the alpha channel if cmask equals  8  or  1,  respectively.  An
122       image  with 3 channels is considered to have no alpha channel, which is
123       equivalent to having an alpha channel filled with all 1.0, or  0xff  in
124       case of MLIB_BYTE, if the general formulas for blending shown above are
125       used.
126
127
128       Both src and dst must be of type MLIB_BYTE. They can have either 3 or 4
129       channels.
130
131
132       The src image cannot have width or height larger than 32767.
133

PARAMETERS

135       The function takes the following arguments:
136
137       dst      Pointer to destination image.
138
139
140       src      Pointer to first source image.
141
142
143       zoomx    X zoom factor. zoomx > 0.0.
144
145
146       zoomy    Y zoom factor. zoomy > 0.0.
147
148
149       tx       X translation.
150
151
152       ty       Y translation.
153
154
155       table    Pointer to interpolation table structure.
156
157
158       edge     Type of edge condition. It can be one of the following:
159
160                  MLIB_EDGE_DST_NO_WRITE
161                  MLIB_EDGE_DST_FILL_ZERO
162                  MLIB_EDGE_OP_NEAREST
163                  MLIB_EDGE_SRC_EXTEND
164                  MLIB_EDGE_SRC_EXTEND_INDEF
165                  MLIB_EDGE_SRC_PADDED
166
167
168
169       blend    Type of alpha blending. It can be one of the following:
170
171                  MLIB_BLEND_GTK_SRC
172                  MLIB_BLEND_GTK_SRC_OVER
173                  MLIB_BLEND_GTK_SRC_OVER2
174
175
176
177       cmask    Channel mask to indicate the alpha channel.
178
179

RETURN VALUES

181       The  function  returns MLIB_SUCCESS if successful. Otherwise it returns
182       MLIB_FAILURE.
183

ATTRIBUTES

185       See attributes(5) for descriptions of the following attributes:
186
187
188
189
190       ┌─────────────────────────────┬─────────────────────────────┐
191       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
192       ├─────────────────────────────┼─────────────────────────────┤
193       │Interface Stability          │Committed                    │
194       ├─────────────────────────────┼─────────────────────────────┤
195       │MT-Level                     │MT-Safe                      │
196       └─────────────────────────────┴─────────────────────────────┘
197

SEE ALSO

199       mlib_ImageZoomBlend(3MLIB),        mlib_ImageZoomTranslateBlend(3MLIB),
200       mlib_ImageInterpTableCreate(3MLIB), attributes(5)
201
202
203
204SunOS 5.11                        2 Marml2i0b0_7ImageZoomTranslateTableBlend(3MLIB)
Impressum