mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-22 06:30:27 +01:00
Fix to use shifts and masks for endianness-correct PS image generation. Rename bgr to rgb now that the byte order issues are clear.
This commit is contained in:
parent
9da5af44f4
commit
b95d2066a5
3 changed files with 33 additions and 28 deletions
|
|
@ -1,3 +1,10 @@
|
|||
2003-12-11 Carl Worth <cworth@east.isi.edu>
|
||||
|
||||
* src/cairo_ps_surface.c (_cairo_ps_surface_copy_page): Fix to use
|
||||
shifts and masks for endianness-correct PS image
|
||||
generation. Rename bgr to rgb now that the byte order issues are
|
||||
clear.
|
||||
|
||||
2003-12-08 Carl Worth <cworth@isi.edu>
|
||||
|
||||
* src/cairo_path_bounds.c (_cairo_path_bounder_move_to):
|
||||
|
|
|
|||
|
|
@ -286,19 +286,19 @@ _cairo_ps_surface_copy_page (void *abstract_surface)
|
|||
int i, x, y;
|
||||
|
||||
cairo_surface_t *white_surface;
|
||||
char *bgr, *compressed;
|
||||
long bgr_size, compressed_size;
|
||||
char *rgb, *compressed;
|
||||
long rgb_size, compressed_size;
|
||||
|
||||
cairo_color_t white;
|
||||
|
||||
bgr_size = 3 * width * height;
|
||||
bgr = malloc (bgr_size);
|
||||
if (bgr == NULL) {
|
||||
rgb_size = 3 * width * height;
|
||||
rgb = malloc (rgb_size);
|
||||
if (rgb == NULL) {
|
||||
status = CAIRO_STATUS_NO_MEMORY;
|
||||
goto BAIL0;
|
||||
}
|
||||
|
||||
compressed_size = (int) (1.0 + 1.1 * bgr_size);
|
||||
compressed_size = (int) (1.0 + 1.1 * rgb_size);
|
||||
compressed = malloc (compressed_size);
|
||||
if (compressed == NULL) {
|
||||
status = CAIRO_STATUS_NO_MEMORY;
|
||||
|
|
@ -330,16 +330,15 @@ _cairo_ps_surface_copy_page (void *abstract_surface)
|
|||
|
||||
i = 0;
|
||||
for (y = 0; y < height; y++) {
|
||||
char *line = surface->image->data + y * surface->image->stride;
|
||||
for (x = 0; x < width; x++) {
|
||||
unsigned char *pixel = (unsigned char *) line + x * 4;
|
||||
bgr[i++] = *(pixel+2);
|
||||
bgr[i++] = *(pixel+1);
|
||||
bgr[i++] = *(pixel);
|
||||
IcBits *pixel = (IcBits *) (surface->image->data + y * surface->image->stride);
|
||||
for (x = 0; x < width; x++, pixel++) {
|
||||
rgb[i++] = (*pixel & 0x00ff0000) >> 16;
|
||||
rgb[i++] = (*pixel & 0x0000ff00) >> 8;
|
||||
rgb[i++] = (*pixel & 0x000000ff) >> 0;
|
||||
}
|
||||
}
|
||||
|
||||
compress (compressed, &compressed_size, bgr, bgr_size);
|
||||
compress (compressed, &compressed_size, rgb, rgb_size);
|
||||
|
||||
/* Page header */
|
||||
fprintf (file, "%%%%Page: %d\n", ++surface->pages);
|
||||
|
|
@ -375,7 +374,7 @@ _cairo_ps_surface_copy_page (void *abstract_surface)
|
|||
BAIL2:
|
||||
free (compressed);
|
||||
BAIL1:
|
||||
free (bgr);
|
||||
free (rgb);
|
||||
BAIL0:
|
||||
return status;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,19 +286,19 @@ _cairo_ps_surface_copy_page (void *abstract_surface)
|
|||
int i, x, y;
|
||||
|
||||
cairo_surface_t *white_surface;
|
||||
char *bgr, *compressed;
|
||||
long bgr_size, compressed_size;
|
||||
char *rgb, *compressed;
|
||||
long rgb_size, compressed_size;
|
||||
|
||||
cairo_color_t white;
|
||||
|
||||
bgr_size = 3 * width * height;
|
||||
bgr = malloc (bgr_size);
|
||||
if (bgr == NULL) {
|
||||
rgb_size = 3 * width * height;
|
||||
rgb = malloc (rgb_size);
|
||||
if (rgb == NULL) {
|
||||
status = CAIRO_STATUS_NO_MEMORY;
|
||||
goto BAIL0;
|
||||
}
|
||||
|
||||
compressed_size = (int) (1.0 + 1.1 * bgr_size);
|
||||
compressed_size = (int) (1.0 + 1.1 * rgb_size);
|
||||
compressed = malloc (compressed_size);
|
||||
if (compressed == NULL) {
|
||||
status = CAIRO_STATUS_NO_MEMORY;
|
||||
|
|
@ -330,16 +330,15 @@ _cairo_ps_surface_copy_page (void *abstract_surface)
|
|||
|
||||
i = 0;
|
||||
for (y = 0; y < height; y++) {
|
||||
char *line = surface->image->data + y * surface->image->stride;
|
||||
for (x = 0; x < width; x++) {
|
||||
unsigned char *pixel = (unsigned char *) line + x * 4;
|
||||
bgr[i++] = *(pixel+2);
|
||||
bgr[i++] = *(pixel+1);
|
||||
bgr[i++] = *(pixel);
|
||||
IcBits *pixel = (IcBits *) (surface->image->data + y * surface->image->stride);
|
||||
for (x = 0; x < width; x++, pixel++) {
|
||||
rgb[i++] = (*pixel & 0x00ff0000) >> 16;
|
||||
rgb[i++] = (*pixel & 0x0000ff00) >> 8;
|
||||
rgb[i++] = (*pixel & 0x000000ff) >> 0;
|
||||
}
|
||||
}
|
||||
|
||||
compress (compressed, &compressed_size, bgr, bgr_size);
|
||||
compress (compressed, &compressed_size, rgb, rgb_size);
|
||||
|
||||
/* Page header */
|
||||
fprintf (file, "%%%%Page: %d\n", ++surface->pages);
|
||||
|
|
@ -375,7 +374,7 @@ _cairo_ps_surface_copy_page (void *abstract_surface)
|
|||
BAIL2:
|
||||
free (compressed);
|
||||
BAIL1:
|
||||
free (bgr);
|
||||
free (rgb);
|
||||
BAIL0:
|
||||
return status;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue