--- cairo-png.c 2005-05-28 16:23:02.000000000 +0200 +++ ../cairo-0.5.0/src/cairo-png.c 2005-05-10 23:55:37.000000000 +0200 @@ -61,19 +61,6 @@ } } -static void -transform_rgb24_data (uint8_t* dst, uint8_t* src, int width) -{ - int i; - for (i = 0; i < width; i ++) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - src += 4; - dst += 3; - } -} - static cairo_status_t write_png (cairo_surface_t *surface, png_rw_ptr write_func, @@ -90,7 +77,6 @@ png_color_16 white; int png_color_type; int depth; - uint8_t* tmp_data = NULL; status = _cairo_surface_acquire_source_image (surface, &image, @@ -107,25 +93,8 @@ goto BAIL1; } - if (image->format == CAIRO_FORMAT_RGB24) - { - tmp_data = malloc(image->height * image->width * 3); - if (tmp_data == NULL) - { - status = CAIRO_STATUS_NO_MEMORY; - goto BAIL2; - } - for (i = 0; i < image->height; i++) - { - rows[i] = tmp_data + 3 * i * image->width; - transform_rgb24_data(rows[i], image->data + i * image->stride, image->width); - } - } - else - { - for (i = 0; i < image->height; i++) - rows[i] = (png_byte *) image->data + i * image->stride; - } + for (i = 0; i < image->height; i++) + rows[i] = (png_byte *) image->data + i * image->stride; png = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png == NULL) { @@ -184,8 +153,7 @@ png_convert_from_time_t (&pt, time (NULL)); png_set_tIME (png, info, &pt); - if (image->format == CAIRO_FORMAT_ARGB32) - png_set_write_user_transform_fn (png, unpremultiply_data); + png_set_write_user_transform_fn (png, unpremultiply_data); if (image->format == CAIRO_FORMAT_ARGB32 || image->format == CAIRO_FORMAT_RGB24) png_set_bgr (png); @@ -198,8 +166,6 @@ BAIL3: png_destroy_write_struct (&png, &info); - if (tmp_data != NULL) - free(tmp_data); BAIL2: free (rows); BAIL1: