summaryrefslogtreecommitdiff
path: root/print/ghostscript-gpl/files/patch-lips:gdevl4r.c
blob: e7ab9d0ecbe260d4081e79d1956b6ff8d10856d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
--- lips/gdevl4r.c.orig	Thu Nov  2 12:09:18 2000
+++ lips/gdevl4r.c	Fri Dec 17 19:19:02 2004
@@ -53,8 +53,8 @@
 #define lips_device(dtype, procs, dname, xdpi, ydpi, lm, bm, rm, tm, color_bits,\
 		    print_page_copies, image_out, cassetFeed, username)\
 {        std_device_std_color_full_body(dtype, &procs, dname,\
-          (int)((long)(DEFAULT_WIDTH_10THS) * (xdpi) / 10),\
-          (int)((long)(DEFAULT_HEIGHT_10THS) * (ydpi) / 10),\
+          (int)((long)((DEFAULT_WIDTH_10THS) * (xdpi)) / 10),\
+          (int)((long)((DEFAULT_HEIGHT_10THS) * (ydpi)) / 10),\
           xdpi, ydpi, color_bits,\
           -(lm) * (xdpi), -(tm) * (ydpi),\
           (lm) * 72.0, (bm) * 72.0,\
@@ -68,8 +68,8 @@
 #define lips4_device(dtype, procs, dname, xdpi, ydpi, lm, bm, rm, tm, color_bits,\
 		    print_page_copies, image_out, cassetFeed, username)\
 {        std_device_std_color_full_body(dtype, &procs, dname,\
-          (int)((long)(DEFAULT_WIDTH_10THS) * (xdpi) / 10),\
-          (int)((long)(DEFAULT_HEIGHT_10THS) * (ydpi) / 10),\
+          (int)((long)((DEFAULT_WIDTH_10THS) * (xdpi)) / 10),\
+          (int)((long)((DEFAULT_HEIGHT_10THS) * (ydpi)) / 10),\
           xdpi, ydpi, color_bits,\
           -(lm) * (xdpi), -(tm) * (ydpi),\
           (lm) * 72.0, (bm) * 72.0,\
@@ -178,8 +178,13 @@
 private int lips4c_output_page(gx_device_printer * pdev, FILE * prn_stream);
 private int lips_delta_encode(byte * inBuff, byte * prevBuff, byte * outBuff, byte * diffBuff, int Length);
 private int lips_byte_cat(byte * TotalBuff, byte * Buff, int TotalLen, int Len);
+#if GS_VERSION_MAJOR >= 8
+private int lips_print_page_copies(gx_device_printer * pdev, FILE * prn_stream, lips_printer_type ptype, int numcopies);
+private int lips_print_page_copies(gx_device_printer * pdev, FILE * prn_stream, lips_printer_type ptype, int numcopies);
+#else
 private int lips_print_page_copies(P4(gx_device_printer * pdev, FILE * prn_stream, lips_printer_type ptype, int numcopies));
 private int lips_print_page_copies(P4(gx_device_printer * pdev, FILE * prn_stream, lips_printer_type ptype, int numcopies));
+#endif
 private int lips4type_print_page_copies(gx_device_printer * pdev, FILE * prn_stream, int num_copies, int ptype);
 
 private int
@@ -597,7 +602,7 @@
     /* Initialize printer. */
     lips_job_start(pdev, ptype, prn_stream, num_copies);
 
-    if (!(lprn->CompBuf = gs_malloc(bpl * 3 / 2 + 1, maxY, "(CompBuf)")))
+    if (!(lprn->CompBuf = gs_malloc(pdev->memory, bpl * 3 / 2 + 1, maxY, "(CompBuf)")))
 	return_error(gs_error_VMerror);
 
 
@@ -607,7 +612,7 @@
     if (code < 0)
 	return code;
 
-    gs_free(lprn->CompBuf, bpl * 3 / 2 + 1, maxY, "(CompBuf)");
+    gs_free(pdev->memory, lprn->CompBuf, bpl * 3 / 2 + 1, maxY, "(CompBuf)");
 
     /* eject page */
     lips_job_end(pdev, prn_stream);
@@ -641,9 +646,9 @@
 
     if (pdev->color_info.depth == 1)
       {
-	if (!(lprn->CompBuf = gs_malloc(bpl * 3 / 2 + 1, maxY, "(CompBuf)")))
+	if (!(lprn->CompBuf = gs_malloc(pdev->memory, bpl * 3 / 2 + 1, maxY, "(CompBuf)")))
 	  return_error(gs_error_VMerror);
-	if (!(lprn->CompBuf2 = gs_malloc(bpl * 3 / 2 + 1, maxY, "(CompBuf2)")))
+	if (!(lprn->CompBuf2 = gs_malloc(pdev->memory, bpl * 3 / 2 + 1, maxY, "(CompBuf2)")))
 	  return_error(gs_error_VMerror);
 
 	if (lprn->NegativePrint) {
@@ -663,8 +668,8 @@
 	if (code < 0)
 	  return code;
 	
-	gs_free(lprn->CompBuf, bpl * 3 / 2 + 1, maxY, "(CompBuf)");
-	gs_free(lprn->CompBuf2, bpl * 3 / 2 + 1, maxY, "(CompBuf2)");
+	gs_free(pdev->memory, lprn->CompBuf, bpl * 3 / 2 + 1, maxY, "(CompBuf)");
+	gs_free(pdev->memory, lprn->CompBuf2, bpl * 3 / 2 + 1, maxY, "(CompBuf2)");
       }
     else
       {
@@ -903,15 +908,15 @@
     int lnum = 0;
 
     /* Memory Allocate */
-    if (!(pBuff = (byte *) gs_malloc(nBytesPerLine, sizeof(byte), "lips4c_compress_output_page(pBuff)")))
+    if (!(pBuff = (byte *) gs_malloc(pdev->memory, nBytesPerLine, sizeof(byte), "lips4c_compress_output_page(pBuff)")))
 	return_error(gs_error_VMerror);
-    if (!(prevBuff = (byte *) gs_malloc(nBytesPerLine, sizeof(byte), "lips4c_compress_output_page(prevBuff)")))
+    if (!(prevBuff = (byte *) gs_malloc(pdev->memory, nBytesPerLine, sizeof(byte), "lips4c_compress_output_page(prevBuff)")))
 	return_error(gs_error_VMerror);
-    if (!(ComBuff = (byte *) gs_malloc(Xpixel * num_components + (Xpixel * num_components + 127) * 129 / 128, sizeof(byte), "lips4c_compress_output_page(ComBuff)")))
+    if (!(ComBuff = (byte *) gs_malloc(pdev->memory, Xpixel * num_components + (Xpixel * num_components + 127) * 129 / 128, sizeof(byte), "lips4c_compress_output_page(ComBuff)")))
 	return_error(gs_error_VMerror);
-    if (!(TotalBuff = (byte *) gs_malloc((Xpixel * num_components + (Xpixel * num_components + 127) * 129 / 128) * NUM_LINES_4C, sizeof(byte), "lips4c_compress_output_page(TotalBuff)")))
+    if (!(TotalBuff = (byte *) gs_malloc(pdev->memory, (Xpixel * num_components + (Xpixel * num_components + 127) * 129 / 128) * NUM_LINES_4C, sizeof(byte), "lips4c_compress_output_page(TotalBuff)")))
 	return_error(gs_error_VMerror);
-    if (!(diffBuff = (byte *) gs_malloc(Xpixel * num_components * 2, sizeof(byte), "lips_print_page")))
+    if (!(diffBuff = (byte *) gs_malloc(pdev->memory, Xpixel * num_components * 2, sizeof(byte), "lips_print_page")))
 	return_error(gs_error_VMerror);
 
     /* make output data */
@@ -927,11 +932,11 @@
 			    pdev->height - (lnum - NUM_LINES_4C));
     }
     /* Free Memory */
-    gs_free(pBuff, nBytesPerLine, sizeof(byte), "lips4c_compress_output_page(pBuff)");
-    gs_free(prevBuff, nBytesPerLine, sizeof(byte), "lips4c_compress_output_page(prevBuff)");
-    gs_free(ComBuff, Xpixel * num_components + (Xpixel * num_components + 127) * 129 / 128, sizeof(byte), "lips4c_compress_output_page(ComBuff)");
-    gs_free(TotalBuff, (Xpixel * num_components + (Xpixel * num_components + 127) * 129 / 128) * NUM_LINES_4C, sizeof(byte), "lips4c_compress_output_page(TotalBuff)");
-    gs_free(diffBuff, Xpixel * num_components * 2, sizeof(byte), "lips_print_page");
+    gs_free(pdev->memory, pBuff, nBytesPerLine, sizeof(byte), "lips4c_compress_output_page(pBuff)");
+    gs_free(pdev->memory, prevBuff, nBytesPerLine, sizeof(byte), "lips4c_compress_output_page(prevBuff)");
+    gs_free(pdev->memory, ComBuff, Xpixel * num_components + (Xpixel * num_components + 127) * 129 / 128, sizeof(byte), "lips4c_compress_output_page(ComBuff)");
+    gs_free(pdev->memory, TotalBuff, (Xpixel * num_components + (Xpixel * num_components + 127) * 129 / 128) * NUM_LINES_4C, sizeof(byte), "lips4c_compress_output_page(TotalBuff)");
+    gs_free(pdev->memory, diffBuff, Xpixel * num_components * 2, sizeof(byte), "lips_print_page");
 
     return 0;
 }
@@ -1065,11 +1070,25 @@
 	if (paper_size == USER_SIZE) {
 	    fprintf(prn_stream, "%c2 I", LIPS_CSI);
 	    fprintf(prn_stream, "%c80;%d;%dp", LIPS_CSI,
-		    width * 10, height * 10);
+		    /* modified by shige 06/27 2003
+		    width * 10, height * 10); */
+		    /* modified by shige 11/09 2003
+		    height * 10, width * 10); */
+		    (height * 10 > LIPS_HEIGHT_MAX_720)?
+		    LIPS_HEIGHT_MAX_720 : (height * 10),
+		    (width * 10 > LIPS_WIDTH_MAX_720)?
+		    LIPS_WIDTH_MAX_720 : (width * 10));
 	} else if (paper_size == USER_SIZE + LANDSCAPE) {
 	    fprintf(prn_stream, "%c2 I", LIPS_CSI);
 	    fprintf(prn_stream, "%c81;%d;%dp", LIPS_CSI,
-		    height * 10, width * 10);
+		    /* modified by shige 06/27 2003
+		    width * 10, height * 10); */
+		    /* modified by shige 11/09 2003
+		    width * 10, height * 10); */
+		    (width * 10 > LIPS_HEIGHT_MAX_720)?
+		    LIPS_HEIGHT_MAX_720 : (width * 10),
+		    (height * 10 > LIPS_WIDTH_MAX_720)?
+		    LIPS_WIDTH_MAX_720 : (height * 10));
 	} else {
 	    fprintf(prn_stream, "%c%dp", LIPS_CSI, paper_size);
 	}
