Delphi Sources

Как получить количество цветов в системной палитре



Функция GetNumColors возвращает количество цветов для актуально выбранного разрешения экрана.
function GetNumColors: LongInt;
var
  BPP: Integer;
  DC: HDC;
begin
  DC := CreateDC('DISPLAY', nil, nil, nil);
  if DC <> 0 then
  begin
    try
      BPP := GetDeviceCaps(DC, BITPIXEL) * GetDeviceCaps(DC, PLANES);
    finally
      DeleteDC(DC);
    end;
    case BPP of
      1: Result := 2;
      4: Result := 16;
      8: Result := 256;
      15: Result := 32768;
      16: Result := 65536;
      24: Result := 16777216;
    end;
  end
  else
    Result := 0;
end;

Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте