[gs-cvs] rev 8278 - trunk/gs/src

leonardo at ghostscript.com leonardo at ghostscript.com
Wed Oct 10 01:12:50 PDT 2007


Author: leonardo
Date: 2007-10-10 01:12:49 -0700 (Wed, 10 Oct 2007)
New Revision: 8278

Modified:
   trunk/gs/src/gdevp14.c
Log:
Fix (pdf14 device) : Properly intersect rects when composing transparency buffers (continued 2).

DETAILS :

Bug 689498 "transparency: The buffer backdroping code can write outside bufers.".
Bug 688631 "PDF segfault".

This patch ports the revision 7064 changes from pdf14_put_image to
pdf14_cmykspot_put_image and pdf14_custom_put_image, which were added 
after the revision 7064. They need same improvement, which was mised
due to a development miscoordination.

This change is committed without any testing,
because the author has no test cases which involve
pdf14_cmykspot_put_image and pdf14_custom_put_image.
Possibly they need to build Ghostscript with special options 
and to run the test case of the bug 688631 with special devices.
The bug 689498 is passed to Suport for further processing and testing.

EXPECTED DIFFERENCES :

None,


Modified: trunk/gs/src/gdevp14.c
===================================================================
--- trunk/gs/src/gdevp14.c	2007-10-09 19:33:27 UTC (rev 8277)
+++ trunk/gs/src/gdevp14.c	2007-10-10 08:12:49 UTC (rev 8278)
@@ -1330,13 +1330,15 @@
 {
     pdf14_device * pdev = (pdf14_device *)dev;
     int code = 0;
-    int width = pdev->width;
-    int height = pdev->height;
     int x, y, tmp, comp_num, output_comp_num;
     pdf14_buf *buf = pdev->ctx->stack;
+    int x1 = min(pdev->width, buf->rect.q.x);
+    int y1 = min(pdev->height, buf->rect.q.y);
+    int width = x1 - buf->rect.p.x;
+    int height = y1 - buf->rect.p.y;
     int planestride = buf->planestride;
     int num_comp = buf->n_chan - 1;
-    byte *buf_ptr = buf->data;
+    byte *buf_ptr = buf->data + buf->rect.p.y * buf->rowstride + buf->rect.p.x;
     const byte bg = pdev->ctx->additive ? gx_max_color_value : 0;
     gx_color_index color;
     gx_color_value cv[GX_DEVICE_COLOR_MAX_COMPONENTS];
@@ -1413,7 +1415,8 @@
 		}
 	    }
 	    color = dev_proc(target, encode_color)(target, cv);
-	    code = dev_proc(target, fill_rectangle)(target, x, y, 1, 1, color);
+	    code = dev_proc(target, fill_rectangle)(target, x + buf->rect.p.x, 
+							    y + buf->rect.p.y, 1, 1, color);
 	}
 
 	buf_ptr += buf->rowstride;
@@ -1438,13 +1441,15 @@
 {
     pdf14_device * pdev = (pdf14_device *)dev;
     int code = 0;
-    int width = pdev->width;
-    int height = pdev->height;
     int x, y, tmp, comp_num;
     pdf14_buf *buf = pdev->ctx->stack;
+    int x1 = min(pdev->width, buf->rect.q.x);
+    int y1 = min(pdev->height, buf->rect.q.y);
+    int width = x1 - buf->rect.p.x;
+    int height = y1 - buf->rect.p.y;
     int planestride = buf->planestride;
     int num_comp = buf->n_chan - 1;
-    byte *buf_ptr = buf->data;
+    byte *buf_ptr = buf->data + buf->rect.p.y * buf->rowstride + buf->rect.p.x;
     const byte bg = pdev->ctx->additive ? gx_max_color_value : 0;
     gx_color_index color;
     gx_color_value cv[GX_DEVICE_COLOR_MAX_COMPONENTS];
@@ -1479,7 +1484,8 @@
 		}
 	    }
 	    color = dev_proc(target, encode_color)(target, cv);
-	    code = dev_proc(target, fill_rectangle)(target, x, y, 1, 1, color);
+	    code = dev_proc(target, fill_rectangle)(target, x + buf->rect.p.x, 
+							    y + buf->rect.p.y, 1, 1, color);
 	}
 
 	buf_ptr += buf->rowstride;



More information about the gs-cvs mailing list