Solved

How to retrieve color depth

Posted on 1998-11-25
5
283 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now