source: trunk/src/gdi32/palette.cpp@ 2592

Last change on this file since 2592 was 2592, checked in by sandervl, 26 years ago

cleaned up + dibsection fixes

File size: 5.5 KB
Line 
1/* $Id: palette.cpp,v 1.2 2000-02-01 12:53:31 sandervl Exp $ */
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>
18#include "dibsect.h"
19
20static UINT SystemPaletteUse = SYSPAL_STATIC; /* currently not considered */
21
22/***********************************************************************
23 * SetSystemPaletteUse32 [GDI32.335]
24 *
25 * RETURNS
26 * Success: Previous system palette
27 * Failure: SYSPAL_ERROR
28 */
29UINT WINAPI SetSystemPaletteUse(
30 HDC hdc, /* [in] Handle of device context */
31 UINT use) /* [in] Palette-usage flag */
32{
33 UINT old = SystemPaletteUse;
34 dprintf(("SetSystemPaletteUse: (%04x,%04x): stub\n", hdc, use ));
35 SystemPaletteUse = use;
36 return old;
37}
38/***********************************************************************
39 * GetSystemPaletteUse32 [GDI32.223] Gets state of system palette
40 *
41 * RETURNS
42 * Current state of system palette
43 */
44UINT WINAPI GetSystemPaletteUse(HDC hdc) /* [in] Handle of device context */
45{
46 dprintf(("GetSystemPaletteUse %x", hdc));
47 return SystemPaletteUse;
48}
49//******************************************************************************
50//******************************************************************************
51UINT WIN32API RealizePalette( HDC hdc)
52{
53 dprintf(("GDI32: RealizePalette %x", hdc));
54 return O32_RealizePalette(hdc);
55}
56//******************************************************************************
57//******************************************************************************
58HPALETTE WIN32API CreatePalette( const LOGPALETTE * arg1)
59{
60 HPALETTE rc;
61 dprintf(("GDI32: CreatePalette\n"));
62 for(int i=0; i<arg1->palNumEntries;i++)
63 {
64 dprintf2(("Index %d : 0x%08X\n",i, *((DWORD*)(&arg1->palPalEntry[i])) ));
65 }
66 rc = O32_CreatePalette(arg1);
67 dprintf((" returns 0x%08X\n",rc));
68
69 return rc;
70}
71//******************************************************************************
72//******************************************************************************
73HPALETTE WIN32API SelectPalette(HDC arg1, HPALETTE arg2, BOOL arg3)
74{
75 dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)\n", arg1, arg2, arg3));
76 if(DIBSection::getSection() != NULL)
77 {
78 DIBSection *dsect = DIBSection::findHDC(arg1);
79 if(dsect)
80 {
81 PALETTEENTRY Pal[256];
82 char PalSize = dsect->GetBitCount();
83 dprintf((" - Set Palette Values in DIBSection\n"));
84 if(PalSize<=8)
85 {
86 GetPaletteEntries( arg2, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal);
87 dsect->SetDIBColorTable(0, 1<< PalSize, (RGBQUAD*)&Pal);
88 }
89
90 }
91 }
92 return O32_SelectPalette(arg1, arg2, arg3);
93}
94//******************************************************************************
95//******************************************************************************
96BOOL WIN32API AnimatePalette( HPALETTE arg1, UINT arg2, UINT arg3, const PALETTEENTRY * arg4)
97{
98 dprintf(("GDI32: AnimatePalette"));
99 return O32_AnimatePalette(arg1, arg2, arg3, arg4);
100}
101//******************************************************************************
102//******************************************************************************
103UINT WIN32API GetNearestPaletteIndex( HPALETTE arg1, COLORREF arg2)
104{
105 UINT rc;
106 dprintf(("GDI32: GetNearestPaletteIndex (0x%08X ,0x%08X) ",arg1,arg2));
107 rc = O32_GetNearestPaletteIndex(arg1, arg2);
108 dprintf(("Returns %d\n",rc));
109 return rc;
110}
111//******************************************************************************
112//******************************************************************************
113UINT WIN32API GetPaletteEntries( HPALETTE arg1, UINT arg2, UINT arg3, PPALETTEENTRY arg4)
114{
115 dprintf(("GDI32: GetPaletteEntries"));
116 return O32_GetPaletteEntries(arg1, arg2, arg3, arg4);
117}
118//******************************************************************************
119//******************************************************************************
120UINT WIN32API GetSystemPaletteEntries( HDC arg1, UINT arg2, UINT arg3, PPALETTEENTRY arg4)
121{
122 UINT rc;
123
124 dprintf(("GDI32: GetSystemPaletteEntries start %d nr %d pal ptr %X", arg2, arg3, arg4));
125 rc = O32_GetSystemPaletteEntries(arg1, arg2, arg3, arg4);
126 dprintf((" GetSystemPaletteEntries returned %d", rc));
127 return(rc);
128}
129//******************************************************************************
130//******************************************************************************
131BOOL WIN32API ResizePalette( HPALETTE arg1, UINT arg2)
132{
133 dprintf(("GDI32: ResizePalette\n"));
134 return O32_ResizePalette(arg1, arg2);
135}
136//******************************************************************************
137//******************************************************************************
138UINT WIN32API SetPaletteEntries( HPALETTE arg1, UINT arg2, UINT arg3, PALETTEENTRY * arg4)
139{
140 dprintf(("GDI32: SetPaletteEntries"));
141 return O32_SetPaletteEntries(arg1, arg2, arg3, (const PALETTEENTRY *)arg4);
142}
143//******************************************************************************
144//******************************************************************************
145HPALETTE WIN32API CreateHalftonePalette(HDC hdc)
146{
147 dprintf(("GDI32: CreateHalftonePalette, not implemented\n"));
148 return(NULL);
149}
150//******************************************************************************
151//******************************************************************************
Note: See TracBrowser for help on using the repository browser.