/*********************************************************************** * GDISelectPalette (Not a Windows API) */ HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg) { HPALETTE ret = 0; DC *dc; TRACE("%p %p\n", hdc, hpal ); hpal = get_full_gdi_handle( hpal ); if (GetObjectType(hpal) != OBJ_PAL) { WARN("invalid selected palette %p\n",hpal); return 0; } if ((dc = get_dc_ptr( hdc ))) { PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectPalette ); ret = dc->hPalette; if (physdev->funcs->pSelectPalette( physdev, hpal, FALSE )) { dc->hPalette = hpal; if (!wBkg) hPrimaryPalette = hpal; } else ret = 0; release_dc_ptr( dc ); } return ret; }
/*********************************************************************** * SetPaletteEntries [GDI32.@] * * Sets color values for range in palette. * * RETURNS * Success: Number of entries that were set * Failure: 0 */ UINT WINAPI SetPaletteEntries( HPALETTE hpalette, /* [in] Handle of logical palette */ UINT start, /* [in] Index of first entry to set */ UINT count, /* [in] Number of entries to set */ const PALETTEENTRY *entries) /* [in] Address of array of structures */ { PALETTEOBJ * palPtr; UINT numEntries; TRACE("hpal=%p,start=%i,count=%i\n",hpalette,start,count ); hpalette = get_full_gdi_handle( hpalette ); if (hpalette == GetStockObject(DEFAULT_PALETTE)) return 0; palPtr = GDI_GetObjPtr( hpalette, OBJ_PAL ); if (!palPtr) return 0; numEntries = palPtr->count; if (start >= numEntries) { GDI_ReleaseObj( hpalette ); return 0; } if (start+count > numEntries) count = numEntries - start; memcpy( &palPtr->entries[start], entries, count * sizeof(PALETTEENTRY) ); GDI_ReleaseObj( hpalette ); UnrealizeObject( hpalette ); return count; }
/*********************************************************************** * AnimatePalette [GDI32.@] * * Replaces entries in logical palette. * * RETURNS * Success: TRUE * Failure: FALSE * * FIXME * Should use existing mapping when animating a primary palette */ BOOL WINAPI AnimatePalette( HPALETTE hPal, /* [in] Handle to logical palette */ UINT StartIndex, /* [in] First entry in palette */ UINT NumEntries, /* [in] Count of entries in palette */ const PALETTEENTRY* PaletteColors) /* [in] Pointer to first replacement */ { TRACE("%p (%i - %i)\n", hPal, StartIndex,StartIndex+NumEntries); hPal = get_full_gdi_handle( hPal ); if( hPal != GetStockObject(DEFAULT_PALETTE) ) { PALETTEOBJ * palPtr; UINT pal_entries; const PALETTEENTRY *pptr = PaletteColors; palPtr = GDI_GetObjPtr( hPal, OBJ_PAL ); if (!palPtr) return FALSE; pal_entries = palPtr->count; if (StartIndex >= pal_entries) { GDI_ReleaseObj( hPal ); return FALSE; } if (StartIndex+NumEntries > pal_entries) NumEntries = pal_entries - StartIndex; for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++) { /* According to MSDN, only animate PC_RESERVED colours */ if (palPtr->entries[StartIndex].peFlags & PC_RESERVED) { TRACE("Animating colour (%d,%d,%d) to (%d,%d,%d)\n", palPtr->entries[StartIndex].peRed, palPtr->entries[StartIndex].peGreen, palPtr->entries[StartIndex].peBlue, pptr->peRed, pptr->peGreen, pptr->peBlue); palPtr->entries[StartIndex] = *pptr; } else { TRACE("Not animating entry %d -- not PC_RESERVED\n", StartIndex); } } GDI_ReleaseObj( hPal ); /* FIXME: check for palette selected in active window */ } return TRUE; }
/****************************************************************** * EMFDRV_AddHandle */ static UINT EMFDRV_AddHandle( PHYSDEV dev, HGDIOBJ obj ) { EMFDRV_PDEVICE *physDev = get_emf_physdev( dev ); UINT index; for(index = 0; index < physDev->handles_size; index++) if(physDev->handles[index] == 0) break; if(index == physDev->handles_size) { physDev->handles_size += HANDLE_LIST_INC; physDev->handles = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, physDev->handles, physDev->handles_size * sizeof(physDev->handles[0])); } physDev->handles[index] = get_full_gdi_handle( obj ); physDev->cur_handles++; if(physDev->cur_handles > physDev->emh->nHandles) physDev->emh->nHandles++; return index + 1; /* index 0 is reserved for the hmf, so we increment everything by 1 */ }