[cairo-commit] cairo/src cairo_ps_surface.c,1.4,1.5

Carl Worth commit at pdx.freedesktop.org
Thu Dec 11 07:03:43 PST 2003


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory pdx:/tmp/cvs-serv28342/src

Modified Files:
	cairo_ps_surface.c 
Log Message:

        * 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.


Index: cairo_ps_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_ps_surface.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** cairo_ps_surface.c	4 Nov 2003 03:17:31 -0000	1.4
--- cairo_ps_surface.c	11 Dec 2003 15:03:41 -0000	1.5
***************
*** 287,303 ****
  
      cairo_surface_t *white_surface;
!     char *bgr, *compressed;
!     long bgr_size, compressed_size;
  
      cairo_color_t white;
  
!     bgr_size = 3 * width * height;
!     bgr = malloc (bgr_size);
!     if (bgr == NULL) {
  	status = CAIRO_STATUS_NO_MEMORY;
  	goto BAIL0;
      }
  
!     compressed_size = (int) (1.0 + 1.1 * bgr_size);
      compressed = malloc (compressed_size);
      if (compressed == NULL) {
--- 287,303 ----
  
      cairo_surface_t *white_surface;
!     char *rgb, *compressed;
!     long rgb_size, compressed_size;
  
      cairo_color_t white;
  
!     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 * rgb_size);
      compressed = malloc (compressed_size);
      if (compressed == NULL) {
***************
*** 331,344 ****
      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);
  	}
      }
  
!     compress (compressed, &compressed_size, bgr, bgr_size);
  
      /* Page header */
--- 331,343 ----
      i = 0;
      for (y = 0; y < height; y++) {
! 	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, rgb, rgb_size);
  
      /* Page header */
***************
*** 376,380 ****
      free (compressed);
      BAIL1:
!     free (bgr);
      BAIL0:
      return status;
--- 375,379 ----
      free (compressed);
      BAIL1:
!     free (rgb);
      BAIL0:
      return status;





More information about the cairo-commit mailing list