Source code of Windows XP (NT5)
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.

94 lines
2.5 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. register PGETSYSTEMPALETTEENTRIES16 parg16;
  26. GETARGPTR(pFrame, sizeof(GETSYSTEMPALETTEENTRIES16), parg16);
  27. GETVDMPTR(parg16->f4, parg16->f3 * sizeof(PALETTEENTRY), ppal);
  28. if( ppal ) {
  29. ul = GETWORD16(GetSystemPaletteEntries(HDC32(parg16->f1),
  30. WORD32(parg16->f2),
  31. WORD32(parg16->f3),
  32. ppal));
  33. // if we fail but are on a rgb device, fill in the default 256 entries.
  34. // WIN31 just calls Escape(hdc,GETCOLORTABLE) which on NT just calls
  35. // GetSysteemPaletteEntries().
  36. if (!ul && (GetDeviceCaps(HDC32(parg16->f1),BITSPIXEL) > 8))
  37. {
  38. if (parg16->f4 == 0)
  39. {
  40. ul = 256;
  41. }
  42. else
  43. {
  44. int j;
  45. int i = WORD32(parg16->f2);
  46. int c = WORD32(parg16->f3);
  47. if ((c + i) > 256)
  48. c = 256 - i;
  49. if (c > 0)
  50. {
  51. BYTE abGreenRed[8] = {0x0,0x25,0x48,0x6d,0x92,0xb6,0xdb,0xff};
  52. BYTE abBlue[4] = {0x0,0x55,0xaa,0xff};
  53. // green mask 00000111
  54. // red mask 00111000
  55. // blue mask 11000000
  56. // could certainly do this faster with a table and mem copy
  57. // but I don't really care about performance here. Apps
  58. // shouldn't be doing this. That is why it is in the wow
  59. // layer.
  60. for (j = 0; j < c; ++j,++i)
  61. {
  62. ppal[j].peGreen = abGreenRed[i & 0x07];
  63. ppal[j].peRed = abGreenRed[(i >> 3) & 0x07];
  64. ppal[j].peBlue = abBlue[(i >> 6) & 0x03];
  65. ppal[j].peFlags = 0;
  66. }
  67. ul = c;
  68. }
  69. }
  70. }
  71. FREEVDMPTR(ppal);
  72. }
  73. FREEARGPTR(parg16);
  74. RETURN(ul);
  75. }