| 1 | /* $Id: palette.cpp,v 1.3 2000-02-16 14:18:12 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 |
|
|---|
| 20 | #define DBG_LOCALLOG DBG_palette
|
|---|
| 21 | #include "dbglocal.h"
|
|---|
| 22 |
|
|---|
| 23 | static 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 | */
|
|---|
| 32 | UINT 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 | */
|
|---|
| 47 | UINT WINAPI GetSystemPaletteUse(HDC hdc) /* [in] Handle of device context */
|
|---|
| 48 | {
|
|---|
| 49 | dprintf(("GetSystemPaletteUse %x", hdc));
|
|---|
| 50 | return SystemPaletteUse;
|
|---|
| 51 | }
|
|---|
| 52 | //******************************************************************************
|
|---|
| 53 | //******************************************************************************
|
|---|
| 54 | UINT WIN32API RealizePalette( HDC hdc)
|
|---|
| 55 | {
|
|---|
| 56 | dprintf(("GDI32: RealizePalette %x", hdc));
|
|---|
| 57 | return O32_RealizePalette(hdc);
|
|---|
| 58 | }
|
|---|
| 59 | //******************************************************************************
|
|---|
| 60 | //******************************************************************************
|
|---|
| 61 | HPALETTE WIN32API CreatePalette( const LOGPALETTE * arg1)
|
|---|
| 62 | {
|
|---|
| 63 | HPALETTE rc;
|
|---|
| 64 | dprintf(("GDI32: CreatePalette\n"));
|
|---|
| 65 | for(int i=0; i<arg1->palNumEntries;i++)
|
|---|
| 66 | {
|
|---|
| 67 | dprintf2(("Index %d : 0x%08X\n",i, *((DWORD*)(&arg1->palPalEntry[i])) ));
|
|---|
| 68 | }
|
|---|
| 69 | rc = O32_CreatePalette(arg1);
|
|---|
| 70 | dprintf((" returns 0x%08X\n",rc));
|
|---|
| 71 |
|
|---|
| 72 | return rc;
|
|---|
| 73 | }
|
|---|
| 74 | //******************************************************************************
|
|---|
| 75 | //******************************************************************************
|
|---|
| 76 | HPALETTE WIN32API SelectPalette(HDC arg1, HPALETTE arg2, BOOL arg3)
|
|---|
| 77 | {
|
|---|
| 78 | dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)\n", arg1, arg2, arg3));
|
|---|
| 79 | if(DIBSection::getSection() != NULL)
|
|---|
| 80 | {
|
|---|
| 81 | DIBSection *dsect = DIBSection::findHDC(arg1);
|
|---|
| 82 | if(dsect)
|
|---|
| 83 | {
|
|---|
| 84 | PALETTEENTRY Pal[256];
|
|---|
| 85 | char PalSize = dsect->GetBitCount();
|
|---|
| 86 | dprintf((" - Set Palette Values in DIBSection\n"));
|
|---|
| 87 | if(PalSize<=8)
|
|---|
| 88 | {
|
|---|
| 89 | GetPaletteEntries( arg2, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal);
|
|---|
| 90 | dsect->SetDIBColorTable(0, 1<< PalSize, (RGBQUAD*)&Pal);
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | }
|
|---|
| 94 | }
|
|---|
| 95 | return O32_SelectPalette(arg1, arg2, arg3);
|
|---|
| 96 | }
|
|---|
| 97 | //******************************************************************************
|
|---|
| 98 | //******************************************************************************
|
|---|
| 99 | BOOL WIN32API AnimatePalette( HPALETTE arg1, UINT arg2, UINT arg3, const PALETTEENTRY * arg4)
|
|---|
| 100 | {
|
|---|
| 101 | dprintf(("GDI32: AnimatePalette"));
|
|---|
| 102 | return O32_AnimatePalette(arg1, arg2, arg3, arg4);
|
|---|
| 103 | }
|
|---|
| 104 | //******************************************************************************
|
|---|
| 105 | //******************************************************************************
|
|---|
| 106 | UINT WIN32API GetNearestPaletteIndex( HPALETTE arg1, COLORREF arg2)
|
|---|
| 107 | {
|
|---|
| 108 | UINT rc;
|
|---|
| 109 | dprintf(("GDI32: GetNearestPaletteIndex (0x%08X ,0x%08X) ",arg1,arg2));
|
|---|
| 110 | rc = O32_GetNearestPaletteIndex(arg1, arg2);
|
|---|
| 111 | dprintf(("Returns %d\n",rc));
|
|---|
| 112 | return rc;
|
|---|
| 113 | }
|
|---|
| 114 | //******************************************************************************
|
|---|
| 115 | //******************************************************************************
|
|---|
| 116 | UINT WIN32API GetPaletteEntries( HPALETTE arg1, UINT arg2, UINT arg3, PPALETTEENTRY arg4)
|
|---|
| 117 | {
|
|---|
| 118 | dprintf(("GDI32: GetPaletteEntries"));
|
|---|
| 119 | return O32_GetPaletteEntries(arg1, arg2, arg3, arg4);
|
|---|
| 120 | }
|
|---|
| 121 | //******************************************************************************
|
|---|
| 122 | //******************************************************************************
|
|---|
| 123 | UINT WIN32API GetSystemPaletteEntries( HDC arg1, UINT arg2, UINT arg3, PPALETTEENTRY arg4)
|
|---|
| 124 | {
|
|---|
| 125 | UINT rc;
|
|---|
| 126 |
|
|---|
| 127 | dprintf(("GDI32: GetSystemPaletteEntries start %d nr %d pal ptr %X", arg2, arg3, arg4));
|
|---|
| 128 | rc = O32_GetSystemPaletteEntries(arg1, arg2, arg3, arg4);
|
|---|
| 129 | dprintf((" GetSystemPaletteEntries returned %d", rc));
|
|---|
| 130 | return(rc);
|
|---|
| 131 | }
|
|---|
| 132 | //******************************************************************************
|
|---|
| 133 | //******************************************************************************
|
|---|
| 134 | BOOL WIN32API ResizePalette( HPALETTE arg1, UINT arg2)
|
|---|
| 135 | {
|
|---|
| 136 | dprintf(("GDI32: ResizePalette\n"));
|
|---|
| 137 | return O32_ResizePalette(arg1, arg2);
|
|---|
| 138 | }
|
|---|
| 139 | //******************************************************************************
|
|---|
| 140 | //******************************************************************************
|
|---|
| 141 | UINT WIN32API SetPaletteEntries( HPALETTE arg1, UINT arg2, UINT arg3, PALETTEENTRY * arg4)
|
|---|
| 142 | {
|
|---|
| 143 | dprintf(("GDI32: SetPaletteEntries"));
|
|---|
| 144 | return O32_SetPaletteEntries(arg1, arg2, arg3, (const PALETTEENTRY *)arg4);
|
|---|
| 145 | }
|
|---|
| 146 | //******************************************************************************
|
|---|
| 147 | //******************************************************************************
|
|---|
| 148 | HPALETTE WIN32API CreateHalftonePalette(HDC hdc)
|
|---|
| 149 | {
|
|---|
| 150 | dprintf(("GDI32: CreateHalftonePalette, not implemented\n"));
|
|---|
| 151 | return(NULL);
|
|---|
| 152 | }
|
|---|
| 153 | //******************************************************************************
|
|---|
| 154 | //******************************************************************************
|
|---|