Mercurial > MadButterfly
comparison src/graph_engine_cairo.c @ 1098:cb4a2ffdf9e8
Merge HEAD
author | wycc |
---|---|
date | Sat, 04 Dec 2010 16:58:25 +0800 |
parents | d09f603438d8 |
children | e1a76d10953e |
comparison
equal
deleted
inserted
replaced
1097:52d8bf5d12b4 | 1098:cb4a2ffdf9e8 |
---|---|
148 stop++; | 148 stop++; |
149 } | 149 } |
150 | 150 |
151 return ptn; | 151 return ptn; |
152 } | 152 } |
153 | |
154 mbe_pattern_t * | |
155 mbe_pattern_create_image(mb_img_data_t *img) { | |
156 cairo_surface_t *surf; | |
157 cairo_pattern_t *ptn; | |
158 cairo_format_t fmt; | |
159 | |
160 switch(img->fmt) { | |
161 case MB_IFMT_ARGB32: | |
162 fmt = CAIRO_FORMAT_ARGB32; | |
163 break; | |
164 | |
165 case MB_IFMT_RGB24: | |
166 fmt = CAIRO_FORMAT_RGB24; | |
167 break; | |
168 | |
169 case MB_IFMT_A8: | |
170 fmt = CAIRO_FORMAT_A8; | |
171 break; | |
172 | |
173 case MB_IFMT_A1: | |
174 fmt = CAIRO_FORMAT_A1; | |
175 break; | |
176 | |
177 case MB_IFMT_RGB16_565: | |
178 fmt = CAIRO_FORMAT_RGB16_565; | |
179 break; | |
180 | |
181 default: | |
182 return NULL; | |
183 } | |
184 | |
185 surf = cairo_image_surface_create_for_data(img->content, fmt, | |
186 img->w, img->h, img->stride); | |
187 ptn = cairo_pattern_create_for_surface(surf); | |
188 cairo_surface_destroy(surf); | |
189 | |
190 return ptn; | |
191 } | |
192 | |
193 void | |
194 mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) { | |
195 area_t *area; | |
196 int i; | |
197 | |
198 cairo_new_path(canvas); | |
199 | |
200 for(i = 0; i < n_areas; i++) { | |
201 area = areas[i]; | |
202 cairo_rectangle(canvas, area->x, area->y, area->w, area->h); | |
203 } | |
204 | |
205 cairo_clip(canvas); | |
206 } |