void IupGLPalette(Ihandle* ih, int index, float r, float g, float b) { iupASSERT(iupObjectCheck(ih)); if (!iupObjectCheck(ih)) return; /* must be a IupGLCanvas */ if (!iupStrEqual(ih->iclass->name, "glcanvas")) return; /* must be mapped */ if (!ih->handle) return; /* must have a palette */ if (ih->data->palette) { PALETTEENTRY entry; entry.peRed = (BYTE)(r*255); entry.peGreen = (BYTE)(g*255); entry.peBlue = (BYTE)(b*255); entry.peFlags = PC_NOCOLLAPSE; SetPaletteEntries(ih->data->palette,index,1,&entry); UnrealizeObject(ih->data->device); SelectPalette(ih->data->device,ih->data->palette,FALSE); RealizePalette(ih->data->device); } }
void tkSetGreyRamp(void) { HPALETTE CurrentPal; PALETTEENTRY *Entries; UINT Count, i; float intensity; if ( NULL != (CurrentPal = CreateCIPalette( tkhdc )) ) { Count = GetPaletteEntries( CurrentPal, 0, 0, NULL ); Entries = AllocateMemory( Count * sizeof(PALETTEENTRY) ); if ( NULL != Entries ) { for (i = 0; i < Count; i++) { intensity = (float)(((double)i / (double)(Count-1)) * (double)255.0 + (double)0.5); Entries[i].peRed = Entries[i].peGreen = Entries[i].peBlue = (BYTE) intensity; Entries[i].peFlags = 0; } SetPaletteEntries( CurrentPal, 0, Count, Entries ); FreeMemory( Entries ); DelayPaletteRealization(); } } }
static int GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Color * colors, int firstcolor, int ncolors) { GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; if (data->yuv) { SDL_SetError("YUV textures don't have a palette"); return -1; } else { PALETTEENTRY entries[256]; int i; for (i = 0; i < ncolors; ++i) { entries[i].peRed = colors[i].r; entries[i].peGreen = colors[i].g; entries[i].peBlue = colors[i].b; entries[i].peFlags = 0; } if (!SetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) { WIN_SetError("SetPaletteEntries()"); return -1; } return 0; } }
static void set_palette(ui_palette pal1, int start, int end) { PUCHAR pal = (PUCHAR) pal1; HDC hDC; int i; // store new palette entries locally memcpy(backpalette + 4 * start, pal, (end - start) * 4); for (i = start; i <= end; i++) { bmp->bmiColors[i].rgbRed = *(pal + 4 * (i - start) + 0); bmp->bmiColors[i].rgbGreen = *(pal + 4 * (i - start) + 1); bmp->bmiColors[i].rgbBlue = *(pal + 4 * (i - start) + 2); bmp->bmiColors[i].rgbReserved = 0; } // update window/screen #ifdef DDRAW_DRIVER if (directX) { IDirectDrawPalette_SetEntries(dxPalette, 0, start, end - start + 1, (PALETTEENTRY *) pal); } else #endif { SetPaletteEntries(hPalette, start, end - start + 1, (PALETTEENTRY *) pal); hDC = GetDC(hWnd); UnrealizeObject(hPalette); RealizePalette(hDC); ReleaseDC(hWnd, hDC); win32_display(); } }
void graphdefaults() { set_defaults(); for (int i = 0; i <= MAXCOLORS; i++) { current_palette.colors[i] = i; BGIpalette[i] = BGIcolor[i]; } SetPaletteEntries(hPalette, BG, MAXCOLORS+1, BGIpalette); RealizePalette(hdc[0]); SetTextColor(hdc[0], PALETTEINDEX(text_color+BG)); SetTextColor(hdc[1], PALETTEINDEX(text_color+BG)); SetBkColor(hdc[0], PALETTEINDEX(BG)); SetBkColor(hdc[1], PALETTEINDEX(BG)); SelectClipRgn(hdc[0], NULL); SelectClipRgn(hdc[1], NULL); SetViewportOrgEx(hdc[0], 0, 0, NULL); SetViewportOrgEx(hdc[1], 0, 0, NULL); SelectObject(hdc[0], hBrush[fill_settings.pattern]); SelectObject(hdc[1], hBrush[fill_settings.pattern]); moveto(0,0); }
void gr_palette_clear() { int i; HRESULT ddresult; Assert(_lpDDPalActive!=0); // Zero out Palette for (i = 0; i < 256; i++) { PalGDIData.ScratchPal[i].peRed = PalGDIData.ScratchPal[i].peBlue = PalGDIData.ScratchPal[i].peGreen = 0; PalGDIData.ScratchPal[i].peFlags = 0; } if (!hPalGDI) { ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert(ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } gr_palette_faded_out = 1; if (GRMODEINFO(emul)) DDClearDisplay(); }
void IupGLPalette(Ihandle* ih, int index, float r, float g, float b) { IGlControlData* gldata; iupASSERT(iupObjectCheck(ih)); if (!iupObjectCheck(ih)) return; /* must be an IupGLCanvas */ if (ih->iclass->nativetype != IUP_TYPECANVAS || !IupClassMatch(ih, "glcanvas")) return; /* must be mapped */ gldata = (IGlControlData*)iupAttribGet(ih, "_IUP_GLCONTROLDATA"); if (!gldata->window) return; /* must have a palette */ if (gldata->palette) { PALETTEENTRY entry; entry.peRed = (BYTE)(r*255); entry.peGreen = (BYTE)(g*255); entry.peBlue = (BYTE)(b*255); entry.peFlags = PC_NOCOLLAPSE; SetPaletteEntries(gldata->palette,index,1,&entry); UnrealizeObject(gldata->device); SelectPalette(gldata->device,gldata->palette,FALSE); RealizePalette(gldata->device); } }
void setbkcolor(int color) { color &= MAXCOLORS; BGIpalette[0] = BGIcolor[color]; SetPaletteEntries(hPalette, BG, 1, &BGIpalette[0]); RealizePalette(hdc[0]); bkcolor = color; }
void setallpalette(palettetype* pal) { for (int i = 0; i < pal->size; i++) { current_palette.colors[i] = pal->colors[i] & MAXCOLORS; BGIpalette[i] = BGIcolor[pal->colors[i] & MAXCOLORS]; } SetPaletteEntries(hPalette, BG, pal->size, BGIpalette); RealizePalette(hdc[0]); bkcolor = 0; }
static Bool winStoreColorsShadowGDI (ColormapPtr pColormap, int ndef, xColorItem *pdefs) { ScreenPtr pScreen = pColormap->pScreen; winScreenPriv(pScreen); winCmapPriv(pColormap); ColormapPtr curpmap = pScreenPriv->pcmapInstalled; /* Put the X colormap entries into the Windows logical palette */ if (SetPaletteEntries (pCmapPriv->hPalette, pdefs[0].pixel, ndef, pCmapPriv->peColors + pdefs[0].pixel) == 0) { ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n"); return FALSE; } /* Don't install the Windows palette if the colormap is not installed */ if (pColormap != curpmap) { return TRUE; } /* Try to install the newly modified colormap */ if (!winInstallColormapShadowGDI (pColormap)) { ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI " "failed\n"); return FALSE; } #if 0 /* Tell Windows that the palette has changed */ RealizePalette (pScreenPriv->hdcScreen); /* Set the DIB color table */ if (SetDIBColorTable (pScreenPriv->hdcShadow, pdefs[0].pixel, ndef, pCmapPriv->rgbColors + pdefs[0].pixel) == 0) { ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n"); return FALSE; } /* Save a pointer to the newly installed colormap */ pScreenPriv->pcmapInstalled = pColormap; #endif return TRUE; }
void setpalette(int index, int color) { color &= MAXCOLORS; BGIpalette[index] = BGIcolor[color]; current_palette.colors[index] = color; SetPaletteEntries(hPalette, BG+index, 1, &BGIpalette[index]); RealizePalette(hdc[0]); if (index == 0) { bkcolor = 0; } }
void setrgbpalette(int index, int red, int green, int blue) { BGIpalette[index].peRed = red & 0xFC; BGIpalette[index].peGreen = green & 0xFC; BGIpalette[index].peBlue = blue & 0xFC; SetPaletteEntries(hPalette, BG+index, 1, &BGIpalette[index]); RealizePalette(hdc[0]); if (index == 0) { bkcolor = 0; } }
VOID vTestPal1(void) { HPALETTE hpal1; UINT uiTemp; hpal1 = CreatePalette((LPLOGPALETTE) &logpalVGA); if (hpal1 == (HPALETTE) 0) { DbgPrint("vTestPal1 failed to create palette\n"); return; } AnimatePalette(hpal1, 0, 100, NULL); SetPaletteEntries(hpal1, 0, 100, NULL); uiTemp = GetNearestPaletteIndex(hpal1, 0); if (uiTemp != 0) DbgPrint("GetNearestPaletteIndex failed 0 %lx\n", uiTemp); uiTemp = GetNearestPaletteIndex(hpal1, 0x00000080); if (uiTemp != 1) DbgPrint("GetNearestPaletteIndex failed 1 %lx\n", uiTemp); uiTemp = GetNearestPaletteIndex(hpal1, 0x00C0C0C0); if (uiTemp != 7) DbgPrint("GetNearestPaletteIndex failed 7 %lx\n", uiTemp); uiTemp = GetNearestPaletteIndex(hpal1, 0x0000FF00); if (uiTemp != 10) DbgPrint("GetNearestPaletteIndex failed 10 %lx\n", uiTemp); uiTemp = GetNearestPaletteIndex(hpal1, 0x00FFFFFF); if (uiTemp != 15) DbgPrint("GetNearestPaletteIndex failed 15 %lx\n", uiTemp); uiTemp = GetNearestPaletteIndex(hpal1, PALETTEINDEX(5)); if (uiTemp != 5) DbgPrint("GetNearestPaletteIndex failed 15 %lx\n", uiTemp); uiTemp = GetNearestPaletteIndex(hpal1, PALETTEINDEX(10)); if (uiTemp != 10) DbgPrint("GetNearestPaletteIndex failed 15 %lx\n", uiTemp); if (!DeleteObject(hpal1)) DbgPrint("vTestPal1 failed to delete palette\n"); }
void setPaletteIndex(int i, float r, float g, float b) { PALETTEENTRY pe; pe.peRed = (BYTE) (255.0F * r); pe.peGreen = (BYTE) (255.0F * g); pe.peBlue = (BYTE) (255.0F * b); pe.peFlags = PC_NOCOLLAPSE; SetPaletteEntries(hPalette, i, 1, &pe); UnrealizeObject(hPalette); }
HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette, DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries) { struct wined3d_resource *resource; TRACE("palette %p, flags %#x, start %u, count %u, entries %p.\n", palette, flags, start, count, entries); TRACE("Palette flags: %#x.\n", palette->flags); if (palette->flags & WINEDDPCAPS_8BITENTRIES) { const BYTE *entry = (const BYTE *)entries; unsigned int i; for (i = start; i < count + start; ++i) palette->palents[i].peRed = *entry++; } else { memcpy(palette->palents + start, entries, count * sizeof(*palette->palents)); /* When WINEDDCAPS_ALLOW256 isn't set we need to override entry 0 with black and 255 with white */ if (!(palette->flags & WINEDDPCAPS_ALLOW256)) { TRACE("WINEDDPCAPS_ALLOW256 set, overriding palette entry 0 with black and 255 with white\n"); palette->palents[0].peRed = 0; palette->palents[0].peGreen = 0; palette->palents[0].peBlue = 0; palette->palents[255].peRed = 255; palette->palents[255].peGreen = 255; palette->palents[255].peBlue = 255; } if (palette->hpal) SetPaletteEntries(palette->hpal, start, count, palette->palents + start); } /* If the palette is attached to the render target, update all render targets */ LIST_FOR_EACH_ENTRY(resource, &palette->device->resources, struct wined3d_resource, resource_list_entry) { if (resource->type == WINED3D_RTYPE_SURFACE) { struct wined3d_surface *surface = surface_from_resource(resource); if (surface->palette == palette) surface->surface_ops->surface_realize_palette(surface); } } return WINED3D_OK; }
void tkSetOneColor(int index, float r, float g, float b) { PALETTEENTRY PalEntry; HPALETTE Palette; if ( NULL != (Palette = CreateCIPalette( tkhdc )) ) { PalEntry.peRed = (BYTE)(r*(float)255.0 + (float)0.5); PalEntry.peGreen = (BYTE)(g*(float)255.0 + (float)0.5); PalEntry.peBlue = (BYTE)(b*(float)255.0 + (float)0.5); PalEntry.peFlags = 0; SetPaletteEntries( Palette, index, 1, &PalEntry); DelayPaletteRealization(); } }
/* Primitive palette functions */ static int set_palette (UINT8 *pal, int scol, int numcols) { int i; #if 0 HDC hdc; LOGPALETTE *palette; PALETTEENTRY *entries; hdc = GetDC(hwndMain); if (GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL) <= 8) { entries = (PALETTEENTRY *)malloc(32 * sizeof(PALETTEENTRY)); for (i = scol; i < numcols; i++) { entries[i].peRed = pal[i*3 ] << 2; entries[i].peGreen = pal[i*3 + 1] << 2; entries[i].peBlue = pal[i*3 + 2] << 2; entries[i].peFlags = PC_NOCOLLAPSE; } palette = malloc(sizeof(*palette) + 32 * sizeof(PALETTEENTRY)); if (palette == NULL) { OutputDebugString("malloc failed for palette"); return err_Unk; } palette->palVersion = 0x300; palette->palNumEntries = 32; g_hPalette = CreatePalette(palette); free(palette); SetPaletteEntries(g_hPalette, 0, 32, entries); SelectPalette(hdc, g_hPalette, FALSE); RealizePalette(hdc); } else #endif for (i = scol; i < numcols; i ++) { g_screen.binfo->bmiColors[i].rgbRed = (pal[i*3 ]) << 2; g_screen.binfo->bmiColors[i].rgbGreen= (pal[i*3 + 1]) << 2; g_screen.binfo->bmiColors[i].rgbBlue = (pal[i*3 + 2]) << 2; g_screen.binfo->bmiColors[i].rgbReserved = 0; } ReleaseDC(hwndMain, hdc); return err_OK; }
/*\internal Store color values in the given colormap. */ static void qStoreColors(HPALETTE cmap, const QGLColormap & cols) { QRgb color; PALETTEENTRY pe; for (int i = 0; i < cols.size(); i++) { color = cols.entryRgb(i); pe.peRed = qRed(color); pe.peGreen = qGreen(color); pe.peBlue = qBlue(color); pe.peFlags = 0; SetPaletteEntries(cmap, i, 1, &pe); } }
void gr_palette_step_up( int r, int g, int b ) { HRESULT ddresult; int i; ubyte *p; int temp; Assert(_lpDDPalActive!=0); if (gr_palette_faded_out) return; if ( (r==last_r) && (g==last_g) && (b==last_b) ) return; last_r = r; last_g = g; last_b = b; p=gr_palette; for (i=0; i<256; i++ ) { temp = (int)(*p++) + r + gr_palette_gamma; if (temp<0) temp=0; else if (temp>63) temp=63; PalGDIData.ScratchPal[i].peRed = temp << 2; temp = (int)(*p++) + g + gr_palette_gamma; if (temp<0) temp=0; else if (temp>63) temp=63; PalGDIData.ScratchPal[i].peGreen = temp << 2; temp = (int)(*p++) + b + gr_palette_gamma; if (temp<0) temp=0; else if (temp>63) temp=63; PalGDIData.ScratchPal[i].peBlue = temp << 2; PalGDIData.ScratchPal[i].peFlags = PC_NOCOLLAPSE; } if (!PalGDI) { ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert(ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } }
int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) { RGBQUAD *pal; int i; #ifndef _WIN32_WCE HDC hdc, mdc; #else HDC hdc; #endif /* Update the display palette */ hdc = GetDC(SDL_Window); if ( screen_pal ) { PALETTEENTRY *entries; entries = (PALETTEENTRY *)alloca(ncolors*sizeof(PALETTEENTRY)); for ( i=0; i<ncolors; ++i ) { entries[i].peRed = colors[i].r; entries[i].peGreen = colors[i].g; entries[i].peBlue = colors[i].b; entries[i].peFlags = PC_NOCOLLAPSE; } SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); SelectPalette(hdc, screen_pal, FALSE); RealizePalette(hdc); } /* Copy palette colors into DIB palette */ pal = (RGBQUAD *)alloca(ncolors*sizeof(RGBQUAD)); for ( i=0; i<ncolors; ++i ) { pal[i].rgbRed = colors[i].r; pal[i].rgbGreen = colors[i].g; pal[i].rgbBlue = colors[i].b; pal[i].rgbReserved = 0; } /* Set the DIB palette and update the display */ #ifndef _WIN32_WCE mdc = CreateCompatibleDC(hdc); SelectObject(mdc, screen_bmp); SetDIBColorTable(mdc, firstcolor, ncolors, pal); BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, mdc, 0, 0, SRCCOPY); DeleteDC(mdc); #endif ReleaseDC(SDL_Window, hdc); return(1); }
void IupGLPalette (Ihandle* self, int index, float r, float g, float b) { GLData* d = (GLData*)IupGetAttribute(self,"_IUPGL_DATA"); if (d && d->palette) { PALETTEENTRY entry; entry.peRed = (BYTE)(r*255); entry.peGreen = (BYTE)(g*255); entry.peBlue = (BYTE)(b*255); entry.peFlags = PC_NOCOLLAPSE; SetPaletteEntries(d->palette,index,1,&entry); UnrealizeObject(d->device); SelectPalette(d->device,d->palette,FALSE); RealizePalette(d->device); } }
void gr_palette_load( ubyte * pal ) { int i; ubyte c; HRESULT ddresult; Assert(_lpDDPalActive!=0); for (i=0; i<256; i++ ) { c = pal[i*3] + gr_palette_gamma; if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peRed = c << 2; gr_current_pal[i*3] = pal[i*3]; c = pal[i*3+1] + gr_palette_gamma; if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peGreen = c << 2; gr_current_pal[i*3+1] = pal[i*3+1]; c = pal[i*3+2] + gr_palette_gamma; if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peBlue = c << 2; gr_current_pal[i*3+2] = pal[i*3+2]; PalGDIData.ScratchPal[i].peFlags = 0; } if (!hPalGDI) { ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert(ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } gr_palette_faded_out = 0; init_computed_colors(); }
void gr_palette_read(ubyte * palette) { int i; HRESULT ddresult; Assert(_lpDDPalActive!=0); if (!hPalGDI) { ddresult = IDirectDrawPalette_GetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert(ddresult == DD_OK); } else { SetPaletteEntries(hPalGDI, 0, 256, PalGDIData.ScratchPal); } for (i=0; i<256; i++ ) { *palette++ = PalGDIData.ScratchPal[i].peRed >> 2; *palette++ = PalGDIData.ScratchPal[i].peGreen >> 2; *palette++ = PalGDIData.ScratchPal[i].peBlue >> 2; } }
static BOOL xxPointToHit(LONG addr, PVOID pvBits, DWORD cb) { UINT iLeng = 0; pBmpHunted[iExtPalColor] = addr; iLeng = SetBitmapBits(hBmpHunted, 0xD00, pBmpHunted); if (iLeng < 0xD00) { return FALSE; } PVOID pvTable = NULL; UINT cbSize = (cb + 3) & ~3; // sizeof(PALETTEENTRY) => 4 pvTable = malloc(cbSize); memcpy(pvTable, pvBits, cb); iLeng = SetPaletteEntries(hPalExtend, 0, cbSize / 4, (PPALETTEENTRY)pvTable); free(pvTable); if (iLeng < cbSize / 4) { return FALSE; } return TRUE; }
void vdriver_set_colors(int first_color, int num_colors, const ColorSpec *colors) { int i, c; PALETTEENTRY entries[NUM_COLORS]; if(!saved_pal || ((first_color + num_colors) > NUM_COLORS)) { /* Fatal error... */ return; } /* Set the palette */ for(i = 0; i < num_colors; ++i) { entries[i].peRed = (CW(colors[i].rgb.red) >> 8); entries[i].peGreen = (CW(colors[i].rgb.green) >> 8); entries[i].peBlue = (CW(colors[i].rgb.blue) >> 8); entries[i].peFlags = 0; } if(sys_palette_p) SetPaletteEntries(our_palette, first_color, num_colors, entries); for(i = 0; i < num_colors; ++i) { c = first_color + i; saved_pal[c].rgbRed = entries[i].peRed; saved_pal[c].rgbGreen = entries[i].peGreen; saved_pal[c].rgbBlue = entries[i].peBlue; saved_pal[c].rgbReserved = 0; } /* Re-create the DIB with the new palette */ vdriver_set_mode(vdriver_width, vdriver_height, vdriver_bpp, vdriver_grayscale_p); /* Redraw the screen with the new colors */ vdriver_update_screen(0, 0, vdriver_height, vdriver_width, false); }
Bool qtStoreColorsShadow (ColormapPtr pColormap, int ndef, xColorItem *pdefs) { #if 0 /* ### NOT YET */ ScreenPtr pScreen = pColormap->pScreen; winScreenPriv(pScreen); winCmapPriv(pColormap); ColormapPtr curpmap = pScreenPriv->pcmapInstalled; /* Put the X colormap entries into the Windows logical palette */ if (SetPaletteEntries (pCmapPriv->hPalette, pdefs[0].pixel, ndef, pCmapPriv->peColors + pdefs[0].pixel) == 0) { ErrorF ("qtStoreColorsShadow - SetPaletteEntries () failed\n"); return FALSE; } /* Don't install the Windows palette if the colormap is not installed */ if (pColormap != curpmap) { return TRUE; } /* Try to install the newly modified colormap */ if (!winInstallColormapShadow (pColormap)) { ErrorF ("qtInstallColormapShadow - winInstallColormapShadow " "failed\n"); return FALSE; } #endif return TRUE; }
static void SetPaletteColors(void) { assert(This.m_PalEntries != NULL); assert(This.m_AdjustedPalette != NULL); if (This.m_nDepth == 8) { assert(This.m_hPalette != NULL); SetPaletteEntries(This.m_hPalette, 0, This.m_nTotalColors, This.m_AdjustedPalette); } else if (This.m_bModifiablePalette == TRUE) { UINT i; for (i = 0; i < This.m_nTotalColors; i++) { This.m_p16BitLookup[i] = MAKECOL(This.m_AdjustedPalette[i].peRed, This.m_AdjustedPalette[i].peGreen, This.m_AdjustedPalette[i].peBlue) * 0x10001; } } }
/* Called in response to WM_ACTIVATE messages */ void Win_Focus(int on) { HDC hdc; /* Right now, the only thing we care about is palette manipulation */ if(!sys_palette_p) return; hdc = GetDC(Win_Window); if(on) { PALETTEENTRY entries[NUM_COLORS]; /* Save the current system palette */ GetSystemPaletteEntries(hdc, 0, NUM_COLORS, entries); SetPaletteEntries(sys_palette, 0, NUM_COLORS, entries); /* Set our palette as the logical palette */ #ifdef PRIVATE_CMAP /* This is more trouble than it's worth. It fries system colors */ SetSystemPaletteUse(hdc, SYSPAL_NOSTATIC); #endif SelectPalette(hdc, our_palette, false); RealizePalette(hdc); InvalidateRect(Win_Window, NULL, 0); } else { /* Set the system palette and reset colors */ SelectPalette(hdc, sys_palette, false); RealizePalette(hdc); #ifdef PRIVATE_CMAP SetSystemPaletteUse(hdc, SYSPAL_STATIC); #endif } ReleaseDC(hdc, Win_Window); }
static void test_palette_entries(void) { char logpalettebuf[sizeof(LOGPALETTE) + sizeof(logpalettedata)]; PLOGPALETTE logpalette = (PLOGPALETTE)logpalettebuf; HPALETTE hpal; UINT res=0; PALETTEENTRY palEntry = { 0x1, 0x2, 0x3, 0xff }; PALETTEENTRY getEntryResult; /* Initialize the logical palette with a few colours */ logpalette->palVersion = 0x300; logpalette->palNumEntries = 8; memcpy( logpalette->palPalEntry, logpalettedata, sizeof(logpalettedata) ); hpal = CreatePalette( logpalette ); /* Set a new entry with peFlags to 0xff */ SetPaletteEntries(hpal, 0, 1, &palEntry); /* Retrieve the entry to see if GDI32 performs any filtering on peFlags */ res = GetPaletteEntries(hpal, 0, 1, &getEntryResult); ok(res == 1, "GetPaletteEntries should have returned 1 but returned %d\n", res); ok( palEntry.peFlags == getEntryResult.peFlags, "palEntry.peFlags (%#x) != getEntryResult.peFlags (%#x)\n", palEntry.peFlags, getEntryResult.peFlags ); }
BOOL MDIORGB_SetColour (OOTint pmClrNum, OOTreal pmRed, OOTreal pmGreen, OOTreal pmBlue) { PALETTEENTRY myPaletteEntry; MIOWinInfoPtr myInfo = MIO_selectedRunWindowInfo; /* BITMAPINFO myBitMapInfo; PBITMAPINFOHEADER myBitMapInfoHeader; void *myBits; ZeroMemory (&myBitMapInfo, sizeof(myBitMapInfo)); myBitMapInfo.bmiHeader.biSize = sizeof (myBitMapInfo.bmiHeader); GetDIBits (myInfo -> offscreenDeviceContext, myInfo -> offscreenBitMap, 0, 0, NULL, &myBitMapInfo, DIB_PAL_COLORS); myBitMapInfoHeader = (BITMAPINFOHEADER *) malloc (sizeof (BITMAPINFO) + sizeof (RGBQUAD) * 256); // Duplicate the bitmapinfoheader information into the new struct. memcpy(myBitMapInfoHeader , &myBitMapInfo, sizeof(myBitMapInfo.bmiHeader)); myBits = malloc (myBitMapInfoHeader -> biSizeImage); GetDIBits (myInfo -> offscreenDeviceContext, myInfo -> offscreenBitMap, 0, 1, myBits, &myBitMapInfo, DIB_PAL_COLORS); /* 1. To fill in a BITMAPINFOHEADER struct. Call Thus: BITMAPINFO bmi; Here GetDIBits will use the inititlized bmiSize member to determine which structure it should be writing to. It will fill in the BITMAPINFOHEADER struct with the size and characteristics of the bitmap. myBitMapInfo = MyCreateBitmapInfo (myInfo -> offscreenBitMap); if (myBitMapInfo == NULL) { // Error Message return FALSE; } myBitMapInfoHeader = (PBITMAPINFOHEADER) myBitMapInfo; myBits = malloc (myBitMapInfoHeader -> biSizeImage); if (myBits == NULL) { // Error Message return FALSE; } // Retrieve the color table (RGBQUAD array) and the bits // (array of palette indices) from the DIB. // if (!GetDIBits (myInfo -> deviceContext, myInfo -> offscreenBitMap, 0, // (WORD) myBitMapInfoHeader -> biHeight, myBits, myBitMapInfo, // DIB_RGB_COLORS)) // { // // Error Message // return FALSE; // } */ /*****/ // Now set the new palette entry myPaletteEntry.peRed = (int) (pmRed * 255 + 0.5); myPaletteEntry.peGreen = (int) (pmGreen * 255 + 0.5); myPaletteEntry.peBlue = (int) (pmBlue * 255 + 0.5); myPaletteEntry.peFlags = 0; if (SetPaletteEntries (myInfo -> palette, pmClrNum, 1, &myPaletteEntry) == 0) { return FALSE; } MDIORGB_UseNewPalette (myInfo); RealizePalette (myInfo -> deviceContext); RealizePalette (myInfo -> offscreenDeviceContext); return TRUE; } // MDIORGB_SetColour