Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to retrieve color depth

Posted on 1998-11-25
5
287 Views
Last Modified: 2010-04-04
Resolution is no problem using Screen.Width and Height.
But what about the colors ??
0
Comment
Question by:Tulip
  • 2
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 100 total points
ID: 1347848
If you mean the number of colors in the color palette:
function GetScreenColors: Integer;
var h : hDC;
begin
    Result := 0;
    try
      h := GetDC( 0 );
      Result := 1 shl  (GetDeviceCaps(h, PLANES) * GetDeviceCaps(h, BITSPIXEL));
    finally
      ReleaseDC( 0, h );
    end;
end;
0
 

Author Comment

by:Tulip
ID: 1347849
Hey, a very quick answer !!
your function solves my problem (256 colors or more ?), but it returns 1 if true color is set.
65536 is returned correctly.
This also happens if I change the return type from integer to longint

0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347850
try his to get the color depth ( 8 bit.. 16 bit.. 24 bit.. )

BitsPerPixel := GetDeviceCaps( GetDC( 0 ), BITSPIXEL );

bryan
0
 

Author Comment

by:Tulip
ID: 1347851
Thanks, Bryan. This works even better !!
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347852
glad to help,

bryan =)

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question