Mega Code Archive

 
Categories / Delphi / Graphic
 

How to get the current color depth

Title: How to get the current color depth function GetColorDepth: string; var DesktopDC: HDC; // LongWord BitsPerPixel: Integer; begin DesktopDC := GetDC(0); BitsPerPixel := GetDeviceCaps(DesktopDC, BITSPIXEL); case BitsPerPixel of 4: Result := '4-Bit'; 8: Result := '8-Bit'; 16: Result := '16-Bit'; 24: Result := '24-Bit'; 32: Result := '32-Bit'; end; ReleaseDC(0, DesktopDC); end; procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(GetColorDepth); end;