[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Screen depth



At  3:35 PM 10/25/93 +0100, Gilles Serasset wrote:
>Hello,
>
>I think this has been discussed before, but I can't find any reference in
>my archives.
>
>How can I check the main screen depth. I would like to know if the screen
>is color/grayscale/B&W.

There is no documented way to do it short of calling the device manager
traps yourself. There are some internal, undocumented functions that
MCL uses to figure out where to pop up the USER-PICK-COLOR dialog.
Using them you could define:

(defun main-screen-bits-and-colorp ()
  (ccl::do-screens (screen)
    (when (eql #@(0 0) (ccl::screen-position screen))
      (return (values (ccl::screen-bits screen)
                      (ccl::screen-color-p screen))))))

--------------------------------------------------------------------------

; from ":lib;color.lisp" in the "Additional MCL Source Code" folder
; on the "MCL 2.0 CD".

(in-package :ccl)

(defun screen-attribute (screen attribute)
  (#_TestDeviceAttribute screen attribute))

(defun screen-active-p (screen)
  (and (screen-attribute screen #$screenDevice)
       (screen-attribute screen #$screenActive)))

(defun screen-color-p (screen)
  (screen-attribute screen #$gdDevType))

(defun screen-bits (screen)
  (rref (rref screen :GDevice.gdPMap) :PixMap.PixelSize))

(defun screen-position (screen)
  (rref screen :GDevice.gdRect.topleft))

(defun screen-size (screen)
  (subtract-points
   (rref screen :GDevice.gdRect.bottomright)
   (screen-position screen)))

(defmacro do-screens ((s &optional (active-only? t)) &body body)
  `(with-macptrs ((,s (require-trap #_GetDeviceList)))
     (loop
       (if (%null-ptr-p ,s) (return))
       (when ,(if active-only? `(screen-active-p ,s) t)
         ,@body)
       (%setf-macptr ,s (require-trap #_GetNextDevice ,s)))))