Don't add spaces in the PostScript between every pixel - this made

debugging easier but results in an awful lot of whitespace being sent
to the printer.
Don't generate the %%Orientation DSC comment.  The cups pstops filter
tries to rotate the image by 90degs when to it sees this comment.
Stop a crash if the document title is NULL.
This commit is contained in:
Huw Davies 2003-05-19 23:21:56 +00:00 committed by Alexandre Julliard
parent 5e63af58a0
commit 4bc46368d5
1 changed files with 35 additions and 32 deletions

View File

@ -31,13 +31,12 @@
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
static char psheader[] = /* title llx lly urx ury orientation */ static char psheader[] = /* title llx lly urx ury */
"%%!PS-Adobe-3.0\n" "%%!PS-Adobe-3.0\n"
"%%%%Creator: Wine PostScript Driver\n" "%%%%Creator: Wine PostScript Driver\n"
"%%%%Title: %s\n" "%%%%Title: %s\n"
"%%%%BoundingBox: %d %d %d %d\n" "%%%%BoundingBox: %d %d %d %d\n"
"%%%%Pages: (atend)\n" "%%%%Pages: (atend)\n"
"%%%%Orientation: %s\n"
"%%%%EndComments\n"; "%%%%EndComments\n";
static char psbeginprolog[] = static char psbeginprolog[] =
@ -231,15 +230,15 @@ INT PSDRV_WriteFeature(HANDLE16 hJob, char *feature, char *value,
INT PSDRV_WriteHeader( PSDRV_PDEVICE *physDev, LPCSTR title ) INT PSDRV_WriteHeader( PSDRV_PDEVICE *physDev, LPCSTR title )
{ {
char *buf, *orient; char *buf;
INPUTSLOT *slot; INPUTSLOT *slot;
PAGESIZE *page; PAGESIZE *page;
int llx, lly, urx, ury; int llx, lly, urx, ury;
TRACE("'%s'\n", title); TRACE("'%s'\n", debugstr_a(title));
buf = (char *)HeapAlloc( PSDRV_Heap, 0, sizeof(psheader) + buf = (char *)HeapAlloc( PSDRV_Heap, 0, sizeof(psheader) +
strlen(title) + 30 ); (title ? strlen(title) : 0) + 30 );
if(!buf) { if(!buf) {
WARN("HeapAlloc failed\n"); WARN("HeapAlloc failed\n");
return 0; return 0;
@ -251,16 +250,9 @@ INT PSDRV_WriteHeader( PSDRV_PDEVICE *physDev, LPCSTR title )
lly = physDev->ImageableArea.bottom * 72.0 / physDev->logPixelsY; lly = physDev->ImageableArea.bottom * 72.0 / physDev->logPixelsY;
urx = physDev->ImageableArea.right * 72.0 / physDev->logPixelsX; urx = physDev->ImageableArea.right * 72.0 / physDev->logPixelsX;
ury = physDev->ImageableArea.top * 72.0 / physDev->logPixelsY; ury = physDev->ImageableArea.top * 72.0 / physDev->logPixelsY;
if(physDev->Devmode->dmPublic.u1.s1.dmOrientation == DMORIENT_LANDSCAPE) {
orient = "Landscape";
} else {
orient = "Portrait";
}
/* FIXME should do something better with BBox */ /* FIXME should do something better with BBox */
sprintf(buf, psheader, title, llx, lly, urx, ury, orient); sprintf(buf, psheader, title ? title : "", llx, lly, urx, ury);
if( WriteSpool16( physDev->job.hJob, buf, strlen(buf) ) != if( WriteSpool16( physDev->job.hJob, buf, strlen(buf) ) !=
strlen(buf) ) { strlen(buf) ) {
@ -668,12 +660,14 @@ BOOL PSDRV_WriteBytes(PSDRV_PDEVICE *physDev, const BYTE *bytes, int number)
ptr = buf; ptr = buf;
for(i = 0; i < number; i++) { for(i = 0; i < number; i++) {
sprintf(ptr, "%02x%c", bytes[i], sprintf(ptr, "%02x", bytes[i]);
((i & 0xf) == 0xf) || (i == number - 1) ? '\n' : ' '); ptr += 2;
ptr += 3; if(((i & 0xf) == 0xf) || (i == number - 1)) {
strcpy(ptr, "\n");
ptr++;
} }
PSDRV_WriteSpool(physDev, buf, number * 3); }
PSDRV_WriteSpool(physDev, buf, ptr - buf);
HeapFree(PSDRV_Heap, 0, buf); HeapFree(PSDRV_Heap, 0, buf);
return TRUE; return TRUE;
} }
@ -697,11 +691,14 @@ BOOL PSDRV_WriteDIBits16(PSDRV_PDEVICE *physDev, const WORD *words, int number)
g = g << 3 | g >> 2; g = g << 3 | g >> 2;
b = words[i] & 0x1f; b = words[i] & 0x1f;
b = b << 3 | b >> 2; b = b << 3 | b >> 2;
sprintf(ptr, "%02x%02x%02x%c", r, g, b, sprintf(ptr, "%02x%02x%02x", r, g, b);
((i & 0x7) == 0x7) || (i == number - 1) ? '\n' : ' '); ptr += 6;
ptr += 7; if(((i & 0x7) == 0x7) || (i == number - 1)) {
strcpy(ptr, "\n");
ptr++;
} }
PSDRV_WriteSpool(physDev, buf, number * 7); }
PSDRV_WriteSpool(physDev, buf, ptr - buf);
HeapFree(PSDRV_Heap, 0, buf); HeapFree(PSDRV_Heap, 0, buf);
return TRUE; return TRUE;
@ -716,12 +713,15 @@ BOOL PSDRV_WriteDIBits24(PSDRV_PDEVICE *physDev, const BYTE *bits, int number)
ptr = buf; ptr = buf;
for(i = 0; i < number; i++) { for(i = 0; i < number; i++) {
sprintf(ptr, "%02x%02x%02x%c", bits[i * 3 + 2], bits[i * 3 + 1], sprintf(ptr, "%02x%02x%02x", bits[i * 3 + 2], bits[i * 3 + 1],
bits[i * 3], bits[i * 3]);
((i & 0x7) == 0x7) || (i == number - 1) ? '\n' : ' '); ptr += 6;
ptr += 7; if(((i & 0x7) == 0x7) || (i == number - 1)) {
strcpy(ptr, "\n");
ptr++;
} }
PSDRV_WriteSpool(physDev, buf, number * 7); }
PSDRV_WriteSpool(physDev, buf, ptr - buf);
HeapFree(PSDRV_Heap, 0, buf); HeapFree(PSDRV_Heap, 0, buf);
return TRUE; return TRUE;
@ -736,12 +736,15 @@ BOOL PSDRV_WriteDIBits32(PSDRV_PDEVICE *physDev, const BYTE *bits, int number)
ptr = buf; ptr = buf;
for(i = 0; i < number; i++) { for(i = 0; i < number; i++) {
sprintf(ptr, "%02x%02x%02x%c", bits[i * 4 + 2], bits[i * 4 + 1], sprintf(ptr, "%02x%02x%02x", bits[i * 4 + 2], bits[i * 4 + 1],
bits[i * 4], bits[i * 4]);
((i & 0x7) == 0x7) || (i == number - 1) ? '\n' : ' '); ptr += 6;
ptr += 7; if(((i & 0x7) == 0x7) || (i == number - 1)) {
strcpy(ptr, "\n");
ptr++;
} }
PSDRV_WriteSpool(physDev, buf, number * 7); }
PSDRV_WriteSpool(physDev, buf, ptr - buf);
HeapFree(PSDRV_Heap, 0, buf); HeapFree(PSDRV_Heap, 0, buf);
return TRUE; return TRUE;