@@ -1078,14 +1097,28 @@
 	    prev_paper_height != height) {
 	    fprintf(prn_stream, "%c2 I", LIPS_CSI);
 	    fprintf(prn_stream, "%c80;%d;%dp", LIPS_CSI,
-		    width * 10, height * 10);
+		    /* modified by shige 06/27 2003
+		    width * 10, height * 10); */
+		    /* modified by shige 11/09 2003
+		    height * 10, width * 10); */
+		    (height * 10 > LIPS_HEIGHT_MAX_720)?
+		    LIPS_HEIGHT_MAX_720 : (height * 10),
+		    (width * 10 > LIPS_WIDTH_MAX_720)?
+		    LIPS_WIDTH_MAX_720 : (width * 10));
 	}
     } else if (paper_size == USER_SIZE + LANDSCAPE) {
 	if (prev_paper_width != width ||
 	    prev_paper_height != height) {
 	    fprintf(prn_stream, "%c2 I", LIPS_CSI);
 	    fprintf(prn_stream, "%c81;%d;%dp", LIPS_CSI,
-		    height * 10, width * 10);
+		    /* modified by shige 06/27 2003
+		    height * 10, width * 10); */
+		    /* modified by shige 11/09 2003
+		    width * 10, height * 10); */
+		    (width * 10 > LIPS_HEIGHT_MAX_720)?
+		    LIPS_HEIGHT_MAX_720 : (width * 10),
+		    (height * 10 > LIPS_WIDTH_MAX_720)?
+		    LIPS_WIDTH_MAX_720 : (height * 10));
 	}
     }
     /* desired number of copies */