scx/scheme/xlib/pixmap.scm

80 lines
2.9 KiB
Scheme
Raw Normal View History

2001-07-16 09:53:08 -04:00
;; author -> Norbert Freudemann
;; creation date : 16/07/2001
;; last change : 16/07/2001
2001-10-09 11:32:54 -04:00
;; create a new pixmap.
2001-07-16 09:53:08 -04:00
(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)))
2001-07-16 09:53:08 -04:00
(import-lambda-definition %create-pixmap (Xdisplay Xdrawable w h depth)
"scx_Create_Pixmap")
2001-07-16 09:53:08 -04:00
2001-10-09 11:32:54 -04:00
;; 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.
2001-07-16 09:53:08 -04:00
(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)))
2001-07-16 09:53:08 -04:00
2001-07-18 11:45:54 -04:00
(import-lambda-definition %create-bitmap-from-data (Xdisplay Xdrawable data w h)
"scx_Create_Bitmap_From_Data")
2001-07-16 09:53:08 -04:00
2001-10-09 11:32:54 -04:00
;; 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.
2001-07-16 09:53:08 -04:00
(define (create-pixmap-from-bitmap-data win data widht height
foregrnd backgrnd depth)
(let* ((display (window-display window))
(pixmap (create-pixmap-from-bitmap-data (display-Xdisplay display)
(window-Xwindow window)
data widht height foregrnd
backgrd depth)))
(make-pixmap pixmap display #t)))
2001-07-16 09:53:08 -04:00
(import-lambda-definition %create-pixmap-from-bitmap-data
(Xdisplay Xdrawabel data w h f b depth)
"scx_Create_Pixmap_From_Bitmap_Data")
2001-07-16 09:53:08 -04:00
2001-10-09 11:32:54 -04:00
;; read-bitmap-file reads the bitmap data from the file, creates a new
;; pixmap and returns a list of five elements (pixmap widht 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;
2001-07-16 09:53:08 -04:00
(define (read-bitmap-file drawable filename)
(let ((res (%read-bitmap-file (display-Xdisplay (drawable-display drawable))
(drawable-Xobject drawable)
filename)))
2001-08-21 10:57:08 -04:00
(if (pair? res)
(set-car! res (make-pixmap (car res) (drawable-display drawable) #t))
res)))
2001-07-16 09:53:08 -04:00
(import-lambda-definition %read-bitmap-file (Xdisplay Xdrawable file)
"scx_Read_Bitmap_File")
2001-07-16 09:53:08 -04:00
2001-10-09 11:32:54 -04:00
;; 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.
2001-07-16 09:53:08 -04:00
2001-10-09 11:32:54 -04:00
(define (write-bitmap-file filename pixmap width height . hotspot)
2001-07-16 09:53:08 -04:00
(let ((dpy (display-Xdisplay (pixmap-display pixmap)))
(xy-hot (cond
2001-10-09 11:32:54 -04:00
((null? hotspot) (cons -1 -1))
(else (car hotspot)))))
(%write-bitmap-file dpy filename pixmap widht height
2001-10-09 11:32:54 -04:00
(car xy-hot) (cdr xy-hot))))
2001-07-16 09:53:08 -04:00
(import-lambda-definition %write-bitmap-file (Xdisplay file Xpixmap w h x y)
2001-10-09 11:32:54 -04:00
"scx_Write_Bitmap_File")