[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need help with image/pixmap problem



HELP.  I am having a problem with images and pixmaps.  I must be doing
something wrong.  CLX keeps wanting to pad my image with zero words, and
I don't know why.  What happens is that I make an image from a C Bitmap
file (works fine in C).  If I use read-bitmap-from-file, my image (in
this case all 1's) becomes padded with two bytes of 0's every other 2
bytes.

If I use a different form with create-image, everything looks innocent
until I put-image the image in the pixmap.  Then the zero word padding
starts again.

Sure looks funny on the screen.   Anyone got a clue???

Below is the example.  I'm running CLX on a TI Explorer, using
a Vaxstation 2000 as the Xserver and display (X11 R3).


John Brolio
Brolio@cs.umass.edu
GBB Development Group

(413) 545-3279


----------- The C bitmap file --------------------------
#define horiz_width 16
#define horiz_height 16
#define horiz_x_hot 7
#define horiz_y_hot 8
static char horiz_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
	
---------------------------------------------------------
The Code

(setf pix (read-bitmap-from-file "horiz.c"))

'#S(IMAGE-X :WIDTH 16 :HEIGHT 16 :PLIST (:NAME :HORIZ :Y_HOT 8 :X_HOT 7 :HEIGHT 16 :WIDTH 16)
	:FORMAT :XY-PIXMAP :BYTES-PER-LINE 4 :BIT-LSB-FIRST-P T
	:DATA #(255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0
	255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255
	0 0 255 255 0 0 255 255 0 0 255 255 0 0))

;;; -----------------------------------------------------------------
;; NOTE THAT THERE ARE LINES OF ZEROES EVERY TWO BYTES NOW.
;;; -----------------------------------------------------------------

(setf map (create-pixmap :width 16 :height 16 :depth 1 :drawable *root*))


(put-image map gc pix :x 0 :y 0 :width 16 :height 16 :bitmap-p t)

'#S(IMAGE-X :WIDTH 16 :HEIGHT 16 :PLIST (:NAME :HORIZ :Y_HOT 8 :X_HOT 7 :HEIGHT 16 :WIDTH 16)
	:FORMAT :XY-PIXMAP :BYTES-PER-LINE 4 :BIT-LSB-FIRST-P T :BYTE-LSB-FIRST-P T
	:DATA #(0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255
	0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0
	255 255 0 0 255 255 0 0 255 255 0 0 255 255))

;;; -----------------------------------------------------------------
;; NOTE THAT THE ORDER HAS BEEN ROTATED TWO BYTES
;;; -----------------------------------------------------------------

****** another version
;;; THE FILE

(defconstant %horiz-width% 16)
(defconstant %horiz-height% 16)
(defconstant %horiz-x-hot% 7)
(defconstant %horiz-y-hot% 8)
(defconstant %horiz-bits% #(
   #xff #xff #xff #xff #xff #xff #xff #xff #xff #xff #xff #xff 
   #xff #xff #xff #xff #xff #xff #xff #xff #xff #xff #xff #xff 
   #xff #xff #xff #xff #xff #xff #xff #xff ))

;;; =================================================================

(setf im (xlib::create-image :depth 1 :data %horiz-bits%
				 :x-hot  %horiz-x-hot% :y-hot  %horiz-y-hot%
				 :width %horiz-width% :height %horiz-height%))


#S(XLIB:IMAGE-X :WIDTH 16 :HEIGHT 16 :PLIST (:Y_HOT 8 :X_HOT 7) :FORMAT :XY-PIXMAP
		:BYTES-PER-LINE 2
		:DATA #(255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
			    255 255 255 255 255 255 255 255 255 255 255 255 255 255 255))

(put-image map gc pix :x 0 :y 0 :width 16 :height 16 :bitmap-p t)

#S(XLIB:IMAGE-X :WIDTH 16 :HEIGHT 16 :PLIST (:Y_HOT 8 :X_HOT 7) :FORMAT :XY-PIXMAP
		:BYTES-PER-LINE 2 :BIT-LSB-FIRST-P T :BYTE-LSB-FIRST-P T
		:DATA #(0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0
			  255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255
			  0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255))


;;; -----------------------------------------------------------------
;;; NOTE THAT "PUTTING" THE IMAGE ADDS THE TWO BYTES OF ZEROES.
;;; -----------------------------------------------------------------