1mlib_ImageZoomTranslateBlenmde(d3iMaLLIiBb)Library Fmulnicbt_iIomnasgeZoomTranslateBlend(3MLIB)
2
3
4
6 mlib_ImageZoomTranslateBlend - image scaling with alpha blending
7
9 cc [ flag... ] file... -lmlib [ library... ]
10 #include <mlib.h>
11
12 mlib_status mlib_ImageZoomTranslateBlend(mlib_image *dst,
13 const mlib_image *src, mlib_d64 zoomx, mlib_d64 zoomy,
14 mlib_d64 tx, mlib_d64 ty, mlib_filter filter, mlib_edge edge,
15 mlib_blend blend, mlib_s32 alpha, mlib_s32 cmask);
16
17
19 The mlib_ImageZoomTranslateBlend() function will enlarge or minify the
20 source image by the X and Y zoom factors, with translation, and blend
21 it with the destination image.
22
23
24 It uses the following equation for coordinate mapping:
25
26 xd = zoomx*xs + tx
27 yd = zoomy*ys + ty
28
29
30
31 where a point with coordinates (xs, ys) in the source image is mapped
32 to a point with coordinates (xd, yd) in the destination image.
33
34
35 The center of the upper-left corner pixel of an image is located at
36 (0.5, 0.5).
37
38
39 The alpha blending is closely combined with the interpolation to
40 achieve better performance. Part of alpha blending has to be performed
41 before or together with the interpolation if the source image has an
42 alpha channel. In that case, the color components of each neighboring
43 source pixel which participates in the interpolation (src_r and etc.)
44 have to be pre-multiplied by the alpha component of the same source
45 pixel (src_a). After the interpolation, the overall alpha (alpha), the
46 interpolated source alpha (interp_a) and the destination pixel's origi‐
47 nal alpha (dst_a, if any) are used to blend the interpolated source
48 pixel (with components interp_r and etc.) with the destination pixel
49 (with components dst_r and etc.).
50
51
52 The MLIB_BLEND_GTK_SRC blending is similar to the SRC rule of the
53 Porter-Duff rules for image compositing. It is defined by
54
55 Cd = Cs
56 Ad = As
57
58
59
60 in general, and by the following formula for this function:
61
62 if (interp_a != 0.0) {
63 if (dst_has_alpha) {
64 dst_r = interp_r/interp_a;
65 dst_g = interp_g/interp_a;
66 dst_b = interp_b/interp_a;
67 dst_a = interp_a;
68 } else {
69 dst_r = interp_r;
70 dst_g = interp_g;
71 dst_b = interp_b;
72 dst_a = 1.0; // implied
73 }
74 } else {
75 dst_r = 0;
76 dst_g = 0;
77 dst_b = 0;
78 dst_a = 0;
79 }
80
81
82
83 The MLIB_BLEND_GTK_SRC_OVER or MLIB_BLEND_GTK_SRC_OVER2 blending is
84 similar to the SRC_OVER rule of the Porter-Duff rules for image com‐
85 positing. It is defined by
86
87 Cd = Cs + Cd*(1 - As)
88 Ad = As + Ad*(1 - As)
89
90
91
92 in general, and by the following formula for this function:
93
94 w = alpha*interp_a + (1 - alpha*interp_a)*dst_a;
95 if (w != 0.0) {
96 dst_r = (alpha*interp_r +
97 (1 - alpha*interp_a)*dst_a*dst_r)/w;
98 dst_g = (alpha*interp_g +
99 (1 - alpha*interp_a)*dst_a*dst_g)/w;
100 dst_b = (alpha*interp_b +
101 (1 - alpha*interp_a)*dst_a*dst_b)/w;
102 dst_a = w;
103 } else if (MLIB_BLEND_GTK_SRC_OVER) {
104 dst_r = 0;
105 dst_g = 0;
106 dst_b = 0;
107 dst_a = 0;
108 }
109
110
111
112 where alpha, src_a, interp_a and dst_a are assumed to be in the range
113 of [0.0, 1.0].
114
115
116 For an image with 4 channels, the first or the fourth channel is con‐
117 sidered the alpha channel if cmask equals 8 or 1, respectively. An
118 image with 3 channels is considered to have no alpha channel, which is
119 equivalent to having an alpha channel filled with all 1.0, or 0xff in
120 case of MLIB_BYTE, if the general formulas for blending shown above are
121 used.
122
123
124 Both src and dst must be of type MLIB_BYTE. They can have either 3 or 4
125 channels.
126
127
128 The src image cannot have width or height larger than 32767.
129
131 The function takes the following arguments:
132
133 dst Pointer to destination image.
134
135
136 src Pointer to first source image.
137
138
139 zoomx X zoom factor. zoomx > 0.0.
140
141
142 zoomy Y zoom factor. zoomy > 0.0.
143
144
145 tx X translation.
146
147
148 ty Y translation.
149
150
151 filter Type of resampling filter. It can be one of the following:
152
153 MLIB_NEAREST
154 MLIB_BILINEAR
155 MLIB_BICUBIC
156 MLIB_BICUBIC2
157
158
159
160 edge Type of edge condition. It can be one of the following:
161
162 MLIB_EDGE_DST_NO_WRITE
163 MLIB_EDGE_DST_FILL_ZERO
164 MLIB_EDGE_OP_NEAREST
165 MLIB_EDGE_SRC_EXTEND
166 MLIB_EDGE_SRC_EXTEND_INDEF
167 MLIB_EDGE_SRC_PADDED
168
169
170
171 blend Type of alpha blending. It can be one of the following:
172
173 MLIB_BLEND_GTK_SRC
174 MLIB_BLEND_GTK_SRC_OVER
175 MLIB_BLEND_GTK_SRC_OVER2
176
177
178
179 alpha Overall alpha for blending.
180
181
182 cmask Channel mask to indicate the alpha channel.
183
184
186 The function returns MLIB_SUCCESS if successful. Otherwise it returns
187 MLIB_FAILURE.
188
190 See attributes(5) for descriptions of the following attributes:
191
192
193
194
195 ┌─────────────────────────────┬─────────────────────────────┐
196 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
197 ├─────────────────────────────┼─────────────────────────────┤
198 │Interface Stability │Committed │
199 ├─────────────────────────────┼─────────────────────────────┤
200 │MT-Level │MT-Safe │
201 └─────────────────────────────┴─────────────────────────────┘
202
204 mlib_ImageZoomBlend(3MLIB), mlib_ImageZoomTranslateTableBlend(3MLIB),
205 attributes(5)
206
207
208
209SunOS 5.11 2 Mar 2007mlib_ImageZoomTranslateBlend(3MLIB)