Re: Fix for 687451 default resolution for displaydevice
"Russell Lang" <[email protected]> Fri, 02 Jul 2004 17:59:45 +1000
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <40E5A291.32681.90428FE0@localhost> |
Igor, Yes, it is a nasty hack. I was trying to avoid making incompatible changes to the display callbacks. Adding separations to the display device (a patch to come soon) does require a new callback. So adding another one for this at the same time is not a problem. I'll submit another patch for the display default resolution that uses a new callback and is more reliable. If there are any other changes that you want that would require changes to the callbacks, now is the time to speak. I personally would like to add a callback for setting the display format and/or handle. This isn't needed for ghostscript, but would be helpful for ghostpcl. Russell > IMO tricks with GS parameter recognition and substitution is a > kind of hack with an unpredictably small life time. > A right way is to improve the display_open callback > with an argument for passing the resolution, alpha, etc., > form the client to Ghostscript. > Likely this also affects display_set_color_format. > > Igor. > > ----- Original Message ----- > From: "Russell Lang" <[email protected]> > To: <[email protected]> > Sent: Thursday, July 01, 2004 6:01 AM > Subject: [gs-code-review] Fix for 687451 default resolution for displaydevice > > > > Log Message: > > Set the display resolution from the MS-Windows display resolution. > > Fixes bug Bug 687451 "default resolution for display device" > > > > DETAILS: > > This affects Windows only and can't be built into the > > display device, since this code is platform independent. > > The implementation checks the command line to see if the > > display device is used and resolution is not specified, > > and if so adds the resolution from Windows LOGPIXELSY > > to the command line. > > This could be confused by various means, including setting > > the device and resolution with PostScript code on the > > command line. > > The default Windows display resolution is 96dpi (the same > > as the display device). This can be changed to 120dpi by > > selecting "large fonts", or other values in recent versions > > of Windows. > > > > > > Russell Lang [email protected] > > > > > > > > > > > -------------------------------------------------------------------------------- > > > > diff -u /cvs/gs/src/dwmain.c src/dwmain.c > > --- /cvs/gs/src/dwmain.c Mon Jun 21 05:33:38 2004 > > +++ src/dwmain.c Thu Jul 01 01:27:03 2004 > > @@ -1,4 +1,4 @@ > > -/* Copyright (C) 1996-2001 Ghostgum Software Pty Ltd. All rights reserved. > > +/* Copyright (C) 1996-2004 Ghostgum Software Pty Ltd. All rights reserved. > > > > This software is provided AS-IS with no warranty, either express or > > implied. > > @@ -255,6 +255,11 @@ > > char **nargv; > > char dformat[64]; > > char buf[256]; > > + char ddpi[64]; > > + int dpi; > > + int use_dpi = 1; > > + int extra_args = 1; > > + int i; > > > > memset(buf, 0, sizeof(buf)); > > if (load_dll(&gsdll, buf, sizeof(buf))) { > > @@ -283,6 +288,7 @@ > > DISPLAY_DEPTH_1 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST; > > HDC hdc = GetDC(NULL); /* get hdc for desktop */ > > int depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL); > > + dpi = GetDeviceCaps(hdc, LOGPIXELSY); > > ReleaseDC(NULL, hdc); > > if (depth == 32) > > format = DISPLAY_COLORS_RGB | DISPLAY_UNUSED_LAST | > > @@ -302,11 +308,30 @@ > > DISPLAY_DEPTH_4 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST; > > sprintf(dformat, "-dDisplayFormat=%d", format); > > } > > - nargc = argc + 1; > > - nargv = (char **)malloc((nargc + 1) * sizeof(char *)); > > + /* If using display device, and resolution not specified, > > + * use the resolution reported by Windows. > > + */ > > + for (i=1; i<argc; i++) { > > + if (argv[i][0] == '@') > > + use_dpi = 0; /* dpi or device could be specified in config file */ > > + if ((strncmp(argv[i], "-sDEVICE=", 9) == 0) && > > + (strcmp(argv[i], "-sDEVICE=display") != 0)) > > + use_dpi = 0; /* not display device */ > > + if (strncmp(argv[i], "-r", 2) == 0) > > + use_dpi = 0; /* dpi already specified */ > > + } > > + if (use_dpi) { > > + sprintf(ddpi, "-r%d", dpi); > > + extra_args++; > > + } > > + > > + nargc = argc + extra_args; > > + nargv = (char **)malloc((nargc + extra_args) * sizeof(char *)); > > nargv[0] = argv[0]; > > nargv[1] = dformat; > > - memcpy(&nargv[2], &argv[1], argc * sizeof(char *)); > > + if (use_dpi) > > + nargv[2] = ddpi; > > + memcpy(&nargv[extra_args+1], &argv[1], argc * sizeof(char *)); > > > > code = gsdll.init_with_args(instance, nargc, nargv); > > if (code == 0) > > diff -u /cvs/gs/src/dwmainc.c src/dwmainc.c > > --- /cvs/gs/src/dwmainc.c Mon Jun 21 05:36:29 2004 > > +++ src/dwmainc.c Thu Jul 01 01:26:22 2004 > > @@ -1,4 +1,4 @@ > > -/* Copyright (C) 1996-2001 Ghostgum Software Pty Ltd. All rights reserved. > > +/* Copyright (C) 1996-2004 Ghostgum Software Pty Ltd. All rights reserved. > > > > This software is provided AS-IS with no warranty, either express or > > implied. > > @@ -313,6 +313,11 @@ > > char **nargv; > > char buf[256]; > > char dformat[64]; > > + char ddpi[64]; > > + int dpi; > > + int use_dpi = 1; > > + int extra_args = 1; > > + int i; > > > > if (!_isatty(fileno(stdin))) > > _setmode(fileno(stdin), _O_BINARY); > > @@ -363,6 +368,7 @@ > > DISPLAY_DEPTH_1 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST; > > HDC hdc = GetDC(NULL); /* get hdc for desktop */ > > int depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL); > > + dpi = GetDeviceCaps(hdc, LOGPIXELSY); > > ReleaseDC(NULL, hdc); > > if (depth == 32) > > format = DISPLAY_COLORS_RGB | DISPLAY_UNUSED_LAST | > > @@ -382,11 +388,30 @@ > > DISPLAY_DEPTH_4 | DISPLAY_LITTLEENDIAN | DISPLAY_BOTTOMFIRST; > > sprintf(dformat, "-dDisplayFormat=%d", format); > > } > > - nargc = argc + 1; > > - nargv = (char **)malloc((nargc + 1) * sizeof(char *)); > > + /* If using display device, and resolution not specified, > > + * use the resolution reported by Windows. > > + */ > > + for (i=1; i<argc; i++) { > > + if (argv[i][0] == '@') > > + use_dpi = 0; /* dpi or device could be specified in config file */ > > + if ((strncmp(argv[i], "-sDEVICE=", 9) == 0) && > > + (strcmp(argv[i], "-sDEVICE=display") != 0)) > > + use_dpi = 0; /* not display device */ > > + if (strncmp(argv[i], "-r", 2) == 0) > > + use_dpi = 0; /* dpi already specified */ > > + } > > + if (use_dpi) { > > + sprintf(ddpi, "-r%d", dpi); > > + extra_args++; > > + } > > + > > + nargc = argc + extra_args; > > + nargv = (char **)malloc((nargc + extra_args) * sizeof(char *)); > > nargv[0] = argv[0]; > > nargv[1] = dformat; > > - memcpy(&nargv[2], &argv[1], argc * sizeof(char *)); > > + if (use_dpi) > > + nargv[2] = ddpi; > > + memcpy(&nargv[extra_args+1], &argv[1], argc * sizeof(char *)); > > > > code = gsdll.init_with_args(instance, nargc, nargv); > > if (code == 0) > > > > > -------------------------------------------------------------------------------- > > > > _______________________________________________ > > gs-code-review mailing list > > [email protected] > > http://www.ghostscript.com/mailman/listinfo/gs-code-review > >