annotate src/glyphs-msw.c @ 371:cc15677e0335 r21-2b1

Import from CVS: tag r21-2b1
author cvs
date Mon, 13 Aug 2007 11:03:08 +0200
parents 4711e16a8e49
children 6240c7796c7a
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.
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
2 Copyright (C) 1998 Andy Piper.
267
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"
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
29
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
30 #define OEMRESOURCE /* Define OCR_ and friend constants */
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
31 #include "console-msw.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
32 #include "glyphs-msw.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
33 #include "objects-msw.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
34
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
35 #include "buffer.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
36 #include "frame.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
37 #include "insdel.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
38 #include "opaque.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
39 #include "sysfile.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
40 #include "faces.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
41 #include "imgproc.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
42
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
43 #ifdef FILE_CODING
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
44 #include "file-coding.h"
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
45 #endif
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
46 #include <stdio.h>
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
47 #include <ctype.h>
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
48
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
49
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
50 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
51 Lisp_Object Qbmp;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
52 Lisp_Object Vmswindows_bitmap_file_path;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
53 static COLORREF transparent_color = RGB (1,1,1);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
54
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
55 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
56 Lisp_Object Q_resource_type, Q_resource_id;
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
57 Lisp_Object Qmswindows_resource;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
58
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
59 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
60 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
61 enum image_instance_type type);
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
62 static void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
63 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
64 struct frame* f);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
65
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
66 COLORREF mswindows_string_to_color (CONST char *name);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
67
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
68 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
69
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
70 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
71 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
72 /* proper display */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
73 /************************************************************************/
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
74 static BITMAPINFO* convert_EImage_to_DIBitmap (Lisp_Object device,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
75 int width, int height,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
76 unsigned char *pic,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
77 int *bit_count,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
78 unsigned char** bmp_data)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
79 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
80 struct device *d = XDEVICE (device);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
81 int i,j;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
82 RGBQUAD* colortbl;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
83 int ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
84 BITMAPINFO* bmp_info;
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
85 unsigned char *ip, *dp;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
86
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
87 if (DEVICE_MSWINDOWS_BITSPIXEL (d) > 0)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
88 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
89 int bpline = BPLINE(width * 3);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
90 /* FIXME: we can do this because 24bpp implies no colour table, once
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
91 * we start paletizing this is no longer true. The X versions of
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
92 * this function quantises to 256 colours or bit masks down to a
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
93 * long. Windows can actually handle rgb triples in the raw so I
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
94 * don't see much point trying to optimize down to the best
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
95 * structure - unless it has memory / color allocation implications
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
96 * .... */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
97 bmp_info=xnew_and_zero (BITMAPINFO);
267
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_info)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
100 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
101 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
102 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
103
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
104 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
105 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
106 bmp_info->bmiHeader.biSizeImage=width*height*3;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
107
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
108 /* bitmap data needs to be in blue, green, red triples - in that
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
109 order, eimage is in RGB format so we need to convert */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
110 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
111 *bit_count = bpline * height;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
112
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
113 if (!bmp_data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
114 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
115 xfree (bmp_info);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
116 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
117 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
118
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
119 ip = pic;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
120 for (i = height-1; i >= 0; i--) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
121 dp = (*bmp_data) + (i * bpline);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
122 for (j = 0; j < width; j++) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
123 dp[2] =*ip++;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
124 dp[1] =*ip++;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
125 *dp =*ip++;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
126 dp += 3;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
127 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
128 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
129 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
130 else /* scale to 256 colors */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
131 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
132 int rd,gr,bl;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
133 quant_table *qtable;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
134 int bpline = BPLINE (width * 3);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
135 /* Quantize the image and get a histogram while we're at it.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
136 Do this first to save memory */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
137 qtable = build_EImage_quantable(pic, width, height, 256);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
138 if (qtable == NULL) return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
139
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
140 /* use our quantize table to allocate the colors */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
141 ncolors = qtable->num_active_colors;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
142 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) +
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
143 sizeof(RGBQUAD) * ncolors);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
144 if (!bmp_info)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
145 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
146 xfree (qtable);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
147 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
148 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
149
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
150 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
151
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
152 bmp_info->bmiHeader.biBitCount=8;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
153 bmp_info->bmiHeader.biCompression=BI_RGB;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
154 bmp_info->bmiHeader.biSizeImage=bpline*height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
155 bmp_info->bmiHeader.biClrUsed=ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
156 bmp_info->bmiHeader.biClrImportant=ncolors;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
157
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
158 *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
159 *bit_count = bpline * height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
160
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
161 if (!*bmp_data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
162 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
163 xfree (qtable);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
164 xfree (bmp_info);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
165 return NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
166 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
167
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
168 /* build up an RGBQUAD colortable */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
169 for (i = 0; i < qtable->num_active_colors; i++) {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
170 colortbl[i].rgbRed = (BYTE) qtable->rm[i];
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
171 colortbl[i].rgbGreen = (BYTE) qtable->gm[i];
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
172 colortbl[i].rgbBlue = (BYTE) qtable->bm[i];
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
173 colortbl[i].rgbReserved = 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
174 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
175
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
176 /* now build up the data. picture has to be upside-down and
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
177 back-to-front for msw bitmaps */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
178 ip = pic;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
179 for (i = height-1; i >= 0; i--) {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
180 dp = (*bmp_data) + (i * bpline);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
181 for (j = 0; j < width; j++) {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
182 rd = *ip++;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
183 gr = *ip++;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
184 bl = *ip++;
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
185 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
186 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
187 }
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
188 xfree (qtable);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
189 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
190 /* fix up the standard stuff */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
191 bmp_info->bmiHeader.biWidth=width;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
192 bmp_info->bmiHeader.biHeight=height;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
193 bmp_info->bmiHeader.biPlanes=1;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
194 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
195 bmp_info->bmiHeader.biXPelsPerMeter=0; /* unless you know better */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
196 bmp_info->bmiHeader.biYPelsPerMeter=0;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
197
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
198 return bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
199 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
200
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
201 /* Given a pixmap filename, look through all of the "standard" places
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
202 where the file might be located. Return a full pathname if found;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
203 otherwise, return Qnil. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
204
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
205 static Lisp_Object
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
206 mswindows_locate_pixmap_file (Lisp_Object name)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
207 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
208 /* This function can GC if IN_REDISPLAY is false */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
209 Lisp_Object found;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
210
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
211 /* Check non-absolute pathnames with a directory component relative to
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
212 the search path; that's the way Xt does it. */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
213 if (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 0)) ||
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
214 (XSTRING_BYTE (name, 0) == '.' &&
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
215 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) ||
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
216 (XSTRING_BYTE (name, 1) == '.' &&
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
217 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2)))))))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
218 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
219 if (!NILP (Ffile_readable_p (name)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
220 return name;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
221 else
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
222 return Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
223 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
224
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
225 if (locate_file (Vmswindows_bitmap_file_path, name, "", &found, R_OK) < 0)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
226 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
227 Lisp_Object temp = list1 (Vdata_directory);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
228 struct gcpro gcpro1;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
229
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
230 GCPRO1 (temp);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
231 locate_file (temp, name, "", &found, R_OK);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
232 UNGCPRO;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
233 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
234
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
235 return found;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
236 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
237
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
238
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
239 /* Initialize an image instance from a bitmap
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
240
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
241 DEST_MASK specifies the mask of allowed image types.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
242
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
243 If this fails, signal an error. INSTANTIATOR is only used
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
244 in the error message. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
245
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
246 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
247 init_image_instance_from_dibitmap (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
248 BITMAPINFO *bmp_info,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
249 int dest_mask,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
250 void *bmp_data,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
251 int bmp_bits,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
252 Lisp_Object instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
253 int x_hot, int y_hot,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
254 int create_mask)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
255 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
256 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
257 struct device *d = XDEVICE (device);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
258 struct frame *f;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
259 void* bmp_buf=0;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
260 int type;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
261 HBITMAP bitmap;
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
262 HDC hdc;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
263
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
264 if (!DEVICE_MSWINDOWS_P (d))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
265 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
266
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
267 if (NILP (DEVICE_SELECTED_FRAME (d)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
268 signal_simple_error ("No selected frame on mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
269
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
270 f = XFRAME (DEVICE_SELECTED_FRAME (d));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
271
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
272 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
273 type = IMAGE_COLOR_PIXMAP;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
274 else if (dest_mask & IMAGE_POINTER_MASK)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
275 type = IMAGE_POINTER;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
276 else
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
277 incompatible_image_types (instantiator, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
278 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
279 hdc = FRAME_MSWINDOWS_CDC (f);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
280
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
281 bitmap=CreateDIBSection (hdc,
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
282 bmp_info,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
283 DIB_RGB_COLORS,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
284 &bmp_buf,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
285 0,0);
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 (!bitmap || !bmp_buf)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
288 signal_simple_error ("Unable to create bitmap", instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
289
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
290 /* copy in the actual bitmap */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
291 memcpy (bmp_buf, bmp_data, bmp_bits);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
292
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
293 mswindows_initialize_dibitmap_image_instance (ii, type);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
294
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
295 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
296 find_keyword_in_vector (instantiator, Q_file);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
297
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
298 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
299 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
300 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
301 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
302 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
303 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
304 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), y_hot);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
305
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
306 if (create_mask)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
307 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
308 mswindows_initialize_image_instance_mask (ii, f);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
309 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
310
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
311 if (type == IMAGE_POINTER)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
312 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
313 mswindows_initialize_image_instance_icon(ii, TRUE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
314 }
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
315 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
316
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
317 static void
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
318 mswindows_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
319 int width, int height,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
320 unsigned char *eimage,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
321 int dest_mask,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
322 Lisp_Object instantiator,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
323 Lisp_Object domain)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
324 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
325 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
326 BITMAPINFO* bmp_info;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
327 unsigned char* bmp_data;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
328 int bmp_bits;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
329 COLORREF bkcolor;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
330
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
331 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
332 signal_simple_error ("Not an mswindows device", device);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
333
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
334 /* this is a hack but MaskBlt and TransparentBlt are not supported
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
335 on most windows variants */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
336 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
337 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain)));
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
338
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
339 /* build a bitmap from the eimage */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
340 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
341 &bmp_bits, &bmp_data)))
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
342 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
343 signal_simple_error ("EImage to DIBitmap conversion failed",
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
344 instantiator);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
345 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
346
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
347 /* Now create the pixmap and set up the image instance */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
348 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
349 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
350 0, 0, 0);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
351
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
352 xfree (bmp_info);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
353 xfree (bmp_data);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
354 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
355
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
356 static void set_mono_pixel ( unsigned char* bits,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
357 int bpline, int height,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
358 int x, int y, int white )
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
359 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
360 int index;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
361 unsigned char bitnum;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
362 /* Find the byte on which this scanline begins */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
363 index = (height - y - 1) * bpline;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
364 /* Find the byte containing this pixel */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
365 index += (x >> 3);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
366 /* Which bit is it? */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
367 bitnum = (unsigned char)( 7 - (x % 8) );
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
368 if( white ) /* Turn it on */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
369 bits[index] |= (1<<bitnum);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
370 else /* Turn it off */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
371 bits[index] &= ~(1<<bitnum);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
372 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
373
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
374 static void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
375 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
376 struct frame* f)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
377 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
378 HBITMAP mask;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
379 HGDIOBJ old = NULL;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
380 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
381 unsigned char* dibits;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
382 BITMAPINFO* bmp_info =
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
383 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
384 int i, j;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
385 int height = IMAGE_INSTANCE_PIXMAP_HEIGHT (image);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
386
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
387 void* and_bits;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
388 int maskbpline = BPLINE (((IMAGE_INSTANCE_PIXMAP_WIDTH (image)+7)/8));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
389 int bpline = BPLINE (IMAGE_INSTANCE_PIXMAP_WIDTH (image) * 3);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
390
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
391 if (!bmp_info)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
392 return;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
393
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
394 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
395 bmp_info->bmiHeader.biHeight = height;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
396 bmp_info->bmiHeader.biPlanes=1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
397 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
398 bmp_info->bmiHeader.biBitCount=1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
399 bmp_info->bmiHeader.biCompression=BI_RGB;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
400 bmp_info->bmiHeader.biClrUsed = 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
401 bmp_info->bmiHeader.biClrImportant = 2;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
402 bmp_info->bmiHeader.biSizeImage = height * maskbpline;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
403 bmp_info->bmiColors[0].rgbRed = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
404 bmp_info->bmiColors[0].rgbGreen = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
405 bmp_info->bmiColors[0].rgbBlue = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
406 bmp_info->bmiColors[0].rgbReserved = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
407 bmp_info->bmiColors[1].rgbRed = 255;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
408 bmp_info->bmiColors[1].rgbGreen = 255;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
409 bmp_info->bmiColors[1].rgbBlue = 255;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
410 bmp_info->bmiColors[0].rgbReserved = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
411
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
412 if (!(mask = CreateDIBSection (hcdc,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
413 bmp_info,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
414 DIB_RGB_COLORS,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
415 &and_bits,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
416 0,0)))
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
417 {
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
418 xfree (bmp_info);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
419 return;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
420 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
421
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
422 old = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (image));
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
423 /* build up an in-memory set of bits to mess with */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
424 xzero (*bmp_info);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
425
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
426 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
427 bmp_info->bmiHeader.biHeight = -height;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
428 bmp_info->bmiHeader.biPlanes=1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
429 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
430 bmp_info->bmiHeader.biBitCount=24;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
431 bmp_info->bmiHeader.biCompression=BI_RGB;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
432 bmp_info->bmiHeader.biClrUsed = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
433 bmp_info->bmiHeader.biClrImportant = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
434 bmp_info->bmiHeader.biSizeImage = height * bpline;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
435
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
436 dibits = xmalloc_and_zero (bpline * height);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
437 if (GetDIBits (hcdc,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
438 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
439 0,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
440 height,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
441 dibits,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
442 bmp_info,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
443 DIB_RGB_COLORS) <= 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
444 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
445 xfree (bmp_info);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
446 return;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
447 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
448
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
449 /* now set the colored bits in the mask and transparent ones to
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
450 black in the original */
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
451 for(i=0; i<IMAGE_INSTANCE_PIXMAP_WIDTH (image); i++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
452 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
453 for(j=0; j<height; j++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
454 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
455 unsigned char* idx = &dibits[j * bpline + i * 3];
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
456
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
457 if( RGB (idx[2], idx[1], idx[0]) == transparent_color )
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
458 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
459 idx[0] = idx[1] = idx[2] = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
460 set_mono_pixel( and_bits, maskbpline, height, i, j, TRUE );
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
461 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
462 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
463 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
464 set_mono_pixel( and_bits, maskbpline, height, i, j, FALSE );
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
465 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
466 }
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
467 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
468
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
469 SetDIBits (hcdc,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
470 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
471 0,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
472 height,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
473 dibits,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
474 bmp_info,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
475 DIB_RGB_COLORS);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
476
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
477 xfree (bmp_info);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
478 xfree (dibits);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
479
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
480 SelectObject(hcdc, old);
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
481
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
482 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
483 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
484
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
485 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
486 mswindows_initialize_image_instance_icon (struct Lisp_Image_Instance* image,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
487 int cursor)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
488 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
489 ICONINFO x_icon;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
490
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
491 /* we rely on windows to do any resizing necessary */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
492 x_icon.fIcon=cursor ? FALSE : TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
493 x_icon.xHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
494 x_icon.yHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
495 x_icon.hbmMask=IMAGE_INSTANCE_MSWINDOWS_MASK (image);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
496 x_icon.hbmColor=IMAGE_INSTANCE_MSWINDOWS_BITMAP (image);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
497
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
498 IMAGE_INSTANCE_MSWINDOWS_ICON (image)=
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
499 CreateIconIndirect (&x_icon);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
500 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
501
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
502 HBITMAP
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
503 mswindows_create_resized_bitmap (struct Lisp_Image_Instance* ii,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
504 struct frame* f,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
505 int newx, int newy)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
506 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
507 HBITMAP newbmp;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
508 HGDIOBJ old1, old2;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
509 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
510 HDC hdcDst = CreateCompatibleDC (hcdc);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
511
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
512 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
513
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
514 newbmp = CreateCompatibleBitmap (hcdc, newx, newy);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
515
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
516 old2 = SelectObject (hdcDst, newbmp);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
517
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
518 if (!StretchBlt (hdcDst, 0, 0, newx, newy,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
519 hcdc, 0, 0,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
520 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
521 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
522 SRCCOPY))
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
523 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
524 return 0;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
525 }
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
526
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
527 SelectObject (hdcDst, old2);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
528 SelectObject (hcdc, old1);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
529 DeleteDC (hdcDst);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
530
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
531 return newbmp;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
532 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
533
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
534 HBITMAP
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
535 mswindows_create_resized_mask (struct Lisp_Image_Instance* ii,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
536 struct frame* f,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
537 int newx, int newy)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
538 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
539 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
540 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
541 HBITMAP newmask;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
542 HGDIOBJ old1, old2;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
543 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
544 HDC hdcDst = CreateCompatibleDC (hcdc);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
545
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
546 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
547 newmask = CreateCompatibleBitmap(hcdc, newx, newy);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
548 old2 = SelectObject (hdcDst, newmask);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
549
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
550 if (!StretchBlt(hdcDst, 0, 0, newx, newy,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
551 hcdc, 0, 0,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
552 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
553 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
554 SRCCOPY))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
555 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
556 return NULL;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
557 }
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
558
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
559 SelectObject (hdcDst, old2);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
560 SelectObject (hcdc, old1);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
561
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
562 DeleteDC (hdcDst);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
563
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
564 return newmask;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
565 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
566
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
567 return NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
568 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
569
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
570 int
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
571 mswindows_resize_dibitmap_instance (struct Lisp_Image_Instance* ii,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
572 struct frame* f,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
573 int newx, int newy)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
574 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
575 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
576 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
577
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
578 if (!newbmp)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
579 return FALSE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
580
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
581 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
582 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
583 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
584 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
585
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
586 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = newbmp;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
587 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = newmask;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
588 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
589 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
590
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
591 return TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
592 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
593
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
594 /**********************************************************************
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
595 * XPM *
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
596 **********************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
597
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
598 #ifdef HAVE_XPM
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
599
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
600 struct color_symbol
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
601 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
602 char* name;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
603 COLORREF color;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
604 };
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
605
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
606 static struct color_symbol*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
607 extract_xpm_color_names (Lisp_Object device,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
608 Lisp_Object domain,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
609 Lisp_Object color_symbol_alist,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
610 int* nsymbols)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
611 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
612 /* This function can GC */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
613 Lisp_Object rest;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
614 Lisp_Object results = Qnil;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
615 int i, j;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
616 struct color_symbol *colortbl;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
617 struct gcpro gcpro1, gcpro2;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
618
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
619 GCPRO2 (results, device);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
620
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
621 /* We built up results to be (("name" . #<color>) ...) so that if an
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
622 error happens we don't lose any malloc()ed data, or more importantly,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
623 leave any pixels allocated in the server. */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
624 i = 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
625 LIST_LOOP (rest, color_symbol_alist)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
626 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
627 Lisp_Object cons = XCAR (rest);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
628 Lisp_Object name = XCAR (cons);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
629 Lisp_Object value = XCDR (cons);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
630 if (NILP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
631 continue;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
632 if (STRINGP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
633 value =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
634 Fmake_color_instance
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
635 (value, device, encode_error_behavior_flag (ERROR_ME_NOT));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
636 else
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
637 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
638 assert (COLOR_SPECIFIERP (value));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
639 value = Fspecifier_instance (value, domain, Qnil, Qnil);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
640 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
641 if (NILP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
642 continue;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
643 results = noseeum_cons (noseeum_cons (name, value), results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
644 i++;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
645 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
646 UNGCPRO; /* no more evaluation */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
647
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
648 *nsymbols=i;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
649 if (i == 0) return 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
650
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
651 colortbl = xnew_array_and_zero (struct color_symbol, i);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
652
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
653 for (j=0; j<i; j++)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
654 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
655 Lisp_Object cons = XCAR (results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
656 colortbl[j].color =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
657 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
658
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
659 colortbl[j].name = (char *) XSTRING_DATA (XCAR (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
660 free_cons (XCONS (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
661 cons = results;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
662 results = XCDR (results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
663 free_cons (XCONS (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
664 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
665 return colortbl;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
666 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
667
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
668 static int xpm_to_eimage (Lisp_Object image, CONST Extbyte *buffer,
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
669 unsigned char** data,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
670 int* width, int* height,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
671 int* x_hot, int* y_hot,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
672 int* transp,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
673 struct color_symbol* color_symbols,
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
674 int nsymbols)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
675 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
676 XpmImage xpmimage;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
677 XpmInfo xpminfo;
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
678 int result, i, j, transp_idx, maskbpline;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
679 unsigned char* dptr;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
680 unsigned int* sptr;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
681 COLORREF color; /* the american spelling virus hits again .. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
682 COLORREF* colortbl;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
683
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
684 xzero (xpmimage);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
685 xzero (xpminfo);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
686 xpminfo.valuemask=XpmHotspot;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
687 *transp=FALSE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
688
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
689 result = XpmCreateXpmImageFromBuffer ((char*)buffer,
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
690 &xpmimage,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
691 &xpminfo);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
692 switch (result)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
693 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
694 case XpmSuccess:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
695 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
696 case XpmFileInvalid:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
697 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
698 signal_simple_error ("invalid XPM data", image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
699 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
700 case XpmNoMemory:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
701 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
702 signal_double_file_error ("Parsing pixmap data",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
703 "out of memory", image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
704 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
705 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
706 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
707 signal_double_file_error_2 ("Parsing pixmap data",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
708 "unknown error code",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
709 make_int (result), image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
710 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
711 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
712
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
713 *width = xpmimage.width;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
714 *height = xpmimage.height;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
715 maskbpline = BPLINE (((~7UL & (unsigned long)(*width + 7)) / 8));
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
716
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
717 *data = xnew_array_and_zero (unsigned char, *width * *height * 3);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
718
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
719 if (!*data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
720 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
721 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
722 XpmFreeXpmInfo (&xpminfo);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
723 return 0;
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 /* build a color table to speed things up */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
727 colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
728 if (!colortbl)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
729 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
730 xfree (*data);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
731 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
732 XpmFreeXpmInfo (&xpminfo);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
733 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
734 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
735
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
736 for (i=0; i<xpmimage.ncolors; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
737 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
738 /* goto alert!!!! */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
739 /* pick up symbolic colors in preference */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
740 if (xpmimage.colorTable[i].symbolic)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
741 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
742 if (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor")
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
743 ||
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
744 !strcasecmp (xpmimage.colorTable[i].symbolic,"None"))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
745 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
746 *transp=TRUE;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
747 colortbl[i]=transparent_color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
748 transp_idx=i;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
749 goto label_found_color;
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
750 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
751 else if (color_symbols)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
752 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
753 for (j = 0; j<nsymbols; j++)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
754 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
755 if (!strcmp (xpmimage.colorTable[i].symbolic,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
756 color_symbols[j].name ))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
757 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
758 colortbl[i]=color_symbols[j].color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
759 goto label_found_color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
760 }
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
761 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
762 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
763 else if (xpmimage.colorTable[i].c_color == 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
764 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
765 goto label_no_color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
766 }
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
767 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
768 /* pick up transparencies */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
769 if (!strcasecmp (xpmimage.colorTable[i].c_color,"None"))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
770 {
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
771 *transp=TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
772 colortbl[i]=transparent_color;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
773 transp_idx=i;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
774 goto label_found_color;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
775 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
776 /* finally pick up a normal color spec */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
777 if (xpmimage.colorTable[i].c_color)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
778 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
779 colortbl[i]=
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
780 mswindows_string_to_color (xpmimage.colorTable[i].c_color);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
781 goto label_found_color;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
782 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
783
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
784 label_no_color:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
785 xfree (*data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
786 xfree (colortbl);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
787 XpmFreeXpmImage (&xpmimage);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
788 XpmFreeXpmInfo (&xpminfo);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
789 return 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
790
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
791 label_found_color:;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
792 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
793
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
794 /* convert the image */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
795 sptr=xpmimage.data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
796 dptr=*data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
797 for (i = 0; i< *width * *height; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
798 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
799 color = colortbl[*sptr++];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
800
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
801 /* split out the 0x02bbggrr colorref into an rgb triple */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
802 *dptr++=GetRValue (color); /* red */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
803 *dptr++=GetGValue (color); /* green */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
804 *dptr++=GetBValue (color); /* blue */
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
805 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
806
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
807 *x_hot=xpminfo.x_hotspot;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
808 *y_hot=xpminfo.y_hotspot;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
809
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
810 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
811 XpmFreeXpmInfo (&xpminfo);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
812 xfree (colortbl);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
813 return TRUE;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
814 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
815
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
816 static void
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
817 mswindows_xpm_instantiate (Lisp_Object image_instance,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
818 Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
819 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
820 int dest_mask, Lisp_Object domain)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
821 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
822 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
823 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
824 CONST Extbyte *bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
825 Extcount len;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
826 unsigned char *eimage;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
827 int width, height, x_hot, y_hot;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
828 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
829 unsigned char* bmp_data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
830 int bmp_bits;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
831 int nsymbols=0, transp;
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
832 struct color_symbol* color_symbols=NULL;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
833
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
834 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
835 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
836 Q_color_symbols);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
837
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
838 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
839 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
840
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
841 assert (!NILP (data));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
842
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
843 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
844
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
845 /* in case we have color symbols */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
846 color_symbols = extract_xpm_color_names (device, domain,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
847 color_symbol_alist, &nsymbols);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
848
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
849 /* convert to an eimage to make processing easier */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
850 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
851 &x_hot, &y_hot, &transp, color_symbols, nsymbols))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
852 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
853 signal_simple_error ("XPM to EImage conversion failed",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
854 image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
855 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
856
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
857 if (color_symbols)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
858 xfree(color_symbols);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
859
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
860 /* build a bitmap from the eimage */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
861 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
862 &bmp_bits, &bmp_data)))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
863 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
864 signal_simple_error ("XPM to EImage conversion failed",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
865 image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
866 }
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
867 xfree (eimage);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
868
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
869 /* Now create the pixmap and set up the image instance */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
870 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
871 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
872 x_hot, y_hot, transp);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
873
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
874 xfree (bmp_info);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
875 xfree (bmp_data);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
876 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
877 #endif /* HAVE_XPM */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
878
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
879 /**********************************************************************
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
880 * BMP *
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
881 **********************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
882
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
883 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
884 bmp_validate (Lisp_Object instantiator)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
885 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
886 file_or_data_must_be_present (instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
887 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
888
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
889 static Lisp_Object
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
890 bmp_normalize (Lisp_Object inst, Lisp_Object console_type)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
891 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
892 return simple_image_type_normalize (inst, console_type, Qbmp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
893 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
894
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
895 static int
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
896 bmp_possible_dest_types (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
897 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
898 return IMAGE_COLOR_PIXMAP_MASK;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
899 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
900
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
901 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
902 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
903 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
904 int dest_mask, Lisp_Object domain)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
905 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
906 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
907 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
908 CONST Extbyte *bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
909 Extcount len;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
910 BITMAPFILEHEADER* bmp_file_header;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
911 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
912 void* bmp_data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
913 int bmp_bits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
914 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
915
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
916 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
917 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
918
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
919 assert (!NILP (data));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
920
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
921 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
922
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
923 /* Then slurp the image into memory, decoding along the way.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
924 The result is the image in a simple one-byte-per-pixel
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
925 format. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
926
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
927 bmp_file_header=(BITMAPFILEHEADER*)bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
928 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
929 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
930 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
931
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
932 /* Now create the pixmap and set up the image instance */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
933 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
934 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
935 0, 0, 0);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
936 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
937
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
938
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
939 /**********************************************************************
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
940 * RESOURCES *
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
941 **********************************************************************/
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
942
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
943 static void
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
944 mswindows_resource_validate (Lisp_Object instantiator)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
945 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
946 if ((NILP (find_keyword_in_vector (instantiator, Q_file))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
947 &&
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
948 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
949 ||
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
950 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
951 signal_simple_error ("Must supply :file, :resource-id and :resource-type",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
952 instantiator);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
953 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
954
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
955 static Lisp_Object
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
956 mswindows_resource_normalize (Lisp_Object inst, Lisp_Object console_type)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
957 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
958 /* This function can call lisp */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
959 Lisp_Object file = Qnil;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
960 struct gcpro gcpro1, gcpro2;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
961 Lisp_Object alist = Qnil;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
962
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
963 GCPRO2 (file, alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
964
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
965 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
966 console_type);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
967
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
968 if (CONSP (file)) /* failure locating filename */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
969 signal_double_file_error ("Opening pixmap file",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
970 "no such file or directory",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
971 Fcar (file));
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
972
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
973 if (NILP (file)) /* no conversion necessary */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
974 RETURN_UNGCPRO (inst);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
975
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
976 alist = tagged_vector_to_alist (inst);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
977
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
978 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
979 alist = remassq_no_quit (Q_file, alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
980 alist = Fcons (Fcons (Q_file, file), alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
981 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
982
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
983 {
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
984 Lisp_Object result = alist_to_tagged_vector (Qmswindows_resource, alist);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
985 free_alist (alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
986 RETURN_UNGCPRO (result);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
987 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
988 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
989
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
990 static int
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
991 mswindows_resource_possible_dest_types (void)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
992 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
993 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
994 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
995
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
996 typedef struct
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
997 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
998 char *name;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
999 int resource_id;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1000 } resource_t;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1001
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1002 #ifndef OCR_ICOCUR
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1003 #define OCR_ICOCUR 32647
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1004 #define OIC_SAMPLE 32512
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1005 #define OIC_HAND 32513
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1006 #define OIC_QUES 32514
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1007 #define OIC_BANG 32515
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1008 #define OIC_NOTE 32516
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1009 #define OIC_WINLOGO 32517
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1010 #define LR_SHARED 0x8000
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1011 #endif
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1012
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1013 static CONST resource_t bitmap_table[] =
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1014 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1015 /* bitmaps */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1016 { "close", OBM_CLOSE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1017 { "uparrow", OBM_UPARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1018 { "dnarrow", OBM_DNARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1019 { "rgarrow", OBM_RGARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1020 { "lfarrow", OBM_LFARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1021 { "reduce", OBM_REDUCE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1022 { "zoom", OBM_ZOOM },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1023 { "restore", OBM_RESTORE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1024 { "reduced", OBM_REDUCED },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1025 { "zoomd", OBM_ZOOMD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1026 { "restored", OBM_RESTORED },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1027 { "uparrowd", OBM_UPARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1028 { "dnarrowd", OBM_DNARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1029 { "rgarrowd", OBM_RGARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1030 { "lfarrowd", OBM_LFARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1031 { "mnarrow", OBM_MNARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1032 { "combo", OBM_COMBO },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1033 { "uparrowi", OBM_UPARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1034 { "dnarrowi", OBM_DNARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1035 { "rgarrowi", OBM_RGARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1036 { "lfarrowi", OBM_LFARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1037 { "size", OBM_SIZE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1038 { "btsize", OBM_BTSIZE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1039 { "check", OBM_CHECK },
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 357
diff changeset
1040 { "cehckboxes", OBM_CHECKBOXES },
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1041 { "btncorners" , OBM_BTNCORNERS },
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1042 {0}
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1043 };
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1044
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1045 static CONST resource_t cursor_table[] =
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1046 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1047 /* cursors */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1048 { "normal", OCR_NORMAL },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1049 { "ibeam", OCR_IBEAM },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1050 { "wait", OCR_WAIT },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1051 { "cross", OCR_CROSS },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1052 { "up", OCR_UP },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1053 /* { "icon", OCR_ICON }, */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1054 { "sizenwse", OCR_SIZENWSE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1055 { "sizenesw", OCR_SIZENESW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1056 { "sizewe", OCR_SIZEWE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1057 { "sizens", OCR_SIZENS },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1058 { "sizeall", OCR_SIZEALL },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1059 /* { "icour", OCR_ICOCUR }, */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1060 { "no", OCR_NO },
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1061 { 0 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1062 };
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1063
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1064 static CONST resource_t icon_table[] =
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1065 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1066 /* icons */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1067 { "sample", OIC_SAMPLE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1068 { "hand", OIC_HAND },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1069 { "ques", OIC_QUES },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1070 { "bang", OIC_BANG },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1071 { "note", OIC_NOTE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1072 { "winlogo", OIC_WINLOGO },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1073 {0}
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1074 };
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1075
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1076 static int resource_name_to_resource (Lisp_Object name, int type)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1077 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1078 CONST resource_t* res = (type == IMAGE_CURSOR ? cursor_table
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1079 : type == IMAGE_ICON ? icon_table
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1080 : bitmap_table);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1081
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1082 if (INTP (name))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1083 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1084 return XINT (name);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1085 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1086 else if (!STRINGP (name))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1087 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1088 signal_simple_error ("invalid resource identifier", name);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1089 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1090
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1091 do {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1092 if (!strcasecmp ((char*)res->name, XSTRING_DATA (name)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1093 return res->resource_id;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1094 } while ((++res)->name);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1095 return 0;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1096 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1097
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1098 static int
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1099 resource_symbol_to_type (Lisp_Object data)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1100 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1101 if (EQ (data, Qcursor))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1102 return IMAGE_CURSOR;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1103 else if (EQ (data, Qicon))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1104 return IMAGE_ICON;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1105 else if (EQ (data, Qbitmap))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1106 return IMAGE_BITMAP;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1107 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1108 return 0;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1109 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1110
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1111 static void
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1112 mswindows_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1113 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1114 int dest_mask, Lisp_Object domain)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1115 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1116 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1117 unsigned int type = 0;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1118 HANDLE himage = NULL;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1119 LPCTSTR resid=0;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1120 HINSTANCE hinst = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1121 ICONINFO iconinfo;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1122 int iitype=0;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1123 char* fname=0;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1124 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1125
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1126 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1127 Lisp_Object resource_type = find_keyword_in_vector (instantiator,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1128 Q_resource_type);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1129 Lisp_Object resource_id = find_keyword_in_vector (instantiator,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1130 Q_resource_id);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1131
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1132 xzero (iconinfo);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1133
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1134 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1135 signal_simple_error ("Not an mswindows device", device);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1136
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1137 type = resource_symbol_to_type (resource_type);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1138
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1139 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1140 iitype = IMAGE_POINTER;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1141 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1142 iitype = IMAGE_COLOR_PIXMAP;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1143 else
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1144 incompatible_image_types (instantiator, dest_mask,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1145 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1146
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1147 /* mess with the keyword info we were provided with */
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1148 if (!NILP (file))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1149 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1150 #ifdef __CYGWIN32__
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1151 CYGWIN_WIN32_PATH (XSTRING_DATA (file), fname);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1152 #else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1153 /* #### FIXME someone who knows ... */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1154 fname = XSTRING_DATA (file);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1155 #endif
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1156
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1157 if (NILP (resource_id))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1158 resid = (LPCTSTR)fname;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1159 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1160 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1161 hinst = LoadLibraryEx (fname, NULL,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1162 LOAD_LIBRARY_AS_DATAFILE);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1163 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1164 type));
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1165
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1166 if (!resid)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1167 resid = XSTRING_DATA (resource_id);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1168 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1169 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1170 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1171 type))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1172 signal_simple_error ("invalid resource identifier", resource_id);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1173
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1174 /* load the image */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1175 if (!(himage = LoadImage (hinst, resid, type, 0, 0,
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1176 LR_CREATEDIBSECTION | LR_DEFAULTSIZE |
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1177 LR_SHARED |
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1178 (!NILP (file) ? LR_LOADFROMFILE : 0))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1179 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1180 signal_simple_error ("cannot load image", instantiator);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1181 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1182
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1183 if (hinst)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1184 FreeLibrary (hinst);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1185
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1186 mswindows_initialize_dibitmap_image_instance (ii, iitype);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1187
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1188 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1189 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) =
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1190 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1191 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) =
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1192 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1193 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1194
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1195 /* hey, we've got an icon type thing so we can reverse engineer the
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1196 bitmap and mask */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1197 if (type != IMAGE_BITMAP)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1198 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1199 GetIconInfo (himage, &iconinfo);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1200 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1201 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1202 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1203 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1204 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = himage;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1205 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1206 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1207 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1208 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1209 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = himage;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1210 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1211 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1212 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1213 }
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1214 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1215
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1216 static void
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1217 check_valid_resource_symbol (Lisp_Object data)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1218 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1219 CHECK_SYMBOL (data);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1220 if (!resource_symbol_to_type (data))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1221 signal_simple_error ("invalid resource type", data);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1222 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1223
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1224 static void
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1225 check_valid_resource_id (Lisp_Object data)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1226 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1227 if (!resource_name_to_resource (data, IMAGE_CURSOR)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1228 &&
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1229 !resource_name_to_resource (data, IMAGE_ICON)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1230 &&
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1231 !resource_name_to_resource (data, IMAGE_BITMAP))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1232 signal_simple_error ("invalid resource identifier", data);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1233 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1234
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1235 void
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1236 check_valid_string_or_int (Lisp_Object data)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1237 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1238 if (!INTP (data))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1239 CHECK_STRING (data);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1240 else
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1241 CHECK_INT (data);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1242 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1243
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1244 /**********************************************************************
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1245 * XBM *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1246 **********************************************************************/
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1247 #ifndef HAVE_X_WINDOWS
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1248 /* $XConsortium: RdBitF.c,v 1.10 94/04/17 20:16:13 kaleb Exp $ */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1249
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1250 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1251
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1252 Copyright (c) 1988 X Consortium
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1253
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1254 Permission is hereby granted, free of charge, to any person obtaining a copy
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1255 of this software and associated documentation files (the "Software"), to deal
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1256 in the Software without restriction, including without limitation the rights
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1257 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1258 copies of the Software, and to permit persons to whom the Software is
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1259 furnished to do so, subject to the following conditions:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1260
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1261 The above copyright notice and this permission notice shall be included in
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1262 all copies or substantial portions of the Software.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1263
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1264 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1265 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1266 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1267 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1268 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1269 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1270
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1271 Except as contained in this notice, the name of the X Consortium shall not be
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1272 used in advertising or otherwise to promote the sale, use or other dealings
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1273 in this Software without prior written authorization from the X Consortium.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1274
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1275 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1276
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1277 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1278 * This file contains miscellaneous utility routines and is not part of the
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1279 * Xlib standard.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1280 *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1281 * Public entry points:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1282 *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1283 * XmuReadBitmapData read data from FILE descriptor
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1284 * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1285 * and return data
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1286 *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1287 * Note that this file and ../X/XRdBitF.c look very similar.... Keep them
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1288 * that way (but don't use common source code so that people can have one
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1289 * without the other).
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1290 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1291
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1292
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1293 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1294 * Based on an optimized version provided by Jim Becker, Auguest 5, 1988.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1295 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1296 #ifndef BitmapSuccess
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1297 #define BitmapSuccess 0
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1298 #define BitmapOpenFailed 1
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1299 #define BitmapFileInvalid 2
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1300 #define BitmapNoMemory 3
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1301 #endif
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1302 #define MAX_SIZE 255
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1303
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1304 /* shared data for the image read/parse logic */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1305 static short hexTable[256]; /* conversion value */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1306 static int initialized = FALSE; /* easier to fill in at run time */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1307
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1308 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1309 * Table index for the hex values. Initialized once, first time.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1310 * Used for translation value or delimiter significance lookup.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1311 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1312 static void initHexTable()
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1313 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1314 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1315 * We build the table at run time for several reasons:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1316 *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1317 * 1. portable to non-ASCII machines.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1318 * 2. still reentrant since we set the init flag after setting table.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1319 * 3. easier to extend.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1320 * 4. less prone to bugs.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1321 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1322 hexTable['0'] = 0; hexTable['1'] = 1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1323 hexTable['2'] = 2; hexTable['3'] = 3;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1324 hexTable['4'] = 4; hexTable['5'] = 5;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1325 hexTable['6'] = 6; hexTable['7'] = 7;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1326 hexTable['8'] = 8; hexTable['9'] = 9;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1327 hexTable['A'] = 10; hexTable['B'] = 11;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1328 hexTable['C'] = 12; hexTable['D'] = 13;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1329 hexTable['E'] = 14; hexTable['F'] = 15;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1330 hexTable['a'] = 10; hexTable['b'] = 11;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1331 hexTable['c'] = 12; hexTable['d'] = 13;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1332 hexTable['e'] = 14; hexTable['f'] = 15;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1333
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1334 /* delimiters of significance are flagged w/ negative value */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1335 hexTable[' '] = -1; hexTable[','] = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1336 hexTable['}'] = -1; hexTable['\n'] = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1337 hexTable['\t'] = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1338
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1339 initialized = TRUE;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1340 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1341
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1342 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1343 * read next hex value in the input stream, return -1 if EOF
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1344 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1345 static int NextInt ( FILE *fstream )
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1346 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1347 int ch;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1348 int value = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1349 int gotone = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1350 int done = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1351
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1352 /* loop, accumulate hex value until find delimiter */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1353 /* skip any initial delimiters found in read stream */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1354
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1355 while (!done) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1356 ch = getc(fstream);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1357 if (ch == EOF) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1358 value = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1359 done++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1360 } else {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1361 /* trim high bits, check type and accumulate */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1362 ch &= 0xff;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1363 if (isascii(ch) && isxdigit(ch)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1364 value = (value << 4) + hexTable[ch];
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1365 gotone++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1366 } else if ((hexTable[ch]) < 0 && gotone)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1367 done++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1368 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1369 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1370 return value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1371 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1372
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1373
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1374 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1375 * The data returned by the following routine is always in left-most byte
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1376 * first and left-most bit first. If it doesn't return BitmapSuccess then
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1377 * its arguments won't have been touched. This routine should look as much
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1378 * like the Xlib routine XReadBitmapfile as possible.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1379 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1380 int read_bitmap_data (fstream, width, height, datap, x_hot, y_hot)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1381 FILE *fstream; /* handle on file */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1382 unsigned int *width, *height; /* RETURNED */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1383 unsigned char **datap; /* RETURNED */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1384 int *x_hot, *y_hot; /* RETURNED */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1385 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1386 unsigned char *data = NULL; /* working variable */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1387 char line[MAX_SIZE]; /* input line from file */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1388 int size; /* number of bytes of data */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1389 char name_and_type[MAX_SIZE]; /* an input line */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1390 char *type; /* for parsing */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1391 int value; /* from an input line */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1392 int version10p; /* boolean, old format */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1393 int padding; /* to handle alignment */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1394 int bytes_per_line; /* per scanline of data */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1395 unsigned int ww = 0; /* width */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1396 unsigned int hh = 0; /* height */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1397 int hx = -1; /* x hotspot */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1398 int hy = -1; /* y hotspot */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1399
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1400 #define Xmalloc(size) malloc(size)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1401
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1402 /* first time initialization */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1403 if (initialized == FALSE) initHexTable();
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1404
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1405 /* error cleanup and return macro */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1406 #define RETURN(code) { if (data) free (data); return code; }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1407
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1408 while (fgets(line, MAX_SIZE, fstream)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1409 if (strlen(line) == MAX_SIZE-1) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1410 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1411 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1412 if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1413 if (!(type = strrchr(name_and_type, '_')))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1414 type = name_and_type;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1415 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1416 type++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1417
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1418 if (!strcmp("width", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1419 ww = (unsigned int) value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1420 if (!strcmp("height", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1421 hh = (unsigned int) value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1422 if (!strcmp("hot", type)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1423 if (type-- == name_and_type || type-- == name_and_type)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1424 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1425 if (!strcmp("x_hot", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1426 hx = value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1427 if (!strcmp("y_hot", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1428 hy = value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1429 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1430 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1431 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1432
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1433 if (sscanf(line, "static short %s = {", name_and_type) == 1)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1434 version10p = 1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1435 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1436 version10p = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1437 else if (sscanf(line, "static char %s = {", name_and_type) == 1)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1438 version10p = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1439 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1440 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1441
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1442 if (!(type = strrchr(name_and_type, '_')))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1443 type = name_and_type;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1444 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1445 type++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1446
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1447 if (strcmp("bits[]", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1448 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1449
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1450 if (!ww || !hh)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1451 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1452
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1453 if ((ww % 16) && ((ww % 16) < 9) && version10p)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1454 padding = 1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1455 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1456 padding = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1457
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1458 bytes_per_line = (ww+7)/8 + padding;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1459
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1460 size = bytes_per_line * hh;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1461 data = (unsigned char *) Xmalloc ((unsigned int) size);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1462 if (!data)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1463 RETURN (BitmapNoMemory);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1464
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1465 if (version10p) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1466 unsigned char *ptr;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1467 int bytes;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1468
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1469 for (bytes=0, ptr=data; bytes<size; (bytes += 2)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1470 if ((value = NextInt(fstream)) < 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1471 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1472 *(ptr++) = value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1473 if (!padding || ((bytes+2) % bytes_per_line))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1474 *(ptr++) = value >> 8;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1475 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1476 } else {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1477 unsigned char *ptr;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1478 int bytes;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1479
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1480 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1481 if ((value = NextInt(fstream)) < 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1482 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1483 *ptr=value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1484 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1485 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1486 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1487 } /* end while */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1488
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1489 if (data == NULL) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1490 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1491 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1492
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1493 *datap = data;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1494 data = NULL;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1495 *width = ww;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1496 *height = hh;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1497 if (x_hot) *x_hot = hx;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1498 if (y_hot) *y_hot = hy;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1499
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1500 RETURN (BitmapSuccess);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1501 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1502
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1503
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1504 int read_bitmap_data_from_file (CONST char *filename, unsigned int *width,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1505 unsigned int *height, unsigned char **datap,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1506 int *x_hot, int *y_hot)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1507 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1508 FILE *fstream;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1509 int status;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1510
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1511 if ((fstream = fopen (filename, "r")) == NULL) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1512 return BitmapOpenFailed;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1513 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1514 status = read_bitmap_data (fstream, width, height, datap, x_hot, y_hot);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1515 fclose (fstream);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1516 return status;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1517 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1518 #endif /* HAVE_X_WINDOWS */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1519
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1520 /* this table flips four bits around. */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1521 static int flip_table[] =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1522 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1523 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1524 };
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1525
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1526 /* the bitmap data comes in the following format: Widths are padded to
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1527 a multiple of 8. Scan lines are stored in increasing byte order
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1528 from left to right, little-endian within a byte. 0 = white, 1 =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1529 black. It must be converted to the following format: Widths are
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1530 padded to a multiple of 16. Scan lines are stored in increasing
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1531 byte order from left to right, big-endian within a byte. 0 =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1532 black, 1 = white. */
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1533 HBITMAP
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1534 xbm_create_bitmap_from_data (HDC hdc, char *data,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1535 unsigned int width, unsigned int height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1536 int mask, COLORREF fg, COLORREF bg)
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1537 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1538 int old_width = (width + 7)/8;
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 357
diff changeset
1539 int new_width = 2*((width + 15)/16);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1540 unsigned char *offset;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1541 void *bmp_buf = 0;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1542 unsigned char *new_data, *new_offset;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1543 int i, j;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1544 BITMAPINFO* bmp_info =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1545 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1546 HBITMAP bitmap;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1547
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1548 if (!bmp_info)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1549 return NULL;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1550
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1551 new_data = (unsigned char *) xmalloc (height * new_width);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1552
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1553 if (!new_data)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1554 {
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1555 xfree (bmp_info);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1556 return NULL;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1557 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1558
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1559 for (i=0; i<height; i++)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1560 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1561 offset = data + i*old_width;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1562 new_offset = new_data + i*new_width;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1563
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1564 new_offset[new_width - 1] = 0; /* there may be an extra byte
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1565 that needs to be padded */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1566 for (j=0; j<old_width; j++)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1567 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1568 int byte = offset[j];
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1569 new_offset[j] = ~ (unsigned char)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1570 ((flip_table[byte & 0xf] << 4) + flip_table[byte >> 4]);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1571 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1572 }
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1573
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1574 /* if we want a mask invert the bits */
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1575 if (!mask)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1576 {
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1577 new_offset = &new_data[height * new_width];
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1578 while (new_offset-- != new_data)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1579 {
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1580 *new_offset ^= 0xff;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1581 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1582 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1583
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1584 bmp_info->bmiHeader.biWidth=width;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1585 bmp_info->bmiHeader.biHeight=-height;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1586 bmp_info->bmiHeader.biPlanes=1;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1587 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1588 bmp_info->bmiHeader.biBitCount=1;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1589 bmp_info->bmiHeader.biCompression=BI_RGB;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1590 bmp_info->bmiHeader.biClrUsed = 2;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1591 bmp_info->bmiHeader.biClrImportant = 2;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1592 bmp_info->bmiHeader.biSizeImage = height * new_width;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1593 bmp_info->bmiColors[0].rgbRed = GetRValue (fg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1594 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1595 bmp_info->bmiColors[0].rgbBlue = GetBValue (fg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1596 bmp_info->bmiColors[0].rgbReserved = 0;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1597 bmp_info->bmiColors[1].rgbRed = GetRValue (bg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1598 bmp_info->bmiColors[1].rgbGreen = GetGValue (bg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1599 bmp_info->bmiColors[1].rgbBlue = GetBValue (bg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1600 bmp_info->bmiColors[1].rgbReserved = 0;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1601
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1602 bitmap = CreateDIBSection (hdc,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1603 bmp_info,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1604 DIB_RGB_COLORS,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1605 &bmp_buf,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1606 0,0);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1607
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1608 xfree (bmp_info);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1609
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1610 if (!bitmap || !bmp_buf)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1611 {
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1612 xfree (new_data);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1613 return NULL;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1614 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1615
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1616 /* copy in the actual bitmap */
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1617 memcpy (bmp_buf, new_data, height * new_width);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1618 xfree (new_data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1619
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1620 return bitmap;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1621 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1622
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1623 /* Given inline data for a mono pixmap, initialize the given
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1624 image instance accordingly. */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1625
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1626 static void
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1627 init_image_instance_from_xbm_inline (struct Lisp_Image_Instance *ii,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1628 int width, int height,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1629 /* Note that data is in ext-format! */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1630 CONST char *bits,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1631 Lisp_Object instantiator,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1632 Lisp_Object pointer_fg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1633 Lisp_Object pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1634 int dest_mask,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1635 HBITMAP mask,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1636 Lisp_Object mask_filename)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1637 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1638 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1639 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (device)));
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1640 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1641 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1642 enum image_instance_type type;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1643 COLORREF black = PALETTERGB (0,0,0);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1644 COLORREF white = PALETTERGB (255,255,255);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1645
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1646 HDC hdc = FRAME_MSWINDOWS_CDC (f);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1647
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1648 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1649 signal_simple_error ("Not an MS-Windows device", device);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1650
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1651 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) &&
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1652 (dest_mask & IMAGE_COLOR_PIXMAP_MASK))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1653 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1654 if (!NILP (foreground) || !NILP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1655 type = IMAGE_COLOR_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1656 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1657 type = IMAGE_MONO_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1658 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1659 else if (dest_mask & IMAGE_MONO_PIXMAP_MASK)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1660 type = IMAGE_MONO_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1661 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1662 type = IMAGE_COLOR_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1663 else if (dest_mask & IMAGE_POINTER_MASK)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1664 type = IMAGE_POINTER;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1665 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1666 incompatible_image_types (instantiator, dest_mask,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1667 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1668 | IMAGE_POINTER_MASK);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1669
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1670 mswindows_initialize_dibitmap_image_instance (ii, type);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1671
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1672 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1673 find_keyword_in_vector (instantiator, Q_file);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1674 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1675 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1676 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1677 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1678 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1679 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask :
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1680 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1681 TRUE, black, white);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1682
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1683 switch (type)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1684 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1685 case IMAGE_MONO_PIXMAP:
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1686 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1687 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1688 FALSE, black, black);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1689 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1690
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1691 case IMAGE_COLOR_PIXMAP:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1692 {
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1693 COLORREF fg = black;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1694 COLORREF bg = white;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1695
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1696 if (!NILP (foreground) && !COLOR_INSTANCEP (foreground))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1697 foreground =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1698 Fmake_color_instance (foreground, device,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1699 encode_error_behavior_flag (ERROR_ME));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1700
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1701 if (COLOR_INSTANCEP (foreground))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1702 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1703
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1704 if (!NILP (background) && !COLOR_INSTANCEP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1705 background =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1706 Fmake_color_instance (background, device,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1707 encode_error_behavior_flag (ERROR_ME));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1708
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1709 if (COLOR_INSTANCEP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1710 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1711
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1712 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1713 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1714
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1715 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1716 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1717 FALSE, fg, black);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1718 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1719 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1720
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1721 case IMAGE_POINTER:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1722 {
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1723 COLORREF fg = black;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1724 COLORREF bg = white;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1725
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1726 if (NILP (foreground))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1727 foreground = pointer_fg;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1728 if (NILP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1729 background = pointer_bg;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1730
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 357
diff changeset
1731 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii),
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 357
diff changeset
1732 find_keyword_in_vector (instantiator, Q_hotspot_x));
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 357
diff changeset
1733 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii),
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 357
diff changeset
1734 find_keyword_in_vector (instantiator, Q_hotspot_y));
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1735 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1736 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1737 if (COLOR_INSTANCEP (foreground))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1738 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1739 if (COLOR_INSTANCEP (background))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1740 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1741
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1742 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1743 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1744 TRUE, fg, black);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1745 mswindows_initialize_image_instance_icon (ii, TRUE);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1746 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1747 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1748
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1749 default:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1750 abort ();
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1751 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1752 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1753
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1754 static void
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1755 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1756 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1757 int dest_mask, int width, int height,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1758 /* Note that data is in ext-format! */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1759 CONST char *bits)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1760 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1761 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1762 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1763 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1764 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1765 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii))));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1766 HDC hdc = FRAME_MSWINDOWS_CDC (f);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1767 HBITMAP mask = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1768 CONST char *gcc_may_you_rot_in_hell;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1769
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1770 if (!NILP (mask_data))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1771 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1772 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (mask_data))),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1773 gcc_may_you_rot_in_hell);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1774 mask =
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1775 xbm_create_bitmap_from_data ( hdc,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1776 (unsigned char *)
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1777 gcc_may_you_rot_in_hell,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1778 XINT (XCAR (mask_data)),
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1779 XINT (XCAR (XCDR (mask_data))), FALSE,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1780 PALETTERGB (0,0,0),
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1781 PALETTERGB (255,255,255));
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1782 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1783
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1784 init_image_instance_from_xbm_inline (ii, width, height, bits,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1785 instantiator, pointer_fg, pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1786 dest_mask, mask, mask_file);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1787 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1788
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1789 /* Instantiate method for XBM's. */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1790
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1791 static void
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1792 mswindows_xbm_instantiate (Lisp_Object image_instance,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1793 Lisp_Object instantiator,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1794 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1795 int dest_mask, Lisp_Object domain)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1796 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1797 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1798 CONST char *gcc_go_home;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1799
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1800 assert (!NILP (data));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1801
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1802 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (data))),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1803 gcc_go_home);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1804
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1805 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1806 pointer_bg, dest_mask, XINT (XCAR (data)),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1807 XINT (XCAR (XCDR (data))), gcc_go_home);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1808 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1809
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1810
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1811 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1812 /* image instance methods */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1813 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1814
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1815 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1816 mswindows_print_image_instance (struct Lisp_Image_Instance *p,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1817 Lisp_Object printcharfun,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1818 int escapeflag)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1819 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1820 char buf[100];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1821
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1822 switch (IMAGE_INSTANCE_TYPE (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1823 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1824 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1825 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1826 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1827 sprintf (buf, " (0x%lx",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1828 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1829 write_c_string (buf, printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1830 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1831 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1832 sprintf (buf, "/0x%lx",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1833 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1834 write_c_string (buf, printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1835 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1836 write_c_string (")", printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1837 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1838 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1839 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1840 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1841 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1842
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1843 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1844 mswindows_finalize_image_instance (struct Lisp_Image_Instance *p)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1845 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1846 if (!p->data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1847 return;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1848
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1849 if (DEVICE_LIVE_P (XDEVICE (p->device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1850 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1851 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p))
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
1852 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1853 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p) = 0;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1854 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1855 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p));
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1856 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1857 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1858 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p));
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1859 IMAGE_INSTANCE_MSWINDOWS_ICON (p) = 0;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1860 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1861
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1862 xfree (p->data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1863 p->data = 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1864 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1865
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1866 static int
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1867 mswindows_image_instance_equal (struct Lisp_Image_Instance *p1,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1868 struct Lisp_Image_Instance *p2, int depth)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1869 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1870 switch (IMAGE_INSTANCE_TYPE (p1))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1871 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1872 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1873 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1874 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1875 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1876 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1877 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1878 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1879 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1880 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1881 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1882
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1883 return 1;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1884 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1885
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1886 static unsigned long
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1887 mswindows_image_instance_hash (struct Lisp_Image_Instance *p, int depth)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1888 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1889 switch (IMAGE_INSTANCE_TYPE (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1890 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1891 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1892 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1893 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1894 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1895 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1896 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1897 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1898 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1899
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1900 /* Set all the slots in an image instance structure to reasonable
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1901 default values. This is used somewhere within an instantiate
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1902 method. It is assumed that the device slot within the image
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1903 instance is already set -- this is the case when instantiate
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1904 methods are called. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1905
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1906 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1907 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1908 enum image_instance_type type)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1909 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1910 ii->data = xnew_and_zero (struct mswindows_image_instance_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1911 IMAGE_INSTANCE_TYPE (ii) = type;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1912 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1913 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1914 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1915 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1916 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1917 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1918 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1919
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1920
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1921 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1922 /* initialization */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1923 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1924
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1925 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1926 syms_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1927 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1928 defkeyword (&Q_resource_id, ":resource-id");
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1929 defkeyword (&Q_resource_type, ":resource-type");
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1930 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1931
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1932 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1933 console_type_create_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1934 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1935 /* image methods */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1936
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1937 CONSOLE_HAS_METHOD (mswindows, print_image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1938 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1939 CONSOLE_HAS_METHOD (mswindows, image_instance_equal);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1940 CONSOLE_HAS_METHOD (mswindows, image_instance_hash);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1941 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1942 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file);
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
1943 #ifdef HAVE_XPM
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
1944 CONSOLE_HAS_METHOD (mswindows, xpm_instantiate);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
1945 #endif
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1946 CONSOLE_HAS_METHOD (mswindows, xbm_instantiate);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1947 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1948
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1949 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1950 image_instantiator_format_create_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1951 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1952 /* image-instantiator types */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1953
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1954 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp");
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1955
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1956 IIFORMAT_HAS_METHOD (bmp, validate);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1957 IIFORMAT_HAS_METHOD (bmp, normalize);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1958 IIFORMAT_HAS_METHOD (bmp, possible_dest_types);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1959 IIFORMAT_HAS_METHOD (bmp, instantiate);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1960
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1961 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1962 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1963
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1964 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource,
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1965 "mswindows-resource");
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1966
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1967 IIFORMAT_HAS_METHOD (mswindows_resource, validate);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1968 IIFORMAT_HAS_METHOD (mswindows_resource, normalize);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1969 IIFORMAT_HAS_METHOD (mswindows_resource, possible_dest_types);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1970 IIFORMAT_HAS_METHOD (mswindows_resource, instantiate);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1971
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1972 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type,
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1973 check_valid_resource_symbol);
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1974 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1975 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1976 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1977
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1978 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1979 vars_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1980 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1981 Fprovide (Qbmp);
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1982 Fprovide (Qmswindows_resource);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1983 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /*
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1984 A list of the directories in which mswindows bitmap files may be found.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1985 This is used by the `make-image-instance' function.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1986 */ );
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1987 Vmswindows_bitmap_file_path = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1988 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1989
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1990 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1991 complex_vars_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1992 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1993 }