home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_3.5 / Examples / Printer / HP_DeskJet_CMYK / density.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-30  |  2.8 KB  |  99 lines

  1. /*
  2.  * $Id: density.c 44.6 1999/09/13 13:36:55 olsen Exp olsen $
  3.  *
  4.  * :ts=4
  5.  *
  6.  * COPYRIGHT:
  7.  *
  8.  *   Unless otherwise noted, all files are Copyright (c) 1999 Amiga, Inc.
  9.  *   All rights reserved.
  10.  *
  11.  * DISCLAIMER:
  12.  *
  13.  *   This software is provided "as is". No representations or warranties
  14.  *   are made with respect to the accuracy, reliability, performance,
  15.  *   currentness, or operation of this software, and all use is at your
  16.  *   own risk. Neither Amiga nor the authors assume any responsibility
  17.  *   or liability whatsoever with respect to your use of this software.
  18.  *
  19.  */
  20.  
  21. #include "global.h"
  22.  
  23. /****************************************************************************/
  24.  
  25. #include "config.h"
  26.  
  27. /****************************************************************************/
  28.  
  29. VOID
  30. SetDensity(ULONG density_code)
  31. {
  32.     STATIC const UWORD color_dpi[7] = CONFIG_COLOR_DPI;
  33.     STATIC const UWORD bw_dpi[7]    = CONFIG_BW_DPI;
  34.  
  35.     /* Paper sizes in dots at 300 DPI */
  36.     STATIC const ULONG PaperSizes[10][2] =
  37.     {
  38.         { 2400, 3200 },    /* US_LETTER (8" x 10") */
  39.         { 2400, 4100 },    /* US_LEGAL (8" x 13") */
  40.         { 2400, 3200 },    /* N_TRACTOR = US_LETTER */
  41.         { 2400, 3200 },    /* W_TRACTOR = US_LETTER */
  42.         { 2400, 3200 },    /* CUSTOM = US_LETTER */
  43.  
  44.         {    0,    0 },    /* EURO_A0 (ignored) */
  45.         {    0,    0 },    /* EURO_A1 (ignored) */
  46.         {    0,    0 },    /* EURO_A2 (ignored) */
  47.         { 3365, 4860 },    /* EURO_A3 (11" x 16") */
  48.         { 2338, 3407 }    /* EURO_A4 ( 7" x 11") */
  49.     };
  50.  
  51.     /* Calculate max dots based on paper size selection */
  52.     ULONG max_width,max_height;
  53.     LONG paper_size;
  54.     LONG density_index;
  55.     LONG paper_index;
  56.  
  57.     /* Don't allow for a page size beyond A4. */
  58.     paper_size = (PD->pd_Preferences.PaperSize & 0xFF);
  59.     if(paper_size > EURO_A4)
  60.         paper_size = EURO_A4;
  61.     else if (paper_size < EURO_A3 && EURO_A0 <= paper_size)
  62.         paper_size = EURO_A3;
  63.  
  64.     paper_index = paper_size >> 4;
  65.  
  66.     max_width  = PaperSizes[paper_index][0];
  67.     max_height = PaperSizes[paper_index][1];
  68.  
  69.     /* Map the density (SPECIAL_DENSITY1..SPECIAL_DENSITY7)
  70.      * to a table index (0..6).
  71.      */
  72.     density_index = ((density_code & SPECIAL_DENSITYMASK) >> 8) - 1;
  73.  
  74.     if(CONFIG_SUPPORTS_COLOR && PD->pd_Preferences.PrintShade == SHADE_COLOR)
  75.     {
  76.         PED->ped_XDotsInch = color_dpi[density_index];
  77.         PED->ped_YDotsInch = color_dpi[density_index];
  78.     }
  79.     else
  80.     {
  81.         PED->ped_XDotsInch = bw_dpi[density_index];
  82.         PED->ped_YDotsInch = bw_dpi[density_index];
  83.     }
  84.  
  85.     /* Calculate the page sizes; defaults are given for 300 DPI
  86.      * which will need to be scaled for different resolutions.
  87.      */
  88.     PED->ped_MaxXDots = (max_width    * PED->ped_XDotsInch) / 300;
  89.     PED->ped_MaxYDots = (max_height    * PED->ped_YDotsInch) / 300;
  90.  
  91.     /* Increase timeout for 300/600 DPI dumps */
  92.     if(PED->ped_MaxXDots == 600)
  93.         PED->ped_TimeoutSecs = 120;
  94.     else if (PED->ped_MaxXDots == 300)
  95.         PED->ped_TimeoutSecs = 60;
  96.     else
  97.         PED->ped_TimeoutSecs = 30;
  98. }
  99.