[gs-cvs] gs/src

Russell Lang ghostgum at casper.ghostscript.com
Thu Jul 18 04:11:42 PDT 2002


Update of /cvs/ghostscript/gs/src
In directory casper:/tmp/cvs-serv15132/src

Modified Files:
      Tag: GS_7_0X
	gdevbmpc.c gdevprn.h gxdevice.h 
Log Message:
Fix: When compiled for A4 default page size, the initial
page size is now 595x842pts.   The initial printer page
size in tenths of an inch now uses floating point.  This may
cause problems with old compilers that do not allow floating
point calculations in initializers for integers.  Add some
casts to suppress warnings with the MS compiler. Fixes SourceForge
bug #535997, "ps2pdf produces incorrect A4 page size".


Index: gdevbmpc.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevbmpc.c,v
retrieving revision 1.2.6.1
retrieving revision 1.2.6.2
diff -u -d -r1.2.6.1 -r1.2.6.2
--- gdevbmpc.c	22 Feb 2002 19:45:55 -0000	1.2.6.1
+++ gdevbmpc.c	18 Jul 2002 11:11:40 -0000	1.2.6.2
@@ -142,9 +142,9 @@
 	 */
 #define INCHES_PER_METER (100 /*cm/meter*/ / 2.54 /*cm/inch*/)
 	BMP_ASSIGN_DWORD(ihdr.xPelsPerMeter,
-			 (dword)(pdev->x_pixels_per_inch * INCHES_PER_METER));
+		 (dword)(pdev->x_pixels_per_inch * INCHES_PER_METER + 0.5));
 	BMP_ASSIGN_DWORD(ihdr.yPelsPerMeter,
-			 (dword)(pdev->y_pixels_per_inch * INCHES_PER_METER));
+		 (dword)(pdev->y_pixels_per_inch * INCHES_PER_METER + 0.5));
 #undef INCHES_PER_METER
 	BMP_ASSIGN_DWORD(ihdr.clrUsed, 0);
 	BMP_ASSIGN_DWORD(ihdr.clrImportant, 0);

