Lisp HUG Maillist Archive

swoopy buttons under LWW

I want to create swoopy looking buttons (i.e. images of "glassy" buttons), but 
"something" is going wrong and I'm ignorant of all of the issues that go into 
creating such buttons under Windows (e.g. restrictions on images used for 
buttons, etc).

Does someone know how to do this and can point me in the right direction?  
Pointers to reading would be fine, e.g. should I read the DIB section in 
Petzhold?  I just don't know where to start.

If I try to specify a transparent color index, I get an error deep in the 
bowels of capi.


In detail, here is what I am doing:

a) create an image in InkScape, saved as .PNG

b) load the image into IrfanView and re-save it as a .BMP

c) use the following snippet of code that I found in one of the capi examples:

(defun slurp-image (file)
  (let ((external-image (gp:read-external-image file)))
    (gp:compress-external-image external-image)
    (setf (gp:external-image-transparent-color-index external-image) 0)
    (make-load-form external-image)))

d) cut/paste the result into the following code (I have elided the 9,954 items 
in the vector)

(defparameter *button*
  (MAKE-INSTANCE (QUOTE GRAPHICS-PORTS:EXTERNAL-IMAGE) :DATA (GRAPHICS-
PORTS::MAKE-DIB-ARRAY 9954 :INITIAL-CONTENTS #(...)) :TRANSPARENT-COLOR-INDEX 
0 :TYPE :BMP :REAL-DATA T))

(defun try ()
  (capi:contain
   (make-instance 'capi:push-button
                  :image *button*)))

e) Run it and get the error:

"NIL is not of type ARRAY" in method gp::%convert-dib ...

f) If I remove all of the "make-dib-array ... :TRANSPARENT-COLOR-INDEX 0 :TYPE 
:BMP :REAL-DATA T", and simply use the vector as the :data, I get the image of 
the button, but no part of it is transparent.

tia
pt


Re: swoopy buttons under LWW

On Thursday 30 October 2008 11:00:33 Paul Tarvydas wrote:

I may have answered my own question - the docs for gp:read-external-image 
state that transparency only works for images with color maps (<= 256 colors).  
IrfanView has a "decrease color depth" option which produces a dib that seems 
to work with the test I posted.

pt


Updated at: 2020-12-10 08:41 UTC