procedure TForm1.SetDCPixelFormat; var DC: HDC; hHeap: THandle; Barvy, i: Integer; Paleta: PLogPalette; Cervena, Zelena, Modra: Byte; nPixelFormat: Integer; pfd: TPixelFormatDescriptor; begin FillChar(pfd, SizeOf(pfd), 0); with pfd do begin nSize := sizeof(pfd); // Velikost struktury pixelu nVersion := 1; // Èíslo verze dwFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER; // struktura pixelu iPixelType:= PFD_TYPE_RGBA; // RGBA pixelové hodnoty cColorBits:= 24; // 24-bit barva cDepthBits:= 32; // 32-bit depth buffer iLayerType:= PFD_MAIN_PLANE; // typ vrstvy end; nPixelFormat := ChoosePixelFormat(DC, @pfd); SetPixelFormat(DC, nPixelFormat, @pfd); DescribePixelFormat(DC, nPixelFormat, sizeof(TPixelFormatDescriptor), pfd); if ((pfd.dwFlags and PFD_NEED_PALETTE) <> 0) then begin Barvy := 1 shl pfd.cColorBits; hHeap := GetProcessHeap; Paleta := HeapAlloc(hHeap, 0, sizeof(TLogPalette) + (Barvy * sizeof(TPaletteEntry))); Paleta^.palVersion := $300; Paleta^.palNumEntries := Barvy; Cervena := (1 shl pfd.cRedBits) - 1; Zelena := (1 shl pfd.cGreenBits) - 1; Modra := (1 shl pfd.cBlueBits) - 1; for i := 0 to Barvy - 1 do begin Paleta^.palPalEntry[i].peRed := (((i shr pfd.cRedShift) and Cervena) * 255) DIV Cervena; Paleta^.palPalEntry[i].peGreen := (((i shr pfd.cGreenShift) and Zelena) * 255) DIV Zelena; Paleta^.palPalEntry[i].peBlue := (((i shr pfd.cBlueShift) and Modra) * 255) DIV Modra; Paleta^.palPalEntry[i].peFlags := 0; end; Palette := CreatePalette(Paleta^); HeapFree(hHeap, 0, Paleta); if (Palette <> 0) then begin SelectPalette(DC, Palette, False); RealizePalette(DC); end; end; end;