source: trunk/src/gdi32/palette.cpp

Last change on this file was 10583, checked in by sandervl, 21 years ago

updates

File size: 6.2 KB
RevLine 
[10583]1/* $Id: palette.cpp,v 1.13 2004-04-14 09:44:14 sandervl Exp $ */
[1931]2
3/*
4 * GDI32 palette apis
5 *
6 * Based on Wine code (991031) (objects\palette.c)
7 *
8 * Copyright 1993,1994 Alexandre Julliard
9 * Copyright 1996 Alex Korobka
10 *
11 * Project Odin Software License can be found in LICENSE.TXT
12 *
13 */
14#include <os2win.h>
15#include <stdlib.h>
16#include <misc.h>
17#include <string.h>
[2592]18#include "dibsect.h"
[1931]19
[2802]20#define DBG_LOCALLOG DBG_palette
21#include "dbglocal.h"
22
[1931]23static UINT SystemPaletteUse = SYSPAL_STATIC; /* currently not considered */
24
25/***********************************************************************
26 * SetSystemPaletteUse32 [GDI32.335]
27 *
28 * RETURNS
29 * Success: Previous system palette
30 * Failure: SYSPAL_ERROR
31 */
32UINT WINAPI SetSystemPaletteUse(
33 HDC hdc, /* [in] Handle of device context */
34 UINT use) /* [in] Palette-usage flag */
35{
36 UINT old = SystemPaletteUse;
37 dprintf(("SetSystemPaletteUse: (%04x,%04x): stub\n", hdc, use ));
38 SystemPaletteUse = use;
39 return old;
40}
41/***********************************************************************
42 * GetSystemPaletteUse32 [GDI32.223] Gets state of system palette
43 *
44 * RETURNS
45 * Current state of system palette
46 */
47UINT WINAPI GetSystemPaletteUse(HDC hdc) /* [in] Handle of device context */
48{
49 dprintf(("GetSystemPaletteUse %x", hdc));
50 return SystemPaletteUse;
51}
[2592]52//******************************************************************************
53//******************************************************************************
54UINT WIN32API RealizePalette( HDC hdc)
55{
[3594]56 UINT rc;
57
58 rc = O32_RealizePalette(hdc);
59 dprintf(("GDI32: RealizePalette %x returned %d", hdc, rc));
[10374]60 if(rc)
[5901]61 {
[10374]62 DIBSECTION_MARK_INVALID(hdc);
[5901]63 }
[3594]64 return rc;
[2592]65}
66//******************************************************************************
67//******************************************************************************
68HPALETTE WIN32API CreatePalette( const LOGPALETTE * arg1)
69{
70 HPALETTE rc;
[3589]71
[9762]72#ifdef DEBUG
[2592]73 for(int i=0; i<arg1->palNumEntries;i++)
74 {
[3589]75 dprintf2(("Index %d : 0x%08X\n",i, *((DWORD*)(&arg1->palPalEntry[i])) ));
[2592]76 }
[4127]77#endif
[2592]78 rc = O32_CreatePalette(arg1);
[4034]79 dprintf(("GDI32: CreatePalette %x %d returns 0x%08X\n", arg1, arg1->palNumEntries, rc));
[2592]80
81 return rc;
82}
83//******************************************************************************
84//******************************************************************************
[4034]85HPALETTE WIN32API SelectPalette(HDC hdc, HPALETTE hPalette, BOOL bForceBackground)
[2592]86{
[5799]87 HPALETTE hPal;
88
[4034]89 dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)", hdc, hPalette, bForceBackground));
[5799]90 hPal = O32_SelectPalette(hdc, hPalette, bForceBackground);
91 return hPal;
[2592]92}
93//******************************************************************************
94//******************************************************************************
95BOOL WIN32API AnimatePalette( HPALETTE arg1, UINT arg2, UINT arg3, const PALETTEENTRY * arg4)
96{
97 dprintf(("GDI32: AnimatePalette"));
98 return O32_AnimatePalette(arg1, arg2, arg3, arg4);
99}
100//******************************************************************************
101//******************************************************************************
102UINT WIN32API GetNearestPaletteIndex( HPALETTE arg1, COLORREF arg2)
103{
104 UINT rc;
105 dprintf(("GDI32: GetNearestPaletteIndex (0x%08X ,0x%08X) ",arg1,arg2));
106 rc = O32_GetNearestPaletteIndex(arg1, arg2);
107 dprintf(("Returns %d\n",rc));
108 return rc;
109}
110//******************************************************************************
111//******************************************************************************
[4034]112UINT WIN32API GetPaletteEntries(HPALETTE hPalette, UINT iStart, UINT count, PPALETTEENTRY entries)
[2592]113{
[4034]114 UINT rc;
115
116 rc = O32_GetPaletteEntries(hPalette, iStart, count, entries);
117 dprintf(("GDI32: GetPaletteEntries %x %d-%d %x returned %d", hPalette, iStart, count, entries, rc));
118 return rc;
[2592]119}
120//******************************************************************************
121//******************************************************************************
122UINT WIN32API GetSystemPaletteEntries( HDC arg1, UINT arg2, UINT arg3, PPALETTEENTRY arg4)
123{
124 UINT rc;
125
126 dprintf(("GDI32: GetSystemPaletteEntries start %d nr %d pal ptr %X", arg2, arg3, arg4));
127 rc = O32_GetSystemPaletteEntries(arg1, arg2, arg3, arg4);
128 dprintf((" GetSystemPaletteEntries returned %d", rc));
129 return(rc);
130}
131//******************************************************************************
132//******************************************************************************
133BOOL WIN32API ResizePalette( HPALETTE arg1, UINT arg2)
134{
135 dprintf(("GDI32: ResizePalette\n"));
136 return O32_ResizePalette(arg1, arg2);
137}
138//******************************************************************************
139//******************************************************************************
[10583]140UINT WIN32API SetPaletteEntries( HPALETTE hPalette, UINT arg2, UINT arg3, const PALETTEENTRY * arg4)
[2592]141{
[3589]142 dprintf(("GDI32: SetPaletteEntries %x %d-%d %x", hPalette, arg2, arg3, arg4));
143 return O32_SetPaletteEntries(hPalette, arg2, arg3, (const PALETTEENTRY *)arg4);
[2592]144}
145//******************************************************************************
146//******************************************************************************
147HPALETTE WIN32API CreateHalftonePalette(HDC hdc)
148{
[4034]149 int i, r, g, b;
150 struct {
151 WORD Version;
152 WORD NumberOfEntries;
153 PALETTEENTRY aEntries[256];
154 } Palette = {
155 0x300, 256
156 };
157
158 dprintf(("GDI32: CreateHalftonePalette %x", hdc));
159 GetSystemPaletteEntries(hdc, 0, 256, Palette.aEntries);
160 return CreatePalette((LOGPALETTE *)&Palette);
161
162 for (r = 0; r < 6; r++) {
163 for (g = 0; g < 6; g++) {
164 for (b = 0; b < 6; b++) {
165 i = r + g*6 + b*36 + 10;
166 Palette.aEntries[i].peRed = r * 51;
167 Palette.aEntries[i].peGreen = g * 51;
168 Palette.aEntries[i].peBlue = b * 51;
[10583]169 }
[4034]170 }
171 }
172
173 for (i = 216; i < 246; i++) {
174 int v = (i - 216) * 8;
175 Palette.aEntries[i].peRed = v;
176 Palette.aEntries[i].peGreen = v;
177 Palette.aEntries[i].peBlue = v;
178 }
179
180 return CreatePalette((LOGPALETTE *)&Palette);
[2592]181}
182//******************************************************************************
183//******************************************************************************
Note: See TracBrowser for help on using the repository browser.