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.

96 lines
2.6 KiB

  1. /*++
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * WGPAL.C
  8. * WOW32 16-bit GDI API support
  9. *
  10. * History:
  11. * 07-Mar-1991 Jeff Parsons (jeffpar)
  12. * Created.
  13. *
  14. * 09-Apr-1991 NigelT
  15. * Various defines are used here to remove calls to Win32
  16. * features which don't work yet.
  17. --*/
  18. #include "precomp.h"
  19. #pragma hdrstop
  20. MODNAME(wgpal.c);
  21. ULONG FASTCALL WG32GetSystemPaletteEntries(PVDMFRAME pFrame)
  22. {
  23. ULONG ul = 0L;
  24. PPALETTEENTRY ppal;
  25. HANDLE hdc32;
  26. register PGETSYSTEMPALETTEENTRIES16 parg16;
  27. GETARGPTR(pFrame, sizeof(GETSYSTEMPALETTEENTRIES16), parg16);
  28. GETVDMPTR(parg16->f4, parg16->f3 * sizeof(PALETTEENTRY), ppal);
  29. if( ppal ) {
  30. hdc32 = HDC32(parg16->f1);
  31. ul = GETWORD16(GetSystemPaletteEntries(hdc32,
  32. WORD32(parg16->f2),
  33. WORD32(parg16->f3),
  34. ppal));
  35. // if we fail but are on a rgb device, fill in the default 256 entries.
  36. // WIN31 just calls Escape(hdc,GETCOLORTABLE) which on NT just calls
  37. // GetSysteemPaletteEntries().
  38. if (!ul && (GetDeviceCaps(hdc32, BITSPIXEL) > 8))
  39. {
  40. if (parg16->f4 == 0)
  41. {
  42. ul = 256;
  43. }
  44. else
  45. {
  46. int j;
  47. int i = WORD32(parg16->f2);
  48. int c = WORD32(parg16->f3);
  49. if ((c + i) > 256)
  50. c = 256 - i;
  51. if (c > 0)
  52. {
  53. BYTE abGreenRed[8] = {0x0,0x25,0x48,0x6d,0x92,0xb6,0xdb,0xff};
  54. BYTE abBlue[4] = {0x0,0x55,0xaa,0xff};
  55. // green mask 00000111
  56. // red mask 00111000
  57. // blue mask 11000000
  58. // could certainly do this faster with a table and mem copy
  59. // but I don't really care about performance here. Apps
  60. // shouldn't be doing this. That is why it is in the wow
  61. // layer.
  62. for (j = 0; j < c; ++j,++i)
  63. {
  64. ppal[j].peGreen = abGreenRed[i & 0x07];
  65. ppal[j].peRed = abGreenRed[(i >> 3) & 0x07];
  66. ppal[j].peBlue = abBlue[(i >> 6) & 0x03];
  67. ppal[j].peFlags = 0;
  68. }
  69. ul = c;
  70. }
  71. }
  72. }
  73. FREEVDMPTR(ppal);
  74. }
  75. FREEARGPTR(parg16);
  76. RETURN(ul);
  77. }