home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gs252src.zip / GS252 / GSDEVICE.C < prev    next >
C/C++ Source or Header  |  1992-09-09  |  17KB  |  595 lines

  1. /* Copyright (C) 1989, 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gsdevice.c */
  21. /* Device operators for Ghostscript library */
  22. #include "math_.h"            /* for fabs */
  23. #include "memory_.h"            /* for memcpy */
  24. #include "gx.h"
  25. #include "gserrors.h"
  26. #include "gsprops.h"
  27. #include "gsutil.h"
  28. #include "gxarith.h"
  29. #include "gxfixed.h"            /* ditto */
  30. #include "gxmatrix.h"            /* for gzstate.h */
  31. #include "gzstate.h"
  32. #include "gzdevice.h"
  33. #include "gxdevmem.h"
  34.  
  35. /* Import the device list from gdevs.c */
  36. extern gx_device *gx_device_list[];
  37.  
  38. /* Device definitions */
  39. /* Following defines the null device */
  40. private dev_proc_fill_rectangle(null_fill_rectangle);
  41. private dev_proc_tile_rectangle(null_tile_rectangle);
  42. private dev_proc_copy_mono(null_copy_mono);
  43. private dev_proc_draw_line(null_draw_line);
  44.  
  45. private gx_device_procs null_procs = {
  46.     gx_default_open_device,
  47.     gx_default_get_initial_matrix,
  48.     gx_default_sync_output,
  49.     gx_default_output_page,
  50.     gx_default_close_device,
  51.     gx_default_map_rgb_color,
  52.     gx_default_map_color_rgb,
  53.     null_fill_rectangle,
  54.     null_tile_rectangle,
  55.     null_copy_mono,
  56.     gx_default_copy_color,
  57.     null_draw_line,
  58.     gx_default_get_bits,
  59.     gx_default_get_props,
  60.     gx_default_put_props
  61. };
  62. private gx_device null_device = {
  63.     sizeof(device),
  64.     &null_procs,
  65.     "null",
  66.     0, 0,
  67.     72, 72,
  68.     no_margins,
  69.     dci_black_and_white,
  70.     1
  71. };
  72.  
  73. /* Flush buffered output to the device */
  74. int
  75. gs_flushpage(gs_state *pgs)
  76. {    gx_device *dev = pgs->device->info;
  77.     return (*dev->procs->sync_output)(dev);
  78. }
  79.  
  80. /* Make the device output the accumulated page description */
  81. int
  82. gs_copypage(gs_state *pgs)
  83. {    return gs_output_page(pgs, 1, 0);
  84. }
  85. int
  86. gs_output_page(gs_state *pgs, int num_copies, int flush)
  87. {    gx_device *dev = pgs->device->info;
  88.     return (*dev->procs->output_page)(dev, num_copies, flush);
  89. }
  90.  
  91. /* Copy scan lines from an image device */
  92. int
  93. gs_copyscanlines(gx_device *dev, int start_y, byte *data, uint size,
  94.   int *plines_copied, uint *pbytes_copied)
  95. {    uint line_size = gx_device_raster(dev, 0);
  96.     int code = (*dev->procs->get_bits)(dev, start_y, data, size, 0);
  97.     uint count;
  98.     if ( code < 0 ) return_error(gs_error_undefined);
  99.     count = size / line_size;
  100.     if ( plines_copied != NULL )
  101.       *plines_copied = count;
  102.     if ( pbytes_copied != NULL )
  103.       *pbytes_copied = count * line_size;
  104.     return 0;
  105. }
  106.  
  107. /* Get the current device from the graphics state */
  108. gx_device *
  109. gs_currentdevice(const gs_state *pgs)
  110. {    return pgs->device->info;
  111. }
  112.  
  113. /* Get the name of a device */
  114. const char *
  115. gs_devicename(const gx_device *dev)
  116. {    return dev->dname;
  117. }
  118.  
  119. /* Get the initial matrix of a device. */
  120. void
  121. gs_deviceinitialmatrix(gx_device *dev, gs_matrix *pmat)
  122. {    (*dev->procs->get_initial_matrix)(dev, pmat);
  123. }
  124.  
  125. /* Get the N'th device from the known device list */
  126. gx_device *
  127. gs_getdevice(int index)
  128. {    int i;
  129.     for ( i = 0; gx_device_list[i] != 0; i++ )
  130.        {    if ( i == index ) return gx_device_list[i];
  131.        }
  132.     return 0;            /* index out of range */
  133. }
  134.  
  135. /* Clone an existing device. */
  136. int
  137. gs_copydevice(gx_device **pnew_dev, const gx_device *dev, proc_alloc_t palloc)
  138. {    register gx_device *new_dev;
  139.     new_dev = (gx_device *)(*palloc)(1, dev->params_size, "gs_copydevice");
  140.     if ( new_dev == 0 ) return_error(gs_error_VMerror);
  141.     memcpy(new_dev, dev, dev->params_size);
  142.     new_dev->is_open = 0;
  143.     *pnew_dev = new_dev;
  144.     return 0;
  145. }
  146.  
  147. /* Make a memory (image) device. */
  148. /* If num_colors = -16, -24, or -32, this is a true-color device; */
  149. /* otherwise, num_colors is the number of elements in the palette */
  150. /* (2^N or 3*2^N). */
  151. int
  152. gs_makeimagedevice(gx_device **pnew_dev, const gs_matrix *pmat,
  153.   uint width, uint height, const byte *colors, int num_colors,
  154.   const gs_memory_procs *mp)
  155. {    const gx_device_memory *old_dev;
  156.     register gx_device_memory *new_dev;
  157.     int palette_size = num_colors;
  158.     int bpp = 1;
  159.     int pcount;
  160.     int bits_per_pixel;
  161.     float x_pixels_per_unit, y_pixels_per_unit;
  162.     byte palette[256 * 3];
  163.     byte *dev_palette;
  164.     int has_color;
  165.     if ( width <= 0 || height <= 0 ) return_error(gs_error_rangecheck);
  166.     switch ( num_colors )
  167.        {
  168.     case 3*2:
  169.         palette_size = 2; bpp = 3;
  170.     case 2:
  171.         bits_per_pixel = 1; break;
  172.     case 3*4:
  173.         palette_size = 4; bpp = 3;
  174.     case 4:
  175.         bits_per_pixel = 2; break;
  176.     case 3*16:
  177.         palette_size = 16; bpp = 3;
  178.     case 16:
  179.         bits_per_pixel = 4; break;
  180.     case 3*256:
  181.         palette_size = 256; bpp = 3;
  182.     case 256:
  183.         bits_per_pixel = 8; break;
  184.     case -16:
  185.         bits_per_pixel = 16; palette_size = 0; break;
  186.     case -24:
  187.         bits_per_pixel = 24; palette_size = 0; break;
  188.     case -32:
  189.         bits_per_pixel = 32; palette_size = 0; break;
  190.     default:
  191.         return_error(gs_error_rangecheck);
  192.        }
  193.     old_dev = gdev_mem_device_for_bits(bits_per_pixel);
  194.     if ( old_dev == 0 )        /* no suitable device */
  195.         return_error(gs_error_rangecheck);
  196.     pcount = palette_size * 3;
  197.     /* Check to make sure the palette contains white and black, */
  198.     /* and, if it has any colors, the six primaries. */
  199.     if ( bits_per_pixel <= 8 )
  200.        {    const byte *p;
  201.         byte *q;
  202.         int primary_mask = 0;
  203.         int i;
  204.         has_color = 0;
  205.         for ( i = 0, p = colors, q = palette;
  206.               i < palette_size; i++, q += 3
  207.             )
  208.            {    int mask = 1;
  209.             switch ( bpp )
  210.                {
  211.             case 1:            /* gray */
  212.                 q[0] = q[1] = q[2] = *p++;
  213.                 break;
  214.             default:        /* bpp == 3, colored */
  215.                 q[0] = p[0], q[1] = p[1], q[2] = p[2];
  216.                 p += 3;
  217.                }
  218. #define shift_mask(b,n)\
  219.   switch ( b ) { case 0xff: mask <<= n; case 0: break; default: mask = 0; }
  220.             shift_mask(q[0], 4);
  221.             shift_mask(q[1], 2);
  222.             shift_mask(q[2], 1);
  223. #undef shift_mask
  224.             primary_mask |= mask;
  225.             if ( q[0] != q[1] || q[0] != q[2] )
  226.                 has_color = 1;
  227.            }
  228.         switch ( primary_mask )
  229.            {
  230.         case 129:        /* just black and white */
  231.             if ( has_color )    /* color but no primaries */
  232.                 return_error(gs_error_rangecheck);
  233.         case 255:        /* full color */
  234.             break;
  235.         default:
  236.             return_error(gs_error_rangecheck);
  237.            }
  238.        }
  239.     else
  240.         has_color = 1;
  241.     /*
  242.      * The initial transformation matrix must map 1 user unit to
  243.      * 1/72".  Let W and H be the width and height in pixels, and
  244.      * assume the initial matrix is of the form [A 0 0 B X Y].
  245.      * Then the size of the image in user units is (W/|A|,H/|B|),
  246.      * hence the size in inches is ((W/|A|)/72,(H/|B|)/72), so
  247.      * the number of pixels per inch is
  248.      * (W/((W/|A|)/72),H/((H/|B|)/72)), or (|A|*72,|B|*72).
  249.      * Similarly, if the initial matrix is [0 A B 0 X Y] for a 90
  250.      * or 270 degree rotation, the size of the image in user
  251.      * units is (W/|B|,H/|A|), so the pixels per inch are
  252.      * (|B|*72,|A|*72).  We forbid non-orthogonal transformation
  253.      * matrices.
  254.      */
  255.     if ( is_fzero2(pmat->xy, pmat->yx) )
  256.         x_pixels_per_unit = pmat->xx, y_pixels_per_unit = pmat->yy;
  257.     else if ( is_fzero2(pmat->xx, pmat->yy) )
  258.         x_pixels_per_unit = pmat->yx, y_pixels_per_unit = pmat->xy;
  259.     else
  260.         return_error(gs_error_undefinedresult);
  261.     /* All checks done, allocate the device. */
  262.     new_dev = (gx_device_memory *)(*mp->alloc)(1, old_dev->params_size, "gs_makeimagedevice(device)");
  263.     if ( new_dev == 0 ) return_error(gs_error_VMerror);
  264.     *new_dev = *old_dev;
  265.     new_dev->initial_matrix = *pmat;
  266.     new_dev->width = width;
  267.     new_dev->height = height;
  268.     new_dev->x_pixels_per_inch = fabs(x_pixels_per_unit) * 72;
  269.     new_dev->y_pixels_per_inch = fabs(y_pixels_per_unit) * 72;
  270.     if ( !has_color )
  271.         new_dev->color_info.max_rgb = 0,
  272.         new_dev->color_info.dither_rgb = 0;
  273.     dev_palette = (byte *)(*mp->alloc)(pcount, 1, "gs_makeimagedevice(palette)");
  274.     if ( dev_palette == 0 ) return_error(gs_error_VMerror);
  275.     new_dev->invert = (palette[0] | palette[1] | palette[2] ? -1 : 0);    /* bogus */
  276.     new_dev->palette_size = palette_size;
  277.     new_dev->palette = dev_palette;
  278.     memcpy(dev_palette, palette, pcount);
  279.     /* The bitmap will be allocated when the device is opened. */
  280.     new_dev->memory_procs = *mp;
  281.     new_dev->is_open = 0;
  282.     *pnew_dev = (gx_device *)new_dev;
  283.     return 0;
  284. }
  285.  
  286. /* Set the device in the graphics state */
  287. int
  288. gs_setdevice(gs_state *pgs, gx_device *dev)
  289. {    register device *pdev = pgs->device;
  290.     int was_open = dev->is_open;
  291.     int code;
  292.     /* Initialize the device */
  293.     if ( !was_open )
  294.        {    code = (*dev->procs->open_device)(dev);
  295.         if ( code < 0 ) return_error(code);
  296.         dev->is_open = 1;
  297.        }
  298.     /* Compute device white and black codes */
  299.     pdev->black = (*dev->procs->map_rgb_color)(dev, 0, 0, 0);
  300.     pdev->white = (*dev->procs->map_rgb_color)(dev, gx_max_color_value, gx_max_color_value, gx_max_color_value);
  301.     pdev->info = dev;
  302.     if (    (code = gs_initmatrix(pgs)) < 0 ||
  303.         (code = gs_initclip(pgs)) < 0
  304.        )
  305.         return code;
  306.     if ( !was_open )
  307.         if ( (code = gs_erasepage(pgs)) < 0 )
  308.             return code;
  309.     return gx_remap_color(pgs);
  310. }
  311.  
  312. /* Select the null device.  This is just a convenience. */
  313. void
  314. gs_nulldevice(gs_state *pgs)
  315. {    gs_setdevice(pgs, &null_device);
  316. }
  317.  
  318. /* Close a device.  The client is responsible for ensuring that */
  319. /* this device is not current in any graphics state. */
  320. int
  321. gs_closedevice(gx_device *dev)
  322. {    int code = 0;
  323.     if ( dev->is_open )
  324.        {    code = (*dev->procs->close_device)(dev);
  325.         if ( code < 0 ) return_error(code);
  326.         dev->is_open = 0;
  327.        }
  328.     return code;
  329. }
  330.  
  331. /* Install enough of a null device to suppress graphics output */
  332. /* during the execution of stringwidth. */
  333. void
  334. gx_device_no_output(gs_state *pgs)
  335. {    pgs->device->info = &null_device;
  336. }
  337.  
  338. /* Just set the device without reinitializing. */
  339. /* (For internal use only.) */
  340. void
  341. gx_set_device_only(gs_state *pgs, gx_device *dev)
  342. {    pgs->device->info = dev;
  343. }
  344.  
  345. /* Compute the size of one scan line for a device, */
  346. /* with or without padding to a word boundary. */
  347. uint
  348. gx_device_raster(const gx_device *dev, int pad)
  349. {    ulong bits = (ulong)dev->width * dev->color_info.depth;
  350.     return (pad ?
  351.         (uint)((bits + 31) >> 5) << 2 :
  352.         (uint)((bits + 7) >> 3));
  353. }
  354.  
  355. /* Adjust the resolution for devices that only have a fixed set of */
  356. /* geometries, so that the apparent size in inches remains constant. */
  357. /* If fit=1, the resolution is adjusted so that the entire image fits; */
  358. /* if fit=0, one dimension fits, but the other one is clipped. */
  359. int
  360. gx_device_adjust_resolution(gx_device *dev,
  361.   int actual_width, int actual_height, int fit)
  362. {    double width_ratio = (double)actual_width / dev->width ;
  363.     double height_ratio = (double)actual_height / dev->height ;
  364.     double ratio =
  365.         (fit ? min(width_ratio, height_ratio) :
  366.          max(width_ratio, height_ratio));
  367.     dev->x_pixels_per_inch *= ratio;
  368.     dev->y_pixels_per_inch *= ratio;
  369.     dev->width = actual_width;
  370.     dev->height = actual_height;
  371.     return 0;
  372. }
  373.  
  374. /* ------ The null `device' ------ */
  375.  
  376. private int
  377. null_fill_rectangle(gx_device *dev, int x, int y, int w, int h,
  378.   gx_color_index color)
  379. {    return 0;
  380. }
  381. private int
  382. null_tile_rectangle(gx_device *dev, const gx_bitmap *tile,
  383.   int x, int y, int w, int h, gx_color_index zero, gx_color_index one,
  384.   int px, int py)
  385. {    return 0;
  386. }
  387. private int
  388. null_copy_mono(gx_device *dev, const byte *data,
  389.   int dx, int raster, gx_bitmap_id id, int x, int y, int w, int h,
  390.   gx_color_index zero, gx_color_index one)
  391. {    return 0;
  392. }
  393. private int
  394. null_draw_line(gx_device *dev, int x0, int y0, int x1, int y1,
  395.   gx_color_index color)
  396. {    return 0;
  397. }
  398.  
  399. /* ------ Default device procedures ------ */
  400.  
  401. int
  402. gx_default_open_device(gx_device *dev)
  403. {    return 0;
  404. }
  405.  
  406. void
  407. gx_default_get_initial_matrix(register gx_device *dev, register gs_matrix *pmat)
  408. {    pmat->xx = dev->x_pixels_per_inch / 72.0;
  409.     pmat->xy = 0;
  410.     pmat->yx = 0;
  411.     pmat->yy = dev->y_pixels_per_inch / -72.0;
  412.     pmat->tx = 0;
  413.     pmat->ty = dev->height;    /****** WRONG for devices with ******/
  414.                 /****** arbitrary initial matrix ******/
  415. }
  416.  
  417. int
  418. gx_default_sync_output(gx_device *dev)
  419. {    return 0;
  420. }
  421.  
  422. int
  423. gx_default_output_page(gx_device *dev, int num_copies, int flush)
  424. {    return (*dev->procs->sync_output)(dev);
  425. }
  426.  
  427. int
  428. gx_default_close_device(gx_device *dev)
  429. {    return 0;
  430. }
  431.  
  432. gx_color_index
  433. gx_default_map_rgb_color(gx_device *dev,
  434.   gx_color_value r, gx_color_value g, gx_color_value b)
  435. {    /* Map values >= 1/2 to 1, < 1/2 to 0. */
  436.     return ((r | g | b) > gx_max_color_value / 2 ?
  437.         (gx_color_index)1 : (gx_color_index)0);
  438. }
  439.  
  440. int
  441. gx_default_map_color_rgb(gx_device *dev, gx_color_index color,
  442.   gx_color_value prgb[3])
  443. {    /* Map 1 to max_value, 0 to 0. */
  444.     prgb[0] = prgb[1] = prgb[2] = -(gx_color_value)color;
  445.     return 0;
  446. }
  447.  
  448. int
  449. gx_default_copy_color(gx_device *dev, const byte *data,
  450.   int data_x, int raster, gx_bitmap_id id,
  451.   int x, int y, int width, int height)
  452. {    return (*dev->procs->copy_mono)(dev, data, data_x, raster, id,
  453.         x, y, width, height, (gx_color_index)0, (gx_color_index)1);
  454. }
  455.  
  456. int
  457. gx_default_get_bits(gx_device *dev, int y,
  458.   byte *data, unsigned int size, int pad)
  459. {    return -1;
  460. }
  461.  
  462. /* Standard device properties */
  463.  
  464. private const gs_prop_item props_std[] = {
  465.         /* Following can be set, but will close and */
  466.         /* reopen the device if necessary. */
  467.     prop_def("HWResolution", prt_float_array),
  468.     prop_def("HWSize", prt_int_array),
  469.         /* Following cannot be set yet */
  470.     prop_def("InitialMatrix", prt_float_array),
  471.         /* Following cannot be set */
  472.     prop_def("Name", prt_string),
  473.         /* Slots for arrays */
  474.     prop_float, prop_float,
  475.     prop_int, prop_int,
  476.     prop_float, prop_float, prop_float, prop_float,
  477.       prop_float, prop_float
  478. };
  479.  
  480. /* Get the size of the device properties. */
  481. int
  482. gs_getdeviceprops_size(gx_device *dev)
  483. {    return (*dev->procs->get_props)(dev, NULL);
  484. }
  485.  
  486. /* Get the device properties. */
  487. int
  488. gs_getdeviceprops(gx_device *dev, gs_prop_item *plist)
  489. {    return (*dev->procs->get_props)(dev, plist);
  490. }
  491.  
  492. /* Get standard properties. */
  493. int
  494. gx_default_get_props(register gx_device *dev, register gs_prop_item *plist)
  495. {    if ( plist != 0 )
  496.        {    register gs_prop_item *pi;
  497.         gs_matrix mat;
  498.         memcpy(plist, props_std, sizeof(props_std));
  499.         plist[0].value.a.size = 2;
  500.         plist[1].value.a.size = 2;
  501.         plist[2].value.a.size = 6;
  502.         plist[3].value.a.p.s = (char *)dev->dname;
  503.         plist[3].value.a.size = -1;
  504.         pi = &plist[4];
  505.             /* resolution array */
  506.         plist[0].value.a.p.v = pi;
  507.         pi[0].value.f = dev->x_pixels_per_inch;
  508.         pi[1].value.f = dev->y_pixels_per_inch;
  509.         pi += 2;
  510.             /* width/height array */
  511.         plist[1].value.a.p.v = pi;
  512.         pi[0].value.i = dev->width;
  513.         pi[1].value.i = dev->height;
  514.         pi += 2;
  515.             /* matrix */
  516.         plist[2].value.a.p.v = pi;
  517.         (*dev->procs->get_initial_matrix)(dev, &mat);
  518.         pi[0].value.f = mat.xx;
  519.         pi[1].value.f = mat.xy;
  520.         pi[2].value.f = mat.yx;
  521.         pi[3].value.f = mat.yy;
  522.         pi[4].value.f = mat.tx;
  523.         pi[5].value.f = mat.ty;
  524.         pi += 6;
  525.        }
  526.     return sizeof(props_std) / sizeof(gs_prop_item);
  527. }
  528.  
  529. /* Set the device properties. */
  530. /* If the device was open and the put_props procedure closed it, */
  531. /* return 1; otherwise, return 0 or an error code as usual. */
  532. int
  533. gs_putdeviceprops(gx_device *dev, gs_prop_item *plist, int count)
  534. {    int was_open = dev->is_open;
  535.     int code = (*dev->procs->put_props)(dev, plist, count);
  536.     return (code < 0 ? code : was_open && !dev->is_open ? 1 : code);
  537. }
  538.  
  539. /* Set standard properties. */
  540. /* Note that setting the size or resolution closes the device. */
  541. int
  542. gx_default_put_props(gx_device *dev, gs_prop_item *plist, int count)
  543. {    gs_prop_item *known[2];
  544.     int code = 0;
  545.     gx_device temp_dev;
  546.     props_extract(plist, count, props_std, 2, known, 1);
  547.     temp_dev = *dev;
  548.     if ( known[1] != 0 )
  549.        {    if ( known[1]->value.a.size != 2 )
  550.             known[1]->status = pv_typecheck,
  551.             code = gs_error_typecheck;
  552.         else
  553.            {    gs_prop_item *ap = known[1]->value.a.p.v;
  554.             if ( ap[0].value.i <= 0 || ap[0].value.i > 0x7fff ||
  555.                  ap[1].value.i <= 0 || ap[1].value.i > 0x7fff
  556.                )
  557.                 known[1]->status = pv_rangecheck,
  558.                 code = gs_error_rangecheck;
  559.             else
  560.                {    temp_dev.width = ap[0].value.i;
  561.                 temp_dev.height = ap[1].value.i;
  562.                }
  563.             if ( code == 0 ) code = 1;
  564.            }
  565.        }
  566.     if ( known[0] != 0 )
  567.        {    if ( known[0]->value.a.size != 2 )
  568.             known[0]->status = pv_typecheck,
  569.             code = gs_error_typecheck;
  570.         else
  571.            {    gs_prop_item *ap = known[0]->value.a.p.v;
  572.             if ( ap[0].value.f <= 0 || ap[1].value.f <= 0 )
  573.                 known[0]->status = pv_rangecheck,
  574.                 code = gs_error_rangecheck;
  575.             else
  576.                {    temp_dev.x_pixels_per_inch = ap[0].value.f;
  577.                 temp_dev.y_pixels_per_inch = ap[1].value.f;
  578.                }
  579.             if ( code == 0 ) code = 1;
  580.            }
  581.        }
  582.     if ( code < 0 )
  583.         return_error(code);
  584.     /* Close the device; gs_putdeviceprops will reopen it. */
  585.     if ( dev->is_open && code )
  586.     {    int ccode = gs_closedevice(dev);
  587.         if ( ccode < 0 ) return ccode;
  588.     }
  589.     dev->x_pixels_per_inch = temp_dev.x_pixels_per_inch;
  590.     dev->y_pixels_per_inch = temp_dev.y_pixels_per_inch;
  591.     dev->width = temp_dev.width;
  592.     dev->height = temp_dev.height;
  593.     return code;
  594. }
  595.