Re: problem with pixmaps

From: Erick Gallesio <eg_at_unice.fr>
Date: Wed, 24 Mar 1999 15:52:35 +0100 (CET)

Brian Denheyer writes:
>
> I keep getting the following error :
>
>
> *** Error at line 39 of file ./aegea.scm:
> must specify :data or :file
>
> Here is the code
>
> :image (make <Pixmap-image> :file "./bitmaps/rectangle.xpm")
>
> Bitmaps, i.e.
>
> :image (make <Bitmap-image> :file "./bitmaps/rectangle.xbm")
>
> works fine
>
> ???

In fact, if you use an image with minimal manipulation (that is if you
just use :file option and don't use tricky option such as gamma
correction), you better use the <Image> class. This class find the
type of the correct image so you don't have to bother if it is a
bitmap, a GIF file or a pixmap. Furthermore, when you use this class,
there is caching so that if you load at several places the same image
(for instance the bullets of an HTML page), all the instance will
share the same image internal representation.

Anyway, my code was incorrect because the pixmap extension don't use
the same conventions as the core Tk images. The following patch should
correct this problem.

                -- Erick



Index: 3.99.5.3/STklos/Tk/Image.stklos
*** 3.99.5.3/STklos/Tk/Image.stklos Sun, 22 Mar 1998 17:16:09 +0100 eg (STk/W/38_Image.stkl 1.4 644)
--- 3.99.5.3(w)/STklos/Tk/Image.stklos Wed, 24 Mar 1999 15:38:04 +0100 eg (STk/W/38_Image.stkl 1.4 644)
***************
*** 1,7 ****
  ;;;;
  ;;;; I m a g e . s t k l o s -- The Tk4.0 image mechanism
  ;;;;
! ;;;; Copyright 1993-1998 Erick Gallesio - I3S-CNRS/ESSI <eg_at_unice.fr>
  ;;;;
  ;;;; Permission to use, copy, and/or distribute this software and its
  ;;;; documentation for any purpose and without fee is hereby granted, provided
--- 1,7 ----
  ;;;;
  ;;;; I m a g e . s t k l o s -- The Tk4.0 image mechanism
  ;;;;
! ;;;; Copyright 1993-1999 Erick Gallesio - I3S-CNRS/ESSI <eg_at_unice.fr>
  ;;;;
  ;;;; Permission to use, copy, and/or distribute this software and its
  ;;;; documentation for any purpose and without fee is hereby granted, provided
***************
*** 13,19 ****
  ;;;;
  ;;;; Author: Erick Gallesio [eg_at_unice.fr]
  ;;;; Creation date: 26-Jul-1995 11:23
! ;;;; Last file update: 21-Mar-1998 22:38
  
  (require "Basics")
  (require "image") ; The one with a lower "i"
--- 13,19 ----
  ;;;;
  ;;;; Author: Erick Gallesio [eg_at_unice.fr]
  ;;;; Creation date: 26-Jul-1995 11:23
! ;;;; Last file update: 24-Mar-1999 15:38
  
  (require "Basics")
  (require "image") ; The one with a lower "i"
***************
*** 94,100 ****
  ;;; Destroy
  ;;;
  (define-method destroy ((self <Image>))
! (delete-image (slo-ref self 'Id)))
  
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--- 94,100 ----
  ;;; Destroy
  ;;;
  (define-method destroy ((self <Image>))
! (delete-image (slot-ref self 'Id)))
  
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
***************
*** 187,196 ****
  (define-class <Pixmap-image> (<Tk-Basic-Image>)
    ())
  
  
! (define-method initialize-image((self <Pixmap-image>) args)
    (require "pixmap")
! (apply image 'create 'pixmap (gensym "Img ") args))
  
  
  (provide "Image")
--- 187,204 ----
  (define-class <Pixmap-image> (<Tk-Basic-Image>)
    ())
  
+ ;; Pixmap extension need that the :file or :data be passed when the
+ ;; image is created => we use a new initialize method rather than the
+ ;; initialize-image scheme used for bitmaps and photos
  
! (define-method initialize ((self <Pixmap-Image>) initargs)
    (require "pixmap")
! (let* ((file (get-keyword :file initargs #f))
! (data (get-keyword :data initargs #f))
! (args (if data
! (list :data data)
! (list :file file))))
! (slot-set! self 'id (apply image 'create 'pixmap (gensym "Img ") args))))
  
  
  (provide "Image")


Received on Wed Mar 24 1999 - 16:32:34 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST