2 * FreeRDP: A Remote Desktop Protocol Client
3 * GDI Palette Functions
5 * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 /* GDI Palette Functions: http://msdn.microsoft.com/en-us/library/dd183454/ */
26 #include <freerdp/freerdp.h>
27 #include <freerdp/gdi/gdi.h>
29 #include <freerdp/gdi/palette.h>
31 static HGDI_PALETTE hSystemPalette = NULL;
33 static const GDI_PALETTEENTRY default_system_palette[20] =
35 /* First 10 entries */
61 * Create a new palette.\n
63 * @param original palette
67 HGDI_PALETTE gdi_CreatePalette(HGDI_PALETTE palette)
69 HGDI_PALETTE hPalette = (HGDI_PALETTE) malloc(sizeof(GDI_PALETTE));
70 hPalette->count = palette->count;
71 hPalette->entries = (GDI_PALETTEENTRY*) malloc(sizeof(GDI_PALETTEENTRY) * hPalette->count);
72 memcpy(hPalette->entries, palette->entries, sizeof(GDI_PALETTEENTRY) * hPalette->count);
77 * Create system palette\n
78 * @return system palette
81 HGDI_PALETTE CreateSystemPalette()
83 HGDI_PALETTE palette = (HGDI_PALETTE) malloc(sizeof(GDI_PALETTE));
86 palette->entries = (GDI_PALETTEENTRY*) malloc(sizeof(GDI_PALETTEENTRY) * 256);
87 memset(palette->entries, 0, sizeof(GDI_PALETTEENTRY) * 256);
89 memcpy(&palette->entries[0], &default_system_palette[0], 10 * sizeof(GDI_PALETTEENTRY));
90 memcpy(&palette->entries[256 - 10], &default_system_palette[10], 10 * sizeof(GDI_PALETTEENTRY));
96 * Get system palette\n
97 * @return system palette
100 HGDI_PALETTE gdi_GetSystemPalette()
102 if (hSystemPalette == NULL)
103 hSystemPalette = CreateSystemPalette();
105 return hSystemPalette;