148a6d5b605eeed88ec3a0360e2faab3547860c1
[wine/hacks.git] / dlls / winedib.drv / palette.c
blob148a6d5b605eeed88ec3a0360e2faab3547860c1
1 /*
2 * DIBDRV palette objects
4 * Copyright 2009 Massimo Del Fedele
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include "dibdrv.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(dibdrv);
28 /***********************************************************************
29 * DIBDRV_RealizePalette
31 UINT DIBDRV_RealizePalette( DIBDRVPHYSDEV *physDev, HPALETTE hpal, BOOL primary )
33 UINT res;
35 MAYBE(TRACE("physDev:%p, hpal:%p, primary:%s\n", physDev, hpal, (primary ? "TRUE" : "FALSE")));
37 /* we should in any case call X11 function, as UnrealizePalette() doesn't
38 * take a physDev parameter */
39 res = _DIBDRV_GetDisplayDriver()->pRealizePalette(physDev->X11PhysDev, hpal, primary);
41 if(physDev->hasDIB)
43 /* DIB section selected in, additional (if needed) engine code */
44 ONCE(FIXME("STUB\n"));
47 return res;
50 /***********************************************************************
51 * DIBDRV_UnrealizePalette
53 BOOL DIBDRV_UnrealizePalette( HPALETTE hpal )
55 BOOL res;
57 MAYBE(TRACE("hpal:%p\n", hpal));
59 /* we should in any case call X11 function, as UnrealizePalette() doesn't
60 * take a physDev parameter */
61 res = _DIBDRV_GetDisplayDriver()->pUnrealizePalette(hpal);
63 /* additional Engine code here, if needed */
64 ONCE(FIXME("STUB\n"));
66 return res;
69 /***********************************************************************
70 * DIBDRV_GetSystemPaletteEntries
72 UINT DIBDRV_GetSystemPaletteEntries( DIBDRVPHYSDEV *physDev, UINT start, UINT count,
73 LPPALETTEENTRY entries )
75 UINT res;
77 MAYBE(TRACE("physDev:%p, start:%d, count:%d, entries:%p\n", physDev, start, count, entries));
79 if(physDev->hasDIB)
81 /* DIB section selected in, use DIB Engine */
82 ONCE(FIXME("STUB\n"));
83 res = 0;
85 else
87 /* DDB selected in, use X11 driver */
88 res = _DIBDRV_GetDisplayDriver()->pGetSystemPaletteEntries(physDev->X11PhysDev, start, count, entries);
90 return res;
93 /***********************************************************************
94 * DIBDRV_GetNearestColor
96 COLORREF DIBDRV_GetNearestColor( DIBDRVPHYSDEV *physDev, COLORREF color )
98 COLORREF res;
100 MAYBE(TRACE("physDev:%p, color:%x\n", physDev, color));
102 if(physDev->hasDIB)
104 /* DIB section selected in, use DIB Engine */
105 ONCE(FIXME("STUB\n"));
106 res = 0;
108 else
110 /* DDB selected in, use X11 driver */
111 res = _DIBDRV_GetDisplayDriver()->pGetNearestColor(physDev->X11PhysDev, color);
113 return res;
116 /***********************************************************************
117 * DIBDRV_RealizeDefaultPalette
119 UINT DIBDRV_RealizeDefaultPalette( DIBDRVPHYSDEV *physDev )
121 UINT res;
122 #ifdef DIBDRV_ENABLE_MAYBE
123 int i;
124 RGBQUAD *q;
125 #endif
127 MAYBE(TRACE("physDev:%p\n", physDev));
129 if(physDev->hasDIB)
131 /* DIB section selected in, use DIB Engine */
132 ONCE(FIXME("STUB\n"));
133 /* HACK - we can't get the dib color table during SelectBitmap since it hasn't
134 been initialized yet. This is called from DC_InitDC so it's a convenient place
135 to grab the color table. */
136 MAYBE(TRACE("Color table size = %d, Color table = %p\n", physDev->physBitmap.colorTableSize, physDev->physBitmap.colorTable));
137 if(!physDev->physBitmap.colorTableGrabbed)
139 MAYBE(TRACE("Grabbing palette\n"));
140 physDev->physBitmap.colorTable = HeapAlloc(GetProcessHeap(), 0, sizeof(physDev->physBitmap.colorTable[0]) * physDev->physBitmap.colorTableSize);
141 GetDIBColorTable(physDev->hdc, 0, physDev->physBitmap.colorTableSize, physDev->physBitmap.colorTable);
142 #ifdef DIBDRV_ENABLE_MAYBE
143 for(i = 0; i < physDev->physBitmap.colorTableSize; i++)
145 q = physDev->physBitmap.colorTable + i;
146 TRACE(" %03d : R%03d G%03d B%03d\n", i, q->rgbRed, q->rgbGreen, q->rgbBlue);
148 #endif
149 physDev->physBitmap.colorTableGrabbed = TRUE;
151 res = 0;
153 else
155 /* DDB selected in, use X11 driver */
156 res = _DIBDRV_GetDisplayDriver()->pRealizeDefaultPalette(physDev->X11PhysDev);
158 return res;
161 BOOL DIBDRV_GetICMProfile(DIBDRVPHYSDEV *physDev, LPDWORD lpcbName, LPWSTR lpszFilename)
163 BOOL res;
165 MAYBE(TRACE("physDev:%p, lpcpName:%p, lpszFilename:%p\n", physDev, lpcbName, lpszFilename));
167 if(physDev->hasDIB)
169 /* DIB section selected in, use DIB Engine */
170 ONCE(FIXME("STUB\n"));
172 res = 0;
174 else
176 /* DDB selected in, use X11 driver */
177 res = _DIBDRV_GetDisplayDriver()->pGetICMProfile(physDev->X11PhysDev, lpcbName, lpszFilename);
179 return res;