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

Re: Monitor settings

ferrante@world.std.com (Richard D Ferrante) asks:
How can I determine the current monitor settings e.g., color/gray &
bits per pixel?

Oodles-of-utils (available by ftp from cambridge.apple.com in the
pub/MCL2/contrib directory contains a very large set of excellant
utilities for working with resources, devices etc. The routines
in brutal-utils folder in the Gdevice-u.lisp file contains routines
for working with graphic devices (e.g. screens). I've used these
routines in the menu-enhancements package (also available through
ftp) in the file oou-utils.lisp to return the pixel/bit map.

Here are the code segments that will return the pixel map
from which you can retrieve the number of bits/pixel:

;;; This code is from gdevice-u.lisp from Michael S. Engber

(defun get-max-device (&optional globalRect)
  (if globalRect
    (#_GetMaxDevice :ptr globalRect)
    (with-dereferenced-handles ((GrayRgn_p (%get-ptr (%int-to-ptr #$GrayRgn))))
      (#_GetMaxDevice :ptr (pref GrayRgn_p :Region.rgnBBox)))))

;;;;; This code uses the get-max-device routine
(defun get-gport (view)
  ;; retrieves the underlying port-pixmap, and the two corners of
  ;; the port-rect for a view which possibly straddles screens
  (let ((port (wptr view)))
    (when port
      (let* ((port-rect (rref port :grafport.portrect))
             (screen-gdevice (get-max-device port-rect))
             (screen-top (rref screen-gdevice :gdevice.gdrect.topLeft))
             (screen-bottom (rref screen-gdevice :gdevice.gdrect.bottomRight))
             (port-pmap (rref screen-gdevice :gdevice.gdpmap)))
        (values port-pmap               ; the screen pixmap
                screen-top              ; the top left corner of the screen port rect
                screen-bottom           ; the bottom right corner