comparison src/glyphs-x.c @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents 6240c7796c7a
children bbff43aa5eb7
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
120 Visual *vis; 120 Visual *vis;
121 XImage *outimg; 121 XImage *outimg;
122 int depth, bitmap_pad, byte_cnt, i, j; 122 int depth, bitmap_pad, byte_cnt, i, j;
123 int rd,gr,bl,q; 123 int rd,gr,bl,q;
124 unsigned char *data, *ip, *dp; 124 unsigned char *data, *ip, *dp;
125 quant_table *qtable; 125 quant_table *qtable = 0;
126 union { 126 union {
127 FOUR_BYTE_TYPE val; 127 FOUR_BYTE_TYPE val;
128 char cp[4]; 128 char cp[4];
129 } conv; 129 } conv;
130 130
143 143
144 bitmap_pad = ((depth > 16) ? 32 : 144 bitmap_pad = ((depth > 16) ? 32 :
145 (depth > 8) ? 16 : 145 (depth > 8) ? 16 :
146 8); 146 8);
147 byte_cnt = bitmap_pad >> 3; 147 byte_cnt = bitmap_pad >> 3;
148 148
149 outimg = XCreateImage (dpy, vis, 149 outimg = XCreateImage (dpy, vis,
150 depth, ZPixmap, 0, 0, width, height, 150 depth, ZPixmap, 0, 0, width, height,
151 bitmap_pad, 0); 151 bitmap_pad, 0);
152 if (!outimg) return NULL; 152 if (!outimg) return NULL;
153 153
156 { 156 {
157 XDestroyImage (outimg); 157 XDestroyImage (outimg);
158 return NULL; 158 return NULL;
159 } 159 }
160 outimg->data = (char *) data; 160 outimg->data = (char *) data;
161 161
162 if (vis->class == PseudoColor) 162 if (vis->class == PseudoColor)
163 { 163 {
164 unsigned long pixarray[256]; 164 unsigned long pixarray[256];
165 int pixcount, n; 165 int pixcount, n;
166 /* use our quantize table to allocate the colors */ 166 /* use our quantize table to allocate the colors */
172 n = *npixels; 172 n = *npixels;
173 for (i = 0; i < qtable->num_active_colors; i++) 173 for (i = 0; i < qtable->num_active_colors; i++)
174 { 174 {
175 XColor color; 175 XColor color;
176 int res; 176 int res;
177 177
178 color.red = qtable->rm[i] ? qtable->rm[i] << 8 : 0; 178 color.red = qtable->rm[i] ? qtable->rm[i] << 8 : 0;
179 color.green = qtable->gm[i] ? qtable->gm[i] << 8 : 0; 179 color.green = qtable->gm[i] ? qtable->gm[i] << 8 : 0;
180 color.blue = qtable->bm[i] ? qtable->bm[i] << 8 : 0; 180 color.blue = qtable->bm[i] ? qtable->bm[i] << 8 : 0;
181 color.flags = DoRed | DoGreen | DoBlue; 181 color.flags = DoRed | DoGreen | DoBlue;
182 res = allocate_nearest_color (dpy, cmap, vis, &color); 182 res = allocate_nearest_color (dpy, cmap, vis, &color);
285 else 285 else
286 for (q = 0; q < byte_cnt; q++) *dp++ = conv.cp[q]; 286 for (q = 0; q < byte_cnt; q++) *dp++ = conv.cp[q];
287 #endif 287 #endif
288 } 288 }
289 } 289 }
290 } 290 }
291 return outimg; 291 return outimg;
292 } 292 }
293 293
294 294
295 295
467 else 467 else
468 return Qnil; 468 return Qnil;
469 } 469 }
470 470
471 if (NILP (Vdefault_x_device)) 471 if (NILP (Vdefault_x_device))
472 /* This may occur during intialization. */ 472 /* This may occur during initialization. */
473 return Qnil; 473 return Qnil;
474 else 474 else
475 /* We only check the bitmapFilePath resource on the original X device. */ 475 /* We only check the bitmapFilePath resource on the original X device. */
476 display = DEVICE_X_DISPLAY (XDEVICE (Vdefault_x_device)); 476 display = DEVICE_X_DISPLAY (XDEVICE (Vdefault_x_device));
477 477
607 break; 607 break;
608 } 608 }
609 /* reset the dynarr */ 609 /* reset the dynarr */
610 Lstream_rewind(ostr); 610 Lstream_rewind(ostr);
611 } 611 }
612 612
613 if (fclose (tmpfil) != 0) 613 if (fclose (tmpfil) != 0)
614 fubar = 1; 614 fubar = 1;
615 Lstream_close (istr); 615 Lstream_close (istr);
616 #ifdef FILE_CODING 616 #ifdef FILE_CODING
617 Lstream_close (costr); 617 Lstream_close (costr);
789 } 789 }
790 790
791 static void 791 static void
792 x_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii, 792 x_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
793 int width, int height, 793 int width, int height,
794 unsigned char *eimage, 794 unsigned char *eimage,
795 int dest_mask, 795 int dest_mask,
796 Lisp_Object instantiator, 796 Lisp_Object instantiator,
797 Lisp_Object domain) 797 Lisp_Object domain)
798 { 798 {
799 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 799 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
800 Colormap cmap = DEVICE_X_COLORMAP (XDEVICE(device)); 800 Colormap cmap = DEVICE_X_COLORMAP (XDEVICE(device));
801 unsigned long *pixtbl = NULL; 801 unsigned long *pixtbl = NULL;
802 int npixels = 0; 802 int npixels = 0;
803 XImage* ximage; 803 XImage* ximage;
804 804
805 ximage = convert_EImage_to_XImage (device, width, height, eimage, 805 ximage = convert_EImage_to_XImage (device, width, height, eimage,
806 &pixtbl, &npixels); 806 &pixtbl, &npixels);
807 if (!ximage) 807 if (!ximage)
808 { 808 {
809 if (pixtbl) xfree (pixtbl); 809 if (pixtbl) xfree (pixtbl);
810 signal_image_error("EImage to XImage conversion failed", instantiator); 810 signal_image_error("EImage to XImage conversion failed", instantiator);
811 } 811 }
812 812
813 /* Now create the pixmap and set up the image instance */ 813 /* Now create the pixmap and set up the image instance */
814 init_image_instance_from_x_image (ii, ximage, dest_mask, 814 init_image_instance_from_x_image (ii, ximage, dest_mask,
815 cmap, pixtbl, npixels, 815 cmap, pixtbl, npixels,
816 instantiator); 816 instantiator);
817 817
824 } 824 }
825 XDestroyImage (ximage); 825 XDestroyImage (ximage);
826 } 826 }
827 } 827 }
828 828
829 int read_bitmap_data_from_file (CONST char *filename, unsigned int *width, 829 int read_bitmap_data_from_file (CONST char *filename, unsigned int *width,
830 unsigned int *height, unsigned char **datap, 830 unsigned int *height, unsigned char **datap,
831 int *x_hot, int *y_hot) 831 int *x_hot, int *y_hot)
832 { 832 {
833 return XmuReadBitmapDataFromFile (filename, width, height, 833 return XmuReadBitmapDataFromFile (filename, width, height,
834 datap, x_hot, y_hot); 834 datap, x_hot, y_hot);
835 } 835 }
836 836
837 /* Given inline data for a mono pixmap, create and return the 837 /* Given inline data for a mono pixmap, create and return the
838 corresponding X object. */ 838 corresponding X object. */
1491 } 1491 }
1492 1492
1493 static Lisp_Object 1493 static Lisp_Object
1494 xface_normalize (Lisp_Object inst, Lisp_Object console_type) 1494 xface_normalize (Lisp_Object inst, Lisp_Object console_type)
1495 { 1495 {
1496 /* This funcation can call lisp */ 1496 /* This function can call lisp */
1497 Lisp_Object file = Qnil, mask_file = Qnil; 1497 Lisp_Object file = Qnil, mask_file = Qnil;
1498 struct gcpro gcpro1, gcpro2, gcpro3; 1498 struct gcpro gcpro1, gcpro2, gcpro3;
1499 Lisp_Object alist = Qnil; 1499 Lisp_Object alist = Qnil;
1500 1500
1501 GCPRO3 (file, mask_file, alist); 1501 GCPRO3 (file, mask_file, alist);
2083 } 2083 }
2084 } 2084 }
2085 2085
2086 /* subwindows are equal iff they have the same window XID */ 2086 /* subwindows are equal iff they have the same window XID */
2087 static int 2087 static int
2088 subwindow_equal (Lisp_Object o1, Lisp_Object o2, int depth) 2088 subwindow_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
2089 { 2089 {
2090 return (XSUBWINDOW (o1)->subwindow == XSUBWINDOW (o2)->subwindow); 2090 return (XSUBWINDOW (obj1)->subwindow == XSUBWINDOW (obj2)->subwindow);
2091 } 2091 }
2092 2092
2093 static unsigned long 2093 static unsigned long
2094 subwindow_hash (Lisp_Object obj, int depth) 2094 subwindow_hash (Lisp_Object obj, int depth)
2095 { 2095 {