pixmap.scm 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ;; Copyright (c) 2001-2003 by Norbert Frese, David Frese
  2. ;; *** create or destroy pixmaps *************************************
  3. (import-xlib-function create-pixmap (display drawable width height depth)
  4. "scx_Create_Pixmap")
  5. (import-xlib-function free-pixmap (display pixmap)
  6. "scx_Free_Pixmap")
  7. ;; *** manipulate bitmaps ********************************************
  8. (define (bitmap-error i data) ;; TODO exceptions ?!
  9. (case i
  10. ((0) #t) ;; no error
  11. ((1) (error "could not open file" data))
  12. ((2) (error "invalid bitmap data in file" data))
  13. ((3) (error "not enough memory to create bitmap" data))))
  14. (import-xlib-function %read-bitmap-file (display drawable filename)
  15. "scx_Read_Bitmap_File")
  16. ;; returns a list (pixmap width height x-hot y-hot). May raise an error.
  17. (define (read-bitmap-file display drawable filename)
  18. (let ((res (%read-bitmap-file display drawable filename)))
  19. (if (number? res)
  20. (bitmap-error res filename)
  21. res)))
  22. (import-xlib-function %write-bitmap-file
  23. (display filename bitmap width height x-hot y-hot)
  24. "scx_Write_Bitmap_File")
  25. (define (write-bitmap-file display filename bitmap width height x-hot y-hot)
  26. (bitmap-error (%write-bitmap-file display filename bitmap width height
  27. x-hot y-hot)
  28. filename))
  29. ;; create-bitmap-from-data creates a new pixmap, consisting of the
  30. ;; image found in data, which has to be a string. Such an image can be
  31. ;; generated with write-bitmap-file. See XCreateBitmapFromData.
  32. (import-xlib-function create-bitmap-from-data (display drawable data w h)
  33. "scx_Create_Bitmap_From_Data")
  34. ;; create-pixmap-from-bitmap-data creates a pixmap of the given depth
  35. ;; and then does a bitmap-format XPutImage of the data into it. See
  36. ;; XCreatePixmapFromBitmapData.
  37. (import-xlib-function create-pixmap-from-bitmap-data
  38. (display drawable data width height foreground background depth)
  39. "scx_Create_Pixmap_From_Bitmap_Data")