Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
5.3 KiB

  1. /****************** Module Header *********************
  2. *
  3. * Copyright (c) 1996 - 1999 Microsoft Corporation
  4. *
  5. * initpal.c
  6. *
  7. * HISTORY
  8. * 14:21 on Wed 05 July 1995 -by- Sandra Matts
  9. * initial version
  10. *
  11. *
  12. ******************************************************/
  13. #include "raster.h"
  14. /* defines for color manipulation */
  15. #define RED_VALUE(c) ((BYTE) c & 0xff)
  16. #define GREEN_VALUE(c) ((BYTE) (c >> 8) & 0xff)
  17. #define BLUE_VALUE(c) ((BYTE) (c >> 16) & 0xff)
  18. /************************** Function Header *********************************
  19. * lSetup8BitPalette
  20. * Function to read in the 256 color palette from GDI into the
  21. * palette data structure in Dev Info.
  22. *
  23. * RETURNS:
  24. * The number of colors in the palette. Returns 0 if the call fails.
  25. *
  26. * HISTORY:
  27. * 10:43 on Wed 06 Sep 1995 -by- Sandra Matts
  28. * Created it to support the Color LaserJet
  29. *
  30. ****************************************************************************/
  31. long lSetup8BitPalette (pRPDev, pPD, pdevinfo, pGDIInfo)
  32. RASTERPDEV *pRPDev;
  33. PAL_DATA *pPD;
  34. DEVINFO *pdevinfo; /* Where to put the data */
  35. GDIINFO *pGDIInfo;
  36. {
  37. long lRet;
  38. int _iI;
  39. PALETTEENTRY pe[ 256 ]; /* 8 bits per pel - all the way */
  40. FillMemory (pe, sizeof (pe), 0xff);
  41. lRet = HT_Get8BPPFormatPalette(pe,
  42. (USHORT)pGDIInfo->ciDevice.RedGamma,
  43. (USHORT)pGDIInfo->ciDevice.GreenGamma,
  44. (USHORT)pGDIInfo->ciDevice.BlueGamma );
  45. #if PRINT_INFO
  46. DbgPrint("RedGamma = %d, GreenGamma = %d, BlueGamma = %d\n",(USHORT)pGDIInfo->ciDevice.RedGamma, (USHORT)pGDIInfo->ciDevice.GreenGamma, (USHORT)pGDIInfo->ciDevice.BlueGamma);
  47. #endif
  48. if( lRet < 1 )
  49. {
  50. #if DBG
  51. DbgPrint( "Rasdd!GetPalette8BPP returns %ld\n", lRet );
  52. #endif
  53. return(0);
  54. }
  55. /*
  56. * Convert the HT derived palette to the engine's desired format.
  57. */
  58. for( _iI = 0; _iI < lRet; _iI++ )
  59. {
  60. pPD->ulPalCol[ _iI ] = RGB( pe[ _iI ].peRed,
  61. pe[ _iI ].peGreen,
  62. pe[ _iI ].peBlue );
  63. #if PRINT_INFO
  64. DbgPrint("Pallette entry %d= (r = %d, g = %d, b = %d)\n",_iI,pe[ _iI ].peRed, pe[ _iI ].peGreen, pe[ _iI ].peBlue);
  65. #endif
  66. }
  67. pPD->iPalGdi = lRet;
  68. pdevinfo->iDitherFormat = BMF_8BPP;
  69. pGDIInfo->ulPrimaryOrder = PRIMARY_ORDER_CBA;
  70. pGDIInfo->ulHTOutputFormat = HT_FORMAT_8BPP;
  71. /*
  72. * Since the GPC spec does not support this flag yet,
  73. * we have to manually set it.
  74. */
  75. pRPDev->fColorFormat |= DC_ZERO_FILL;
  76. /*
  77. * Since the Color laserJet zero fills we are going to
  78. * put white in palette entry 0 and black in 7
  79. */
  80. if (pRPDev->fColorFormat & DC_ZERO_FILL)
  81. {
  82. pPD->ulPalCol[ 7 ] = RGB (0x00, 0x00, 0x00);
  83. pPD->ulPalCol[ 0 ] = RGB (0xff, 0xff, 0xff);
  84. pPD->iWhiteIndex = 0;
  85. pPD->iBlackIndex = 7;
  86. }
  87. return lRet;
  88. }
  89. /************************** Function Header *********************************
  90. * lSetup24BitPalette
  91. * Function to read in the 256 color palette from GDI into the
  92. * palette data structure in Dev Info.
  93. *
  94. * RETURNS:
  95. * The number of colors in the palette. Returns 0 if the call fails.
  96. *
  97. * HISTORY:
  98. * 10:43 on Wed 06 Sep 1995 -by- Sandra Matts
  99. * Created it to support the Color LaserJet
  100. *
  101. ****************************************************************************/
  102. long lSetup24BitPalette (pPD, pdevinfo, pGDIInfo)
  103. PAL_DATA *pPD;
  104. DEVINFO *pdevinfo; /* Where to put the data */
  105. GDIINFO *pGDIInfo;
  106. {
  107. pPD->iPalGdi = 0;
  108. pPD->iWhiteIndex = 0x00ffffff;
  109. pdevinfo->iDitherFormat = BMF_24BPP;
  110. pGDIInfo->ulPrimaryOrder = PRIMARY_ORDER_CBA;
  111. pGDIInfo->ulHTOutputFormat = HT_FORMAT_24BPP;
  112. return 1;
  113. }
  114. /****************************** Function Header ****************************
  115. * v8BPPLoadPal
  116. * Download the palette to the HP Color laserJet in 8BPP
  117. * mode. Takes the data we retrieved from the HT code during
  118. * DrvEnablePDEV.
  119. *
  120. * RETURNS:
  121. * Nothing.
  122. *
  123. * HISTORY:
  124. * 14:46 on Thu 29 June 1995 -by- Sandra Matts
  125. * Initial version
  126. *
  127. ****************************************************************************/
  128. void
  129. v8BPPLoadPal( pPDev )
  130. PDEV *pPDev;
  131. {
  132. /*
  133. * Program the palette according to PCL5 spec.
  134. * The syntax is Esc*v#a#b#c#I
  135. * #a is the first color component
  136. * #b is the second color component
  137. * #c is the third color component
  138. * #I assigns the color to the specified palette index number
  139. * For example, Esc*v0a128b255c5I assigns the 5th index
  140. * of the palette to the color 0, 128, 255
  141. *
  142. */
  143. int iI,
  144. iIndex;
  145. PAL_DATA *pPD;
  146. pPD = pPDev->pPalData;
  147. /*TBD: how do we output a palette to the device?
  148. for( iI = 0; iI < pPD->iPalDev; ++iI )
  149. {
  150. WriteChannel (pPDev, CMD_DC_PC_ENTRY, RED_VALUE (pPD->ulPalCol [iI]),
  151. GREEN_VALUE (pPD->ulPalCol [iI]), BLUE_VALUE (pPD->ulPalCol [iI]),
  152. (ULONG) iI);
  153. }
  154. */
  155. return;
  156. }