Index: gdevprn.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevprn.h,v
retrieving revision 1.6.6.1
retrieving revision 1.6.6.2
diff -u -d -r1.6.6.1 -r1.6.6.2
--- gdevprn.h	22 Feb 2002 19:45:56 -0000	1.6.6.1
+++ gdevprn.h	18 Jul 2002 11:11:40 -0000	1.6.6.2
@@ -393,13 +393,13 @@
 /* This accounts for the short parameter names here and below. */
 #define prn_device_margins_body(dtype, procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)\
 	std_device_full_body_type(dtype, &procs, dname, &st_device_printer,\
-	  (int)((long)(w10) * (xdpi) / 10),\
-	  (int)((long)(h10) * (ydpi) / 10),\
+	  (int)((float)(w10) * (xdpi) / 10 + 0.5),\
+	  (int)((float)(h10) * (ydpi) / 10 + 0.5),\
 	  xdpi, ydpi,\
 	  ncomp, depth, mg, mc, dg, dc,\
-	  -(lo) * (xdpi), -(to) * (ydpi),\
-	  (lm) * 72.0, (bm) * 72.0,\
-	  (rm) * 72.0, (tm) * 72.0\
+	  (float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
+	  (float)((lm) * 72.0), (float)((bm) * 72.0),\
+	  (float)((rm) * 72.0), (float)((tm) * 72.0)\
 	),\
 	prn_device_body_rest_(print_page)
 
@@ -409,12 +409,12 @@
 
 #define prn_device_std_margins_body(dtype, procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page)\
 	std_device_std_color_full_body_type(dtype, &procs, dname, &st_device_printer,\
-	  (int)((long)(w10) * (xdpi) / 10),\
-	  (int)((long)(h10) * (ydpi) / 10),\
+	  (int)((float)(w10) * (xdpi) / 10 + 0.5),\
+	  (int)((float)(h10) * (ydpi) / 10 + 0.5),\
 	  xdpi, ydpi, color_bits,\
-	  -(lo) * (xdpi), -(to) * (ydpi),\
-	  (lm) * 72.0, (bm) * 72.0,\
-	  (rm) * 72.0, (tm) * 72.0\
+	  (float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
+	  (float)((lm) * 72.0), (float)((bm) * 72.0),\
+	  (float)((rm) * 72.0), (float)((tm) * 72.0)\
 	),\
 	prn_device_body_rest_(print_page)
 
@@ -424,12 +424,12 @@
 
 #define prn_device_std_margins_body_copies(dtype, procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page_copies)\
 	std_device_std_color_full_body_type(dtype, &procs, dname, &st_device_printer,\
-	  (int)((long)(w10) * (xdpi) / 10),\
-	  (int)((long)(h10) * (ydpi) / 10),\
+	  (int)((float)(w10) * (xdpi) / 10 + 0.5),\
+	  (int)((float)(h10) * (ydpi) / 10 + 0.5),\
 	  xdpi, ydpi, color_bits,\
-	  -(lo) * (xdpi), -(to) * (ydpi),\
-	  (lm) * 72.0, (bm) * 72.0,\
-	  (rm) * 72.0, (tm) * 72.0\
+	  (float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
+	  (float)((lm) * 72.0), (float)((bm) * 72.0),\
+	  (float)((rm) * 72.0), (float)((tm) * 72.0)\
 	),\
 	prn_device_body_copies_rest_(print_page_copies)
 

Index: gxdevice.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxdevice.h,v
retrieving revision 1.4.6.2
retrieving revision 1.4.6.3
diff -u -d -r1.4.6.2 -r1.4.6.3
--- gxdevice.h	22 Feb 2002 19:45:58 -0000	1.4.6.2
+++ gxdevice.h	18 Jul 2002 11:11:40 -0000	1.4.6.3
@@ -52,9 +52,9 @@
 /* U.S. letter paper (8.5" x 11"). */
 #define DEFAULT_WIDTH_10THS_US_LETTER 85
 #define DEFAULT_HEIGHT_10THS_US_LETTER 110
-/* A4 paper (210mm x 297mm).  The dimensions are off by a few mm.... */
-#define DEFAULT_WIDTH_10THS_A4 83
-#define DEFAULT_HEIGHT_10THS_A4 117
+/* A4 paper (210mm x 297mm), we use 595pt x 842pt. */
+#define DEFAULT_WIDTH_10THS_A4 82.6389
+#define DEFAULT_HEIGHT_10THS_A4 116.9444
 /* Choose a default.  A4 may be set in the makefile. */
 #ifdef A4
 #  define DEFAULT_WIDTH_10THS DEFAULT_WIDTH_10THS_A4
@@ -76,6 +76,7 @@
  * but some compilers (the Ultrix 3.X pcc compiler and the HPUX compiler)
  * can't cast a computed float to an int.  That's why we specify
  * the page width and height in inches/10 instead of inches.
+ * This has been now been changed to use floats.
  *
  * Note that the macro is broken up so as to be usable for devices that
  * add further initialized state to the generic device.
@@ -94,8 +95,8 @@
  */
 #define std_device_part2_(width, height, x_dpi, y_dpi)\
 	{ gx_no_color_index, gx_no_color_index }, width, height,\
-	{ (((width) * 72.0 + 0.5) - 0.5) / (x_dpi)/*MediaSize[0]*/,\
-	  (((height) * 72.0 + 0.5) - 0.5) / (y_dpi)/*MediaSize[1]*/},\
+	{ (float)((((width) * 72.0 + 0.5) - 0.5) / (x_dpi))/*MediaSize[0]*/,\
+	  (float)((((height) * 72.0 + 0.5) - 0.5) / (y_dpi))/*MediaSize[1]*/},\
 	{ 0, 0, 0, 0 }/*ImagingBBox*/, 0/*ImagingBBox_set*/,\
 	{ x_dpi, y_dpi }/*HWResolution*/, { x_dpi, y_dpi }/*MarginsHWResolution*/
 




More information about the gs-cvs mailing list