Board index » delphi » Screen pixelformat

Screen pixelformat


2003-10-14 11:19:15 PM
delphi217
Hello,
before starting my app, I'd like to know if the screen is in 24 bits or
32 bits (true color)
for this I use this in a separate unit
getdevicecaps(application.MainForm.Canvas.Handle, bitspixel)), but of course
the mainform isn't still created and it crashes.
is it possible to get directly the bitperpixel of the screen?
thanks
Armindo
 
 

Re:Screen pixelformat

Hi Armindo,
ads wrote in <XXXX@XXXXX.COM>:
Quote
for this I use this in a separate unit
getdevicecaps(application.MainForm.Canvas.Handle, bitspixel)), but of course
the mainform isn't still created and it crashes.

is it possible to get directly the bitperpixel of the screen?
There is a second mistake, you need the device context of the screen
(desktop), not the device context of your MainForm window.
var
DesktopDC: HDC;
BitsPerPixel: Integer;
begin
DesktopDC := GetDC(0);
try
BitsPerPixel := GetDeviceCaps(DesktopDC, BITSPIXEL);
finally
ReleaseDC(0, DesktopDC);
end;
...
// use BitsPerPixel
...
end;
Bye Peter.
--
JEDI+ API, the active JEDI Header Conversions Project:
jediplus.pjh2.de
 

Re:Screen pixelformat

Thanks Peter.
 

Re:Screen pixelformat

Quote
BitsPerPixel := GetDeviceCaps(DesktopDC, BITSPIXEL);
Theoretically BitsPerPixel is
GetDeviceCaps(DesktopDC, BITSPIXEL) * GetDeviceCaps(DesktopDC, PLANES)
but since GetDeviceCaps(DesktopDC, PLANES) is 1 for all modern screen modes
(multiple planes were only used for 16 color modes), the formula above is
alright (I think we already had this discussion, Peter :-).
Jens
 

Re:Screen pixelformat

Hi Jens,
Jens Gruschel wrote in <XXXX@XXXXX.COM>:
Quote
Theoretically BitsPerPixel is

GetDeviceCaps(DesktopDC, BITSPIXEL) * GetDeviceCaps(DesktopDC, PLANES)
Practically too. ;-)
Quote
(I think we already had this discussion, Peter :-).
Not as far as I remember.
Bye Peter.
--
JEDI+ API, the active JEDI Header Conversions Project:
jediplus.pjh2.de