comparison src/paint.c @ 450:a417fd980228

Replace cairo_format_t with mb_img_fmt_t. - Replace all CAIRO_FORAMT_* with MB_IFMT_* - wrap functions return or are argumented with image format.
author Thinker K.F. Li <thinker@branda.to>
date Wed, 05 Aug 2009 15:54:44 +0800
parents 16116d84bc5e
children ba64f928542b
comparison
equal deleted inserted replaced
449:c525edac917e 450:a417fd980228
288 * Owner-ship of img is transfered. 288 * Owner-ship of img is transfered.
289 */ 289 */
290 paint_t *rdman_paint_image_new(redraw_man_t *rdman, 290 paint_t *rdman_paint_image_new(redraw_man_t *rdman,
291 mb_img_data_t *img) { 291 mb_img_data_t *img) {
292 paint_image_t *paint; 292 paint_image_t *paint;
293 int fmt; 293
294
295 switch(img->fmt) {
296 case MB_IFMT_ARGB32:
297 fmt = CAIRO_FORMAT_ARGB32;
298 break;
299 case MB_IFMT_RGB24:
300 fmt = CAIRO_FORMAT_RGB24;
301 break;
302 case MB_IFMT_A8:
303 fmt = CAIRO_FORMAT_A8;
304 break;
305 case MB_IFMT_A1:
306 fmt = CAIRO_FORMAT_A1;
307 break;
308 default:
309 return NULL;
310 }
311
312 paint = O_ALLOC(paint_image_t); 294 paint = O_ALLOC(paint_image_t);
313 if(paint == NULL) 295 if(paint == NULL)
314 return NULL; 296 return NULL;
315 297
316 paint_init(&paint->paint, MBP_IMAGE, 298 paint_init(&paint->paint, MBP_IMAGE,
317 paint_image_prepare, paint_image_free); 299 paint_image_prepare, paint_image_free);
318 paint->img = img; 300 paint->img = img;
319 paint->surf = mbe_image_surface_create_for_data(img->content, 301 paint->surf = mbe_image_surface_create_for_data(img->content,
320 fmt, 302 img->fmt,
321 img->w, 303 img->w,
322 img->h, 304 img->h,
323 img->stride); 305 img->stride);
324 if(paint->surf == NULL) { 306 if(paint->surf == NULL) {
325 paint_destroy(&paint->paint); 307 paint_destroy(&paint->paint);