annotate src/glyphs-msw.c @ 267:966663fcf606 r20-5b32

Import from CVS: tag r20-5b32
author cvs
date Mon, 13 Aug 2007 10:26:29 +0200
parents
children b2472a1930f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1 /* mswindows-specific Lisp objects.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
2 Copyright (C) 1998 Free Software Foundation, Inc.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
3
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
4 This file is part of XEmacs.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
5
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
9 later version.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
10
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
14 for more details.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
15
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
20
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
22
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
23 /* written by Andy Piper <andyp@parallax.co.uk> plagerising buts from
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
24 glyphs-x.c */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
25
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
26 #include <config.h>
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
27 #include "lisp.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
28 #include "lstream.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
29 #include "console-msw.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
30 #include "glyphs-msw.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
31 #include "objects-msw.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
32
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
33 #include "buffer.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
34 #include "frame.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
35 #include "insdel.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
36 #include "opaque.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
37 #include "sysfile.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
38 #include "faces.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
39 #include "imgproc.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
40
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
41 #ifdef HAVE_XPM
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
42 #include <X11/xpm.h>
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
43 #endif
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
44
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
45 #ifdef FILE_CODING
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
46 #include "file-coding.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
47 #endif
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
48
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
49 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
50 Lisp_Object Qbmp;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
51 Lisp_Object Vmswindows_bitmap_file_path;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
52
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
53 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
54 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
55 enum image_instance_type type);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
56
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
57 COLORREF mswindows_string_to_color(CONST char *name);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
58
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
59 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
60 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
61 /* proper display */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
62 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
63 BITMAPINFO* EImage2DIBitmap(Lisp_Object device, int width, int height,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
64 unsigned char *pic,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
65 int *bit_count,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
66 unsigned char** bmp_data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
67 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
68 struct device *d = XDEVICE (device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
69 int i;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
70 RGBQUAD* colortbl;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
71 int ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
72 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
73
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
74 if (DEVICE_MSWINDOWS_BITSPIXEL(d) > 16)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
75 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
76 /* FIXME: we can do this because 24bpp implies no colour table, once
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
77 * we start paletizing this is no longer true. The X versions of
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
78 * this function quantises to 256 colours or bit masks down to a
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
79 * long. Windows can actually handle rgb triples in the raw so I
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
80 * don't see much point trying to optimise down to the best
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
81 * structure - unless it has memory / color allocation implications
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
82 * .... */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
83 bmp_info=xnew_and_zero(BITMAPINFO);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
84
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
85 if (!bmp_info)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
86 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
87 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
88 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
89
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
90 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
91 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
92 bmp_info->bmiHeader.biSizeImage=width*height*3;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
93
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
94 /* bitmap data needs to be in blue, green, red triples - in that
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
95 order, eimage is in RGB format so we need to convert */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
96 *bmp_data = xnew_array_and_zero (unsigned char, width * height * 3);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
97 *bit_count = width * height * 3;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
98
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
99 if (!bmp_data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
100 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
101 xfree(bmp_info);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
102 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
103 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
104 for (i=0; i<width*height; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
105 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
106 (*bmp_data)[2]=*pic;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
107 (*bmp_data)[1]= pic[1];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
108 **bmp_data = pic[2];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
109 (*bmp_data) += 3;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
110 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
111 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
112 else /* scale to 256 colors */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
113 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
114 int rd,gr,bl, j;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
115 unsigned char *ip, *dp;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
116 quant_table *qtable;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
117 int bpline= (int)(~3UL & (unsigned long)(width +3));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
118 /* Quantize the image and get a histogram while we're at it.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
119 Do this first to save memory */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
120 qtable = EImage_build_quantable(pic, width, height, 256);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
121 if (qtable == NULL) return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
122
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
123 /* use our quantize table to allocate the colors */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
124 ncolors = qtable->num_active_colors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
125 bmp_info=(BITMAPINFO*)xmalloc_and_zero(sizeof(BITMAPINFOHEADER) +
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
126 sizeof(RGBQUAD) * ncolors);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
127 if (!bmp_info)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
128 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
129 xfree(qtable);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
130 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
131 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
132
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
133 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
134
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
135 bmp_info->bmiHeader.biBitCount=8;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
136 bmp_info->bmiHeader.biCompression=BI_RGB;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
137 bmp_info->bmiHeader.biSizeImage=bpline*height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
138 bmp_info->bmiHeader.biClrUsed=ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
139 bmp_info->bmiHeader.biClrImportant=ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
140
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
141 *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
142 *bit_count = bpline * height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
143
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
144 if (!*bmp_data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
145 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
146 xfree(qtable);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
147 xfree(bmp_info);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
148 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
149 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
150
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
151 /* build up an RGBQUAD colortable */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
152 for (i = 0; i < qtable->num_active_colors; i++) {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
153 colortbl[i].rgbRed = qtable->rm[i];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
154 colortbl[i].rgbGreen = qtable->gm[i];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
155 colortbl[i].rgbBlue = qtable->bm[i];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
156 colortbl[i].rgbReserved = 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
157 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
158
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
159 /* now build up the data. picture has to be upside-down and
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
160 back-to-front for msw bitmaps */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
161 ip = pic;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
162 for (i = height-1; i >= 0; i--) {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
163 dp = (*bmp_data) + (i * bpline);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
164 for (j = 0; j < width; j++) {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
165 rd = *ip++;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
166 gr = *ip++;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
167 bl = *ip++;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
168 *dp++ = QUANT_GET_COLOR(qtable,rd,gr,bl);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
169 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
170 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
171 xfree(qtable);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
172 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
173 /* fix up the standard stuff */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
174 bmp_info->bmiHeader.biWidth=width;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
175 bmp_info->bmiHeader.biHeight=height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
176 bmp_info->bmiHeader.biPlanes=1;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
177 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
178 bmp_info->bmiHeader.biXPelsPerMeter=3779; /* unless you know better */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
179 bmp_info->bmiHeader.biYPelsPerMeter=3779;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
180
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
181 return bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
182 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
183
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
184 /* Given a pixmap filename, look through all of the "standard" places
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
185 where the file might be located. Return a full pathname if found;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
186 otherwise, return Qnil. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
187
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
188 static Lisp_Object
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
189 locate_pixmap_file (Lisp_Object name)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
190 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
191 /* This function can GC if IN_REDISPLAY is false */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
192
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
193 /* Check non-absolute pathnames with a directory component relative to
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
194 the search path; that's the way Xt does it. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
195 /* #### Unix-specific */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
196 if (XSTRING_BYTE (name, 0) == '/' ||
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
197 (XSTRING_BYTE (name, 0) == '.' &&
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
198 (XSTRING_BYTE (name, 1) == '/' ||
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
199 (XSTRING_BYTE (name, 1) == '.' &&
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
200 (XSTRING_BYTE (name, 2) == '/')))))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
201 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
202 if (!NILP (Ffile_readable_p (name)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
203 return name;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
204 else
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
205 return Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
206 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
207
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
208 if (!NILP(Vmswindows_bitmap_file_path))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
209 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
210 Lisp_Object found;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
211 if (locate_file (Vmswindows_bitmap_file_path, name, "", &found, R_OK) < 0)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
212 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
213 Lisp_Object temp = list1 (Vdata_directory);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
214 struct gcpro gcpro1;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
215
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
216 GCPRO1 (temp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
217 locate_file (temp, name, "", &found, R_OK);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
218 UNGCPRO;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
219 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
220
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
221 return found;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
222 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
223 else
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
224 return Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
225 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
226
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
227 /* If INSTANTIATOR refers to inline data, return Qnil.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
228 If INSTANTIATOR refers to data in a file, return the full filename
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
229 if it exists; otherwise, return a cons of (filename).
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
230
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
231 FILE_KEYWORD and DATA_KEYWORD are symbols specifying the
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
232 keywords used to look up the file and inline data,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
233 respectively, in the instantiator. Normally these would
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
234 be Q_file and Q_data, but might be different for mask data. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
235
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
236 static Lisp_Object
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
237 potential_pixmap_file_instantiator (Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
238 Lisp_Object file_keyword,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
239 Lisp_Object data_keyword)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
240 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
241 Lisp_Object file;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
242 Lisp_Object data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
243
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
244 assert (VECTORP (instantiator));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
245
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
246 data = find_keyword_in_vector (instantiator, data_keyword);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
247 file = find_keyword_in_vector (instantiator, file_keyword);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
248
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
249 if (!NILP (file) && NILP (data))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
250 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
251 Lisp_Object retval = locate_pixmap_file (file);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
252 if (!NILP (retval))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
253 return retval;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
254 else
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
255 return Fcons (file, Qnil); /* should have been file */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
256 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
257
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
258 return Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
259 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
260
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
261 static Lisp_Object
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
262 simple_image_type_normalize (Lisp_Object inst, Lisp_Object console_type,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
263 Lisp_Object image_type_tag)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
264 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
265 /* This function can call lisp */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
266 Lisp_Object file = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
267 struct gcpro gcpro1, gcpro2;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
268 Lisp_Object alist = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
269
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
270 GCPRO2 (file, alist);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
271
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
272 /* Now, convert any file data into inline data. At the end of this,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
273 `data' will contain the inline data (if any) or Qnil, and `file'
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
274 will contain the name this data was derived from (if known) or
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
275 Qnil.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
276
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
277 Note that if we cannot generate any regular inline data, we
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
278 skip out. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
279
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
280 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
281
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
282 if (CONSP (file)) /* failure locating filename */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
283 signal_double_file_error ("Opening pixmap file",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
284 "no such file or directory",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
285 Fcar (file));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
286
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
287 if (NILP (file)) /* no conversion necessary */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
288 RETURN_UNGCPRO (inst);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
289
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
290 alist = tagged_vector_to_alist (inst);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
291
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
292 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
293 Lisp_Object data = make_string_from_file (file);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
294 alist = remassq_no_quit (Q_file, alist);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
295 /* there can't be a :data at this point. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
296 alist = Fcons (Fcons (Q_file, file),
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
297 Fcons (Fcons (Q_data, data), alist));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
298 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
299
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
300 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
301 Lisp_Object result = alist_to_tagged_vector (image_type_tag, alist);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
302 free_alist (alist);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
303 RETURN_UNGCPRO (result);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
304 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
305 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
306
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
307
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
308 /* Initialize an image instance from a bitmap
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
309
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
310 DEST_MASK specifies the mask of allowed image types.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
311
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
312 If this fails, signal an error. INSTANTIATOR is only used
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
313 in the error message. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
314
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
315 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
316 init_image_instance_from_dibitmap (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
317 BITMAPINFO *bmp_info,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
318 int dest_mask,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
319 void *bmp_data,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
320 int bmp_bits,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
321 Lisp_Object instantiator)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
322 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
323 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
324 struct device *d = XDEVICE (device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
325 struct frame *f = XFRAME (DEVICE_SELECTED_FRAME(d));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
326 void* bmp_buf=0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
327 HBITMAP bitmap;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
328 HDC hdc, cdc;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
329
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
330 if (!DEVICE_MSWINDOWS_P (d))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
331 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
332
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
333 if (NILP (DEVICE_SELECTED_FRAME (d)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
334 signal_simple_error ("No selected frame on mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
335
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
336 if (!(dest_mask & IMAGE_COLOR_PIXMAP_MASK))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
337 incompatible_image_types (instantiator, dest_mask,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
338 IMAGE_COLOR_PIXMAP_MASK);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
339 hdc = FRAME_MSWINDOWS_DC (f);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
340
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
341 bitmap=CreateDIBSection(hdc,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
342 bmp_info,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
343 DIB_RGB_COLORS,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
344 &bmp_buf,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
345 0,0);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
346
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
347 if (!bitmap || !bmp_buf)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
348 signal_simple_error ("Unable to create bitmap", instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
349
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
350 /* copy in the actual bitmap */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
351 memcpy(bmp_buf, bmp_data, bmp_bits);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
352
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
353 /* create a memory dc */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
354 cdc = CreateCompatibleDC(hdc);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
355
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
356 mswindows_initialize_dibitmap_image_instance (ii, IMAGE_COLOR_PIXMAP);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
357
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
358 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
359 find_keyword_in_vector (instantiator, Q_file);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
360
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
361 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
362 IMAGE_INSTANCE_MSWINDOWS_DC (ii) = cdc;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
363 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
364 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
365 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
366 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
367
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
368 /**********************************************************************
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
369 * XPM *
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
370 **********************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
371
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
372 #ifdef HAVE_XPM
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
373 static int xpm_to_eimage(Lisp_Object image, CONST Extbyte *buffer,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
374 unsigned char** data,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
375 int* width, int* height,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
376 COLORREF bg)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
377 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
378 XpmImage xpmimage;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
379 XpmInfo xpminfo;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
380 int result, i;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
381 unsigned char* dptr;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
382 unsigned int* sptr;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
383 COLORREF color; /* the american spelling virus hits again .. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
384 COLORREF* colortbl;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
385
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
386 memset (&xpmimage, 0, sizeof (xpmimage));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
387 memset (&xpminfo, 0, sizeof (xpmimage));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
388
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
389 result = XpmCreateXpmImageFromBuffer((char*)buffer,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
390 &xpmimage,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
391 &xpminfo);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
392 switch(result)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
393 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
394 case XpmSuccess:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
395 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
396 case XpmFileInvalid:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
397 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
398 signal_simple_error ("invalid XPM data", image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
399 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
400 case XpmNoMemory:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
401 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
402 signal_double_file_error ("Parsing pixmap data",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
403 "out of memory", image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
404 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
405 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
406 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
407 signal_double_file_error_2 ("Parsing pixmap data",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
408 "unknown error code",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
409 make_int (result), image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
410 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
411 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
412
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
413 *width = xpmimage.width;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
414 *height = xpmimage.height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
415
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
416 *data = xnew_array_and_zero (unsigned char, *width * *height * 3);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
417 if (!*data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
418 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
419 XpmFreeXpmImage(&xpmimage);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
420 XpmFreeXpmInfo(&xpminfo);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
421 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
422 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
423
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
424 /* build a color table to speed things up */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
425 colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
426 if (!colortbl)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
427 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
428 xfree(*data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
429 XpmFreeXpmImage(&xpmimage);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
430 XpmFreeXpmInfo(&xpminfo);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
431 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
432 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
433
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
434 for (i=0; i<xpmimage.ncolors; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
435 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
436 /* pick up transparencies */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
437 if (!strcmp(xpmimage.colorTable[i].c_color,"None"))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
438 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
439 colortbl[i]=bg;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
440 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
441 else
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
442 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
443 colortbl[i]=
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
444 mswindows_string_to_color(xpmimage.colorTable[i].c_color);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
445 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
446 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
447
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
448 /* convert the image */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
449 sptr=xpmimage.data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
450 dptr=*data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
451 for (i = 0; i< *width * *height; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
452 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
453 color = colortbl[*sptr++];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
454
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
455 /* split out the 0x02bbggrr colorref into an rgb triple */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
456 *dptr++=GetRValue(color); /* red */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
457 *dptr++=GetGValue(color); /* green */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
458 *dptr++=GetBValue(color); /* blue */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
459 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
460
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
461 XpmFreeXpmImage(&xpmimage);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
462 XpmFreeXpmInfo(&xpminfo);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
463 xfree(colortbl);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
464 return TRUE;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
465 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
466
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
467 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
468 mswindows_xpm_instantiate (Lisp_Object image_instance,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
469 Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
470 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
471 int dest_mask, Lisp_Object domain)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
472 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
473 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
474 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
475 CONST Extbyte *bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
476 Extcount len;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
477 unsigned char *eimage;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
478 int width, height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
479 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
480 unsigned char* bmp_data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
481 int bmp_bits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
482 COLORREF bkcolor;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
483
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
484 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
485
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
486 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
487 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
488
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
489 assert (!NILP (data));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
490
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
491 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
492
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
493 /* this is a hack but MaskBlt and TransparentBlt are not supported
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
494 on most windows variants */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
495 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
496 (XCOLOR_INSTANCE (FACE_BACKGROUND(Vdefault_face, domain)));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
497
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
498 /* convert to an eimage to make processing easier */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
499 if (!xpm_to_eimage(image_instance, bytes, &eimage, &width, &height,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
500 bkcolor))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
501 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
502 signal_simple_error ("XPM to EImage conversion failed",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
503 image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
504 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
505
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
506 /* build a bitmap from the eimage */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
507 if (!(bmp_info=EImage2DIBitmap(device, width, height, eimage,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
508 &bmp_bits, &bmp_data)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
509 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
510 signal_simple_error ("XPM to EImage conversion failed",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
511 image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
512 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
513 xfree(eimage);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
514
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
515 /* Now create the pixmap and set up the image instance */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
516 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
517 bmp_data, bmp_bits, instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
518
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
519 xfree(bmp_info);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
520 xfree(bmp_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
521 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
522 #endif /* HAVE_XPM */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
523
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
524 /**********************************************************************
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
525 * BMP *
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
526 **********************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
527
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
528 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
529 bmp_validate (Lisp_Object instantiator)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
530 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
531 file_or_data_must_be_present (instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
532 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
533
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
534 static Lisp_Object
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
535 bmp_normalize (Lisp_Object inst, Lisp_Object console_type)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
536 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
537 return simple_image_type_normalize (inst, console_type, Qbmp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
538 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
539
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
540 static int
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
541 bmp_possible_dest_types (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
542 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
543 return IMAGE_COLOR_PIXMAP_MASK;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
544 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
545
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
546 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
547 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
548 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
549 int dest_mask, Lisp_Object domain)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
550 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
551 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
552 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
553 CONST Extbyte *bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
554 Extcount len;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
555 BITMAPFILEHEADER* bmp_file_header;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
556 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
557 void* bmp_data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
558 int bmp_bits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
559 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
560
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
561 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
562 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
563
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
564 assert (!NILP (data));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
565
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
566 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
567
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
568 /* Then slurp the image into memory, decoding along the way.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
569 The result is the image in a simple one-byte-per-pixel
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
570 format. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
571
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
572 bmp_file_header=(BITMAPFILEHEADER*)bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
573 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
574 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
575 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
576
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
577 /* Now create the pixmap and set up the image instance */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
578 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
579 bmp_data, bmp_bits, instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
580 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
581
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
582
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
583 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
584 /* image instance methods */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
585 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
586
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
587 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
588 mswindows_print_image_instance (struct Lisp_Image_Instance *p,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
589 Lisp_Object printcharfun,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
590 int escapeflag)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
591 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
592 char buf[100];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
593
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
594 switch (IMAGE_INSTANCE_TYPE (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
595 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
596 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
597 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
598 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
599 sprintf (buf, " (0x%lx",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
600 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
601 write_c_string (buf, printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
602 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
603 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
604 sprintf (buf, "/0x%lx",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
605 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
606 write_c_string (buf, printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
607 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
608 write_c_string (")", printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
609 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
610 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
611 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
612 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
613 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
614
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
615 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
616 mswindows_finalize_image_instance (struct Lisp_Image_Instance *p)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
617 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
618 if (!p->data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
619 return;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
620
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
621 if (DEVICE_LIVE_P (XDEVICE (p->device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
622 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
623 if (IMAGE_INSTANCE_MSWINDOWS_DC (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
624 DeleteDC(IMAGE_INSTANCE_MSWINDOWS_DC (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
625 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
626 DeleteObject(IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
627 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p) = 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
628 IMAGE_INSTANCE_MSWINDOWS_DC (p) = 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
629 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
630
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
631 xfree (p->data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
632 p->data = 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
633 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
634
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
635 static int
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
636 mswindows_image_instance_equal (struct Lisp_Image_Instance *p1,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
637 struct Lisp_Image_Instance *p2, int depth)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
638 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
639 switch (IMAGE_INSTANCE_TYPE (p1))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
640 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
641 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
642 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
643 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
644 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
645 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
646 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
647 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
648 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
649 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
650 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
651
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
652 return 1;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
653 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
654
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
655 static unsigned long
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
656 mswindows_image_instance_hash (struct Lisp_Image_Instance *p, int depth)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
657 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
658 switch (IMAGE_INSTANCE_TYPE (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
659 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
660 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
661 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
662 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
663 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
664 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
665 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
666 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
667 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
668
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
669 /* Set all the slots in an image instance structure to reasonable
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
670 default values. This is used somewhere within an instantiate
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
671 method. It is assumed that the device slot within the image
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
672 instance is already set -- this is the case when instantiate
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
673 methods are called. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
674
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
675 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
676 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
677 enum image_instance_type type)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
678 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
679 ii->data = xnew_and_zero (struct mswindows_image_instance_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
680 IMAGE_INSTANCE_TYPE (ii) = type;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
681 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
682 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
683 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
684 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
685 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
686 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
687 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
688
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
689
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
690 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
691 /* initialization */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
692 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
693
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
694 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
695 syms_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
696 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
697 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
698
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
699 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
700 console_type_create_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
701 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
702 /* image methods */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
703
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
704 CONSOLE_HAS_METHOD (mswindows, print_image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
705 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
706 CONSOLE_HAS_METHOD (mswindows, image_instance_equal);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
707 CONSOLE_HAS_METHOD (mswindows, image_instance_hash);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
708 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
709
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
710 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
711 image_instantiator_format_create_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
712 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
713 /* image-instantiator types */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
714
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
715 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp");
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
716
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
717 IIFORMAT_HAS_METHOD (bmp, validate);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
718 IIFORMAT_HAS_METHOD (bmp, normalize);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
719 IIFORMAT_HAS_METHOD (bmp, possible_dest_types);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
720 IIFORMAT_HAS_METHOD (bmp, instantiate);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
721
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
722 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
723 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
724 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
725
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
726 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
727 vars_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
728 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
729 Fprovide (Qbmp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
730 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /*
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
731 A list of the directories in which mswindows bitmap files may be found.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
732 This is used by the `make-image-instance' function.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
733 */ );
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
734 Vmswindows_bitmap_file_path = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
735 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
736
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
737 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
738 complex_vars_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
739 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
740 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
741