Solved

How to retrieve color depth

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

816 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

12 Experts available now in Live!

Get 1:1 Help Now