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)
|
2001-07-30 10:43:22 -04:00
|
|
|
(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)
|
2001-07-31 10:54:53 -04:00
|
|
|
"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)
|
2001-07-30 10:43:22 -04:00
|
|
|
(let* ((display (window-display window))
|
|
|
|
(Xpixmap (%create-bitmap-from-data (display-Xdisplay display)
|
|
|
|
(window-Xwindow window)
|
|
|
|
data width height)))
|
2001-07-19 11:19:07 -04:00
|
|
|
(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)
|
2001-07-31 10:54:53 -04:00
|
|
|
"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
|
|
|
|
2001-10-30 09:31:36 -05:00
|
|
|
(define (create-pixmap-from-bitmap-data window data width height
|
2001-07-16 09:53:08 -04:00
|
|
|
foregrnd backgrnd depth)
|
2001-07-30 10:43:22 -04:00
|
|
|
(let* ((display (window-display window))
|
|
|
|
(pixmap (create-pixmap-from-bitmap-data (display-Xdisplay display)
|
|
|
|
(window-Xwindow window)
|
2001-10-30 09:31:36 -05:00
|
|
|
data width height foregrnd
|
|
|
|
backgrnd depth)))
|
2001-07-19 11:19:07 -04:00
|
|
|
(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)
|
2001-07-31 10:54:53 -04:00
|
|
|
"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
|
2001-10-30 09:31:36 -05:00
|
|
|
;; pixmap and returns a list of five elements (pixmap width heigth
|
2001-10-09 11:32:54 -04:00
|
|
|
;; 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)
|
2001-07-31 10:54:53 -04:00
|
|
|
"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)))))
|
2001-10-30 09:31:36 -05:00
|
|
|
(%write-bitmap-file dpy filename pixmap width 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")
|