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.

109 lines
3.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1998
  6. //
  7. // File: ddpaletteobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // ddPaletteObj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "ddPaletteObj.h"
  15. CONSTRUCTOR(_dxj_DirectDrawPalette, {m_dd=NULL;});
  16. DESTRUCTOR(_dxj_DirectDrawPalette, {m_dd=NULL;});
  17. GETSET_OBJECT(_dxj_DirectDrawPalette);
  18. PASS_THROUGH_CAST_1_R(_dxj_DirectDrawPalette, getCaps, GetCaps, long*,(DWORD *))
  19. /////////////////////////////////////////////////////////////////////////////
  20. STDMETHODIMP C_dxj_DirectDrawPaletteObject::getEntries( //long flags,
  21. long base, long numEntries, SAFEARRAY **ppEntries){
  22. HRESULT hr;
  23. if (!ISSAFEARRAY1D(ppEntries,(DWORD)numEntries)) return E_INVALIDARG;
  24. LPPALETTEENTRY pe=(LPPALETTEENTRY)((SAFEARRAY*)*ppEntries)->pvData;
  25. hr=m__dxj_DirectDrawPalette->GetEntries((DWORD) 0,(DWORD) base, (DWORD) numEntries, pe);
  26. return hr;
  27. }
  28. STDMETHODIMP C_dxj_DirectDrawPaletteObject::setEntries(// long flags,
  29. long base, long numEntries, SAFEARRAY **ppEntries){
  30. HRESULT hr;
  31. if (!ISSAFEARRAY1D(ppEntries,(DWORD)numEntries)) return E_INVALIDARG;
  32. LPPALETTEENTRY pe=(LPPALETTEENTRY)((SAFEARRAY*)*ppEntries)->pvData;
  33. hr=m__dxj_DirectDrawPalette->SetEntries((DWORD) 0,(DWORD) base, (DWORD) numEntries, pe);
  34. return hr;
  35. }
  36. /////////////////////////////////////////////////////////////////////////////
  37. //
  38. #if 0
  39. STDMETHODIMP C_dxj_DirectDrawPaletteObject::initialize( I_dxj_DirectDraw2 *val)
  40. {
  41. DO_GETOBJECT_NOTNULL( LPDIRECTDRAW2, lpdd, val)
  42. return m__dxj_DirectDrawPalette->Initialize((LPDIRECTDRAW)lpdd, 0, NULL);
  43. }
  44. /////////////////////////////////////////////////////////////////////////////
  45. //
  46. STDMETHODIMP C_dxj_DirectDrawPaletteObject::internalAttachDD(I_dxj_DirectDraw2 *dd)
  47. {
  48. m_dd = dd;
  49. return S_OK;
  50. }
  51. #endif
  52. /////////////////////////////////////////////////////////////////////////////
  53. //
  54. STDMETHODIMP C_dxj_DirectDrawPaletteObject::setEntriesHalftone(long start, long count)
  55. {
  56. PALETTEENTRY pe[256];
  57. HDC hdc = GetDC(NULL);
  58. if (!hdc) return E_OUTOFMEMORY;
  59. HPALETTE hpal = CreateHalftonePalette(hdc);
  60. if (!hpal) return E_OUTOFMEMORY;
  61. GetPaletteEntries(hpal, 0, 256, pe );
  62. for ( long i = start; i < start+count; i++ )
  63. pe[i].peFlags |= PC_NOCOLLAPSE | D3DPAL_READONLY;
  64. m__dxj_DirectDrawPalette->SetEntries(0,(DWORD)start,(DWORD)count,pe);
  65. ReleaseDC(NULL,hdc);
  66. return S_OK;
  67. }
  68. STDMETHODIMP C_dxj_DirectDrawPaletteObject::setEntriesSystemPalette(long start, long count)
  69. {
  70. PALETTEENTRY pe[256];
  71. UINT uiRet;
  72. HRESULT hr;
  73. HDC hdc = GetDC(NULL);
  74. if (!hdc) return E_OUTOFMEMORY;
  75. uiRet=GetSystemPaletteEntries(hdc,start,count,pe);
  76. if (uiRet<=0) return E_FAIL;
  77. for ( long i = start; i < start+count; i++ )
  78. pe[i].peFlags |= /*PC_NOCOLLAPSE |*/ D3DPAL_READONLY;
  79. hr=m__dxj_DirectDrawPalette->SetEntries(0,(DWORD)start,(DWORD)count,pe);
  80. ReleaseDC(NULL,hdc);
  81. return S_OK;
  82. }