98 lines
3.4 KiB
Scheme
98 lines
3.4 KiB
Scheme
;; author -> Norbert Freudemann
|
|
;; creation date : 16/07/2001
|
|
;; last change : 16/07/2001
|
|
|
|
;; create a new pixmap.
|
|
|
|
(define (create-pixmap drawable width height depth)
|
|
(let* ((display (drawable-display drawable))
|
|
(pixmap (%create-pixmap (display-Xdisplay display)
|
|
(drawable-Xobject drawable)
|
|
width height depth)))
|
|
(make-pixmap pixmap display #t)))
|
|
|
|
(import-lambda-definition %create-pixmap (Xdisplay Xdrawable w h depth)
|
|
"scx_Create_Pixmap")
|
|
|
|
;; Special pixmap values
|
|
|
|
(define (special-pixmap:none dpy)
|
|
(make-pixmap 0 dpy #f))
|
|
(define (special-pixmap:copy-from-parent dpy)
|
|
(make-pixmap 0 dpy #f))
|
|
(define (special-pixmap:parent-relative dpy)
|
|
(make-pixmap 1 dpy #f))
|
|
|
|
;; create-bitmap-from-data creates a new pixmap, consisting of the
|
|
;; image found in data, which has to be a string. Such an image can be
|
|
;; generated with write-bitmap-file. See XCreateBitmapFromData.
|
|
|
|
(define (create-bitmap-from-data window data width height)
|
|
(let* ((display (window-display window))
|
|
(Xpixmap (%create-bitmap-from-data (display-Xdisplay display)
|
|
(window-Xwindow window)
|
|
data width height)))
|
|
(make-pixmap Xpixmap display #t)))
|
|
|
|
(import-lambda-definition %create-bitmap-from-data (Xdisplay Xdrawable data w h)
|
|
"scx_Create_Bitmap_From_Data")
|
|
|
|
;; create-pixmap-from-bitmap-data creates a pixmap of the given depth
|
|
;; and then does a bitmap-format XPutImage of the data into it. See
|
|
;; XCreatePixmapFromBitmapData.
|
|
|
|
(define (create-pixmap-from-bitmap-data window data width height
|
|
foregrnd backgrnd depth)
|
|
(let* ((display (window-display window))
|
|
(pixmap (create-pixmap-from-bitmap-data (display-Xdisplay display)
|
|
(window-Xwindow window)
|
|
data width height foregrnd
|
|
backgrnd depth)))
|
|
(make-pixmap pixmap display #t)))
|
|
|
|
|
|
(import-lambda-definition %create-pixmap-from-bitmap-data
|
|
(Xdisplay Xdrawabel data w h f b depth)
|
|
"scx_Create_Pixmap_From_Bitmap_Data")
|
|
|
|
;; read-bitmap-file reads the bitmap data from the file, creates a new
|
|
;; pixmap and returns a list of five elements (pixmap width heigth
|
|
;; x-hot y-hot). if x-hot and y-hot are not defined in the file then
|
|
;; they are set to -1,-1. See XReadBitmapFile;
|
|
|
|
(define (read-bitmap-file drawable filename)
|
|
(let ((res (%read-bitmap-file (display-Xdisplay (drawable-display drawable))
|
|
(drawable-Xobject drawable)
|
|
filename)))
|
|
(if (pair? res)
|
|
(set-car! res (make-pixmap (car res) (drawable-display drawable) #t))
|
|
(bitmap-error res filename))))
|
|
|
|
(define (bitmap-error i data)
|
|
(case i
|
|
((0) #t) ;; no error
|
|
((1) (error "could not open file" data))
|
|
((2) (error "invalid bitmap data in file" data))
|
|
((3) (error "not enough memory to create bitmap" data))))
|
|
|
|
(import-lambda-definition %read-bitmap-file (Xdisplay Xdrawable file)
|
|
"scx_Read_Bitmap_File")
|
|
|
|
;; write-bitmap-file writes a bitmap out to a file in the X Version 11
|
|
;; format. The optional argument hotspot specifies the hotspot as a
|
|
;; pair (x-hot . y-hot) which defaults to (-1 . -1). See
|
|
;; XWriteBitmapFile.
|
|
|
|
(define (write-bitmap-file filename pixmap width height . hotspot)
|
|
(let ((dpy (display-Xdisplay (pixmap-display pixmap)))
|
|
(xy-hot (cond
|
|
((null? hotspot) (cons -1 -1))
|
|
(else (car hotspot)))))
|
|
(bitmap-error
|
|
(%write-bitmap-file dpy filename (pixmap-Xpixmap pixmap) width height
|
|
(car xy-hot) (cdr xy-hot))
|
|
filename)))
|
|
|
|
(import-lambda-definition %write-bitmap-file (Xdisplay file Xpixmap w h x y)
|
|
"scx_Write_Bitmap_File")
|