annotate src/glyphs-msw.c @ 331:c9ae480b1fff r21-0-63

Import from CVS: tag r21-0-63
author cvs
date Mon, 13 Aug 2007 10:49:07 +0200
parents f2b5d7006b0a
children 4711e16a8e49
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 {
308
33bdb3d4b97f Import from CVS: tag r21-0b52
cvs
parents: 304
diff changeset
524 DeleteObject (newbmp);
33bdb3d4b97f Import from CVS: tag r21-0b52
cvs
parents: 304
diff changeset
525 DeleteDC (hdcDst);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
526 return 0;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
527 }
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
528
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
529 SelectObject (hdcDst, old2);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
530 SelectObject (hcdc, old1);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
531 DeleteDC (hdcDst);
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 return newbmp;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
534 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
535
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
536 HBITMAP
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
537 mswindows_create_resized_mask (struct Lisp_Image_Instance* ii,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
538 struct frame* f,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
539 int newx, int newy)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
540 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
541 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
542 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
543 HBITMAP newmask;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
544 HGDIOBJ old1, old2;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
545 HDC hcdc = FRAME_MSWINDOWS_CDC (f);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
546 HDC hdcDst = CreateCompatibleDC (hcdc);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
547
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
548 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
549 newmask = CreateCompatibleBitmap(hcdc, newx, newy);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
550 old2 = SelectObject (hdcDst, newmask);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
551
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
552 if (!StretchBlt(hdcDst, 0, 0, newx, newy,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
553 hcdc, 0, 0,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
554 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
555 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
556 SRCCOPY))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
557 {
308
33bdb3d4b97f Import from CVS: tag r21-0b52
cvs
parents: 304
diff changeset
558 DeleteObject (newmask);
33bdb3d4b97f Import from CVS: tag r21-0b52
cvs
parents: 304
diff changeset
559 DeleteDC (hdcDst);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
560 return NULL;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
561 }
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
562
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
563 SelectObject (hdcDst, old2);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
564 SelectObject (hcdc, old1);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
565
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
566 DeleteDC (hdcDst);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
567
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
568 return newmask;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
569 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
570
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
571 return NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
572 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
573
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
574 int
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
575 mswindows_resize_dibitmap_instance (struct Lisp_Image_Instance* ii,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
576 struct frame* f,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
577 int newx, int newy)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
578 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
579 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
580 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
581
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
582 if (!newbmp)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
583 return FALSE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
584
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
585 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
586 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
587 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
588 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
589
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
590 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = newbmp;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
591 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = newmask;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
592 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
593 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
594
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
595 return TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
596 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
597
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
598 /**********************************************************************
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
599 * XPM *
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
600 **********************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
601
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
602 #ifdef HAVE_XPM
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
603
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
604 struct color_symbol
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 char* name;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
607 COLORREF color;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
608 };
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
609
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
610 static struct color_symbol*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
611 extract_xpm_color_names (Lisp_Object device,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
612 Lisp_Object domain,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
613 Lisp_Object color_symbol_alist,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
614 int* nsymbols)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
615 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
616 /* This function can GC */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
617 Lisp_Object rest;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
618 Lisp_Object results = Qnil;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
619 int i, j;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
620 struct color_symbol *colortbl;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
621 struct gcpro gcpro1, gcpro2;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
622
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
623 GCPRO2 (results, device);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
624
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
625 /* We built up results to be (("name" . #<color>) ...) so that if an
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
626 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
627 leave any pixels allocated in the server. */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
628 i = 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
629 LIST_LOOP (rest, color_symbol_alist)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
630 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
631 Lisp_Object cons = XCAR (rest);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
632 Lisp_Object name = XCAR (cons);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
633 Lisp_Object value = XCDR (cons);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
634 if (NILP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
635 continue;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
636 if (STRINGP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
637 value =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
638 Fmake_color_instance
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
639 (value, device, encode_error_behavior_flag (ERROR_ME_NOT));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
640 else
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
641 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
642 assert (COLOR_SPECIFIERP (value));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
643 value = Fspecifier_instance (value, domain, Qnil, Qnil);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
644 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
645 if (NILP (value))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
646 continue;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
647 results = noseeum_cons (noseeum_cons (name, value), results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
648 i++;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
649 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
650 UNGCPRO; /* no more evaluation */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
651
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
652 *nsymbols=i;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
653 if (i == 0) return 0;
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 colortbl = xnew_array_and_zero (struct color_symbol, i);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
656
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
657 for (j=0; j<i; j++)
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 Lisp_Object cons = XCAR (results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
660 colortbl[j].color =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
661 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
662
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
663 colortbl[j].name = (char *) XSTRING_DATA (XCAR (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
664 free_cons (XCONS (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
665 cons = results;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
666 results = XCDR (results);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
667 free_cons (XCONS (cons));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
668 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
669 return colortbl;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
670 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
671
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
672 static int xpm_to_eimage (Lisp_Object image, CONST Extbyte *buffer,
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
673 unsigned char** data,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
674 int* width, int* height,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
675 int* x_hot, int* y_hot,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
676 int* transp,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
677 struct color_symbol* color_symbols,
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
678 int nsymbols)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
679 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
680 XpmImage xpmimage;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
681 XpmInfo xpminfo;
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
682 int result, i, j, transp_idx, maskbpline;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
683 unsigned char* dptr;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
684 unsigned int* sptr;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
685 COLORREF color; /* the american spelling virus hits again .. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
686 COLORREF* colortbl;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
687
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
688 xzero (xpmimage);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
689 xzero (xpminfo);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
690 xpminfo.valuemask=XpmHotspot;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
691 *transp=FALSE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
692
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
693 result = XpmCreateXpmImageFromBuffer ((char*)buffer,
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
694 &xpmimage,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
695 &xpminfo);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
696 switch (result)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
697 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
698 case XpmSuccess:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
699 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
700 case XpmFileInvalid:
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_simple_error ("invalid XPM data", image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
703 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
704 case XpmNoMemory:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
705 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
706 signal_double_file_error ("Parsing pixmap data",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
707 "out of memory", image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
708 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
709 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
710 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
711 signal_double_file_error_2 ("Parsing pixmap data",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
712 "unknown error code",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
713 make_int (result), image);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
714 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
715 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
716
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
717 *width = xpmimage.width;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
718 *height = xpmimage.height;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
719 maskbpline = BPLINE (((~7UL & (unsigned long)(*width + 7)) / 8));
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
720
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
721 *data = xnew_array_and_zero (unsigned char, *width * *height * 3);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
722
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
723 if (!*data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
724 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
725 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
726 XpmFreeXpmInfo (&xpminfo);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
727 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
728 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
729
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
730 /* build a color table to speed things up */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
731 colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
732 if (!colortbl)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
733 {
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
734 xfree (*data);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
735 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
736 XpmFreeXpmInfo (&xpminfo);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
737 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
738 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
739
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
740 for (i=0; i<xpmimage.ncolors; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
741 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
742 /* goto alert!!!! */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
743 /* pick up symbolic colors in preference */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
744 if (xpmimage.colorTable[i].symbolic)
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 if (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor")
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
747 ||
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
748 !strcasecmp (xpmimage.colorTable[i].symbolic,"None"))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
749 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
750 *transp=TRUE;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
751 colortbl[i]=transparent_color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
752 transp_idx=i;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
753 goto label_found_color;
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 else if (color_symbols)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
756 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
757 for (j = 0; j<nsymbols; j++)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
758 {
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
759 if (!strcmp (xpmimage.colorTable[i].symbolic,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
760 color_symbols[j].name ))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
761 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
762 colortbl[i]=color_symbols[j].color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
763 goto label_found_color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
764 }
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
765 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
766 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
767 else if (xpmimage.colorTable[i].c_color == 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
768 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
769 goto label_no_color;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
770 }
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
771 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
772 /* pick up transparencies */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
773 if (!strcasecmp (xpmimage.colorTable[i].c_color,"None"))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
774 {
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
775 *transp=TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
776 colortbl[i]=transparent_color;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
777 transp_idx=i;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
778 goto label_found_color;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
779 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
780 /* finally pick up a normal color spec */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
781 if (xpmimage.colorTable[i].c_color)
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
782 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
783 colortbl[i]=
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
784 mswindows_string_to_color (xpmimage.colorTable[i].c_color);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
785 goto label_found_color;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
786 }
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
787
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
788 label_no_color:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
789 xfree (*data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
790 xfree (colortbl);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
791 XpmFreeXpmImage (&xpmimage);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
792 XpmFreeXpmInfo (&xpminfo);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
793 return 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
794
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
795 label_found_color:;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
796 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
797
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
798 /* convert the image */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
799 sptr=xpmimage.data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
800 dptr=*data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
801 for (i = 0; i< *width * *height; i++)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
802 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
803 color = colortbl[*sptr++];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
804
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
805 /* split out the 0x02bbggrr colorref into an rgb triple */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
806 *dptr++=GetRValue (color); /* red */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
807 *dptr++=GetGValue (color); /* green */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
808 *dptr++=GetBValue (color); /* blue */
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
809 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
810
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
811 *x_hot=xpminfo.x_hotspot;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
812 *y_hot=xpminfo.y_hotspot;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
813
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
814 XpmFreeXpmImage (&xpmimage);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
815 XpmFreeXpmInfo (&xpminfo);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
816 xfree (colortbl);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
817 return TRUE;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
818 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
819
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
820 static void
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
821 mswindows_xpm_instantiate (Lisp_Object image_instance,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
822 Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
823 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
824 int dest_mask, Lisp_Object domain)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
825 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
826 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
827 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
828 CONST Extbyte *bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
829 Extcount len;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
830 unsigned char *eimage;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
831 int width, height, x_hot, y_hot;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
832 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
833 unsigned char* bmp_data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
834 int bmp_bits;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
835 int nsymbols=0, transp;
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
836 struct color_symbol* color_symbols=NULL;
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 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
839 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
840 Q_color_symbols);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
841
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
842 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
843 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
844
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
845 assert (!NILP (data));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
846
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
847 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
848
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
849 /* in case we have color symbols */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
850 color_symbols = extract_xpm_color_names (device, domain,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
851 color_symbol_alist, &nsymbols);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
852
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
853 /* convert to an eimage to make processing easier */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
854 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
855 &x_hot, &y_hot, &transp, color_symbols, nsymbols))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
856 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
857 signal_simple_error ("XPM to EImage conversion failed",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
858 image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
859 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
860
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
861 if (color_symbols)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
862 xfree(color_symbols);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
863
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
864 /* build a bitmap from the eimage */
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
865 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
866 &bmp_bits, &bmp_data)))
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
867 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
868 signal_simple_error ("XPM to EImage conversion failed",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
869 image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
870 }
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
871 xfree (eimage);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
872
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
873 /* Now create the pixmap and set up the image instance */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
874 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
875 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
876 x_hot, y_hot, transp);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
877
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
878 xfree (bmp_info);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
879 xfree (bmp_data);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
880 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
881 #endif /* HAVE_XPM */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
882
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
883 /**********************************************************************
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
884 * BMP *
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
885 **********************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
886
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
887 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
888 bmp_validate (Lisp_Object instantiator)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
889 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
890 file_or_data_must_be_present (instantiator);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
891 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
892
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
893 static Lisp_Object
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
894 bmp_normalize (Lisp_Object inst, Lisp_Object console_type)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
895 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
896 return simple_image_type_normalize (inst, console_type, Qbmp);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
897 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
898
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
899 static int
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
900 bmp_possible_dest_types (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
901 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
902 return IMAGE_COLOR_PIXMAP_MASK;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
903 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
904
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
905 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
906 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
907 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
908 int dest_mask, Lisp_Object domain)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
909 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
910 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
911 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
912 CONST Extbyte *bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
913 Extcount len;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
914 BITMAPFILEHEADER* bmp_file_header;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
915 BITMAPINFO* bmp_info;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
916 void* bmp_data;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
917 int bmp_bits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
918 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
919
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
920 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
921 signal_simple_error ("Not an mswindows device", device);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
922
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
923 assert (!NILP (data));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
924
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
925 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
926
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
927 /* Then slurp the image into memory, decoding along the way.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
928 The result is the image in a simple one-byte-per-pixel
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
929 format. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
930
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
931 bmp_file_header=(BITMAPFILEHEADER*)bytes;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
932 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
933 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
934 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
935
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
936 /* Now create the pixmap and set up the image instance */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
937 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
938 bmp_data, bmp_bits, instantiator,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
939 0, 0, 0);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
940 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
941
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
942
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
943 /**********************************************************************
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
944 * RESOURCES *
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
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
947 static void
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
948 mswindows_resource_validate (Lisp_Object instantiator)
284
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 if ((NILP (find_keyword_in_vector (instantiator, Q_file))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
951 &&
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
952 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
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 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
955 signal_simple_error ("Must supply :file, :resource-id and :resource-type",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
956 instantiator);
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
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
959 static Lisp_Object
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
960 mswindows_resource_normalize (Lisp_Object inst, Lisp_Object console_type)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
961 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
962 /* This function can call lisp */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
963 Lisp_Object file = Qnil;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
964 struct gcpro gcpro1, gcpro2;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
965 Lisp_Object alist = Qnil;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
966
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
967 GCPRO2 (file, alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
968
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
969 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
970 console_type);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
971
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
972 if (CONSP (file)) /* failure locating filename */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
973 signal_double_file_error ("Opening pixmap file",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
974 "no such file or directory",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
975 Fcar (file));
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
976
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
977 if (NILP (file)) /* no conversion necessary */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
978 RETURN_UNGCPRO (inst);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
979
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
980 alist = tagged_vector_to_alist (inst);
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 alist = remassq_no_quit (Q_file, alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
984 alist = Fcons (Fcons (Q_file, file), alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
985 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
986
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
987 {
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
988 Lisp_Object result = alist_to_tagged_vector (Qmswindows_resource, alist);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
989 free_alist (alist);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
990 RETURN_UNGCPRO (result);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
991 }
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
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
994 static int
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
995 mswindows_resource_possible_dest_types (void)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
996 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
997 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
998 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
999
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1000 typedef struct
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 char *name;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1003 int resource_id;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1004 } resource_t;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1005
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1006 #ifndef OCR_ICOCUR
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1007 #define OCR_ICOCUR 32647
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1008 #define OIC_SAMPLE 32512
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1009 #define OIC_HAND 32513
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1010 #define OIC_QUES 32514
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1011 #define OIC_BANG 32515
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1012 #define OIC_NOTE 32516
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1013 #define OIC_WINLOGO 32517
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1014 #define LR_SHARED 0x8000
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1015 #endif
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1016
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1017 static CONST resource_t bitmap_table[] =
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1018 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1019 /* bitmaps */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1020 { "close", OBM_CLOSE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1021 { "uparrow", OBM_UPARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1022 { "dnarrow", OBM_DNARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1023 { "rgarrow", OBM_RGARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1024 { "lfarrow", OBM_LFARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1025 { "reduce", OBM_REDUCE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1026 { "zoom", OBM_ZOOM },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1027 { "restore", OBM_RESTORE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1028 { "reduced", OBM_REDUCED },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1029 { "zoomd", OBM_ZOOMD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1030 { "restored", OBM_RESTORED },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1031 { "uparrowd", OBM_UPARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1032 { "dnarrowd", OBM_DNARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1033 { "rgarrowd", OBM_RGARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1034 { "lfarrowd", OBM_LFARROWD },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1035 { "mnarrow", OBM_MNARROW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1036 { "combo", OBM_COMBO },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1037 { "uparrowi", OBM_UPARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1038 { "dnarrowi", OBM_DNARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1039 { "rgarrowi", OBM_RGARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1040 { "lfarrowi", OBM_LFARROWI },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1041 { "size", OBM_SIZE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1042 { "btsize", OBM_BTSIZE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1043 { "check", OBM_CHECK },
321
19dcec799385 Import from CVS: tag r21-0-58
cvs
parents: 308
diff changeset
1044 { "checkboxes", OBM_CHECKBOXES },
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1045 { "btncorners" , OBM_BTNCORNERS },
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1046 {0}
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1047 };
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1048
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1049 static CONST resource_t cursor_table[] =
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1050 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1051 /* cursors */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1052 { "normal", OCR_NORMAL },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1053 { "ibeam", OCR_IBEAM },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1054 { "wait", OCR_WAIT },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1055 { "cross", OCR_CROSS },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1056 { "up", OCR_UP },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1057 /* { "icon", OCR_ICON }, */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1058 { "sizenwse", OCR_SIZENWSE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1059 { "sizenesw", OCR_SIZENESW },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1060 { "sizewe", OCR_SIZEWE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1061 { "sizens", OCR_SIZENS },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1062 { "sizeall", OCR_SIZEALL },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1063 /* { "icour", OCR_ICOCUR }, */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1064 { "no", OCR_NO },
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1065 { 0 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1066 };
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1067
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1068 static CONST resource_t icon_table[] =
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1069 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1070 /* icons */
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1071 { "sample", OIC_SAMPLE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1072 { "hand", OIC_HAND },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1073 { "ques", OIC_QUES },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1074 { "bang", OIC_BANG },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1075 { "note", OIC_NOTE },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1076 { "winlogo", OIC_WINLOGO },
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1077 {0}
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1078 };
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1079
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1080 static int resource_name_to_resource (Lisp_Object name, int type)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1081 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1082 CONST resource_t* res = (type == IMAGE_CURSOR ? cursor_table
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1083 : type == IMAGE_ICON ? icon_table
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1084 : bitmap_table);
284
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 if (INTP (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 return XINT (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 else if (!STRINGP (name))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1091 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1092 signal_simple_error ("invalid resource identifier", name);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1093 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1094
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1095 do {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1096 if (!strcasecmp ((char*)res->name, XSTRING_DATA (name)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1097 return res->resource_id;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1098 } while ((++res)->name);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1099 return 0;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1100 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1101
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1102 static int
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1103 resource_symbol_to_type (Lisp_Object data)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1104 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1105 if (EQ (data, Qcursor))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1106 return IMAGE_CURSOR;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1107 else if (EQ (data, Qicon))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1108 return IMAGE_ICON;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1109 else if (EQ (data, Qbitmap))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1110 return IMAGE_BITMAP;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1111 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1112 return 0;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1113 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1114
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1115 static void
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1116 mswindows_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1117 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1118 int dest_mask, Lisp_Object domain)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1119 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1120 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1121 unsigned int type = 0;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1122 HANDLE himage = NULL;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1123 LPCTSTR resid=0;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1124 HINSTANCE hinst = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1125 ICONINFO iconinfo;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1126 int iitype=0;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1127 char* fname=0;
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1128 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1129
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1130 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1131 Lisp_Object resource_type = find_keyword_in_vector (instantiator,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1132 Q_resource_type);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1133 Lisp_Object resource_id = find_keyword_in_vector (instantiator,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1134 Q_resource_id);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1135
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1136 xzero (iconinfo);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1137
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1138 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1139 signal_simple_error ("Not an mswindows device", device);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1140
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1141 type = resource_symbol_to_type (resource_type);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1142
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1143 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1144 iitype = IMAGE_POINTER;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1145 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1146 iitype = IMAGE_COLOR_PIXMAP;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1147 else
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1148 incompatible_image_types (instantiator, dest_mask,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1149 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1150
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1151 /* mess with the keyword info we were provided with */
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1152 if (!NILP (file))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1153 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1154 #ifdef __CYGWIN32__
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1155 CYGWIN_WIN32_PATH (XSTRING_DATA (file), fname);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1156 #else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1157 /* #### FIXME someone who knows ... */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1158 fname = XSTRING_DATA (file);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1159 #endif
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 if (NILP (resource_id))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1162 resid = (LPCTSTR)fname;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1163 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1164 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1165 hinst = LoadLibraryEx (fname, NULL,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1166 LOAD_LIBRARY_AS_DATAFILE);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1167 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1168 type));
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 if (!resid)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1171 resid = XSTRING_DATA (resource_id);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1172 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1173 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1174 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1175 type))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1176 signal_simple_error ("invalid resource identifier", resource_id);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1177
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1178 /* load the image */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1179 if (!(himage = LoadImage (hinst, resid, type, 0, 0,
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1180 LR_CREATEDIBSECTION | LR_DEFAULTSIZE |
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1181 LR_SHARED |
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1182 (!NILP (file) ? LR_LOADFROMFILE : 0))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1183 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1184 signal_simple_error ("cannot load image", instantiator);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1185 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1186
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1187 if (hinst)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1188 FreeLibrary (hinst);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1189
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1190 mswindows_initialize_dibitmap_image_instance (ii, iitype);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1191
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1192 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1193 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) =
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1194 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1195 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) =
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1196 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1197 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
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 /* 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
1200 bitmap and mask */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1201 if (type != IMAGE_BITMAP)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1202 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1203 GetIconInfo (himage, &iconinfo);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1204 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1205 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1206 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1207 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1208 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = himage;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1209 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1210 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1211 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1212 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1213 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = himage;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1214 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1215 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1216 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1217 }
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
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1220 static void
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1221 check_valid_resource_symbol (Lisp_Object data)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1222 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1223 CHECK_SYMBOL (data);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1224 if (!resource_symbol_to_type (data))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1225 signal_simple_error ("invalid resource type", 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
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1228 static void
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1229 check_valid_resource_id (Lisp_Object data)
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 if (!resource_name_to_resource (data, IMAGE_CURSOR)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1232 &&
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1233 !resource_name_to_resource (data, IMAGE_ICON)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1234 &&
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1235 !resource_name_to_resource (data, IMAGE_BITMAP))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1236 signal_simple_error ("invalid resource identifier", data);
284
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
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1239 void
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1240 check_valid_string_or_int (Lisp_Object data)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1241 {
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1242 if (!INTP (data))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1243 CHECK_STRING (data);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1244 else
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1245 CHECK_INT (data);
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1246 }
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1247
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1248 /**********************************************************************
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1249 * XBM *
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 #ifndef HAVE_X_WINDOWS
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1252 /* $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
1253
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1254 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1255
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1256 Copyright (c) 1988 X Consortium
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1257
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1258 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
1259 of this software and associated documentation files (the "Software"), to deal
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1260 in the Software without restriction, including without limitation the rights
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1261 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1262 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
1263 furnished to do so, subject to the following conditions:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1264
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1265 The above copyright notice and this permission notice shall be included in
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1266 all copies or substantial portions of the Software.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1267
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1268 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
1269 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1270 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1271 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
1272 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
1273 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
1274
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1275 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
1276 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
1277 in this Software without prior written authorization from the X Consortium.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1278
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1279 */
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 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1282 * This file contains miscellaneous utility routines and is not part of the
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1283 * Xlib standard.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1284 *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1285 * Public entry points:
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 * XmuReadBitmapData read data from FILE descriptor
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1288 * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1289 * and return data
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 * 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
1292 * 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
1293 * without the other).
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1294 */
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
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1297 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1298 * Based on an optimized version provided by Jim Becker, Auguest 5, 1988.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1299 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1300 #ifndef BitmapSuccess
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1301 #define BitmapSuccess 0
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1302 #define BitmapOpenFailed 1
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1303 #define BitmapFileInvalid 2
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1304 #define BitmapNoMemory 3
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1305 #endif
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1306 #define MAX_SIZE 255
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 /* shared data for the image read/parse logic */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1309 static short hexTable[256]; /* conversion value */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1310 static int initialized = FALSE; /* easier to fill in at run time */
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 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1313 * Table index for the hex values. Initialized once, first time.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1314 * Used for translation value or delimiter significance lookup.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1315 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1316 static void initHexTable()
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1317 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1318 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1319 * We build the table at run time for several reasons:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1320 *
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1321 * 1. portable to non-ASCII machines.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1322 * 2. still reentrant since we set the init flag after setting table.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1323 * 3. easier to extend.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1324 * 4. less prone to bugs.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1325 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1326 hexTable['0'] = 0; hexTable['1'] = 1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1327 hexTable['2'] = 2; hexTable['3'] = 3;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1328 hexTable['4'] = 4; hexTable['5'] = 5;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1329 hexTable['6'] = 6; hexTable['7'] = 7;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1330 hexTable['8'] = 8; hexTable['9'] = 9;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1331 hexTable['A'] = 10; hexTable['B'] = 11;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1332 hexTable['C'] = 12; hexTable['D'] = 13;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1333 hexTable['E'] = 14; hexTable['F'] = 15;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1334 hexTable['a'] = 10; hexTable['b'] = 11;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1335 hexTable['c'] = 12; hexTable['d'] = 13;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1336 hexTable['e'] = 14; hexTable['f'] = 15;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1337
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1338 /* delimiters of significance are flagged w/ negative value */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1339 hexTable[' '] = -1; hexTable[','] = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1340 hexTable['}'] = -1; hexTable['\n'] = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1341 hexTable['\t'] = -1;
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 initialized = TRUE;
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
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 * read next hex value in the input stream, return -1 if EOF
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1348 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1349 static int NextInt ( FILE *fstream )
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1350 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1351 int ch;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1352 int value = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1353 int gotone = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1354 int done = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1355
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1356 /* loop, accumulate hex value until find delimiter */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1357 /* skip any initial delimiters found in read stream */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1358
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1359 while (!done) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1360 ch = getc(fstream);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1361 if (ch == EOF) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1362 value = -1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1363 done++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1364 } else {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1365 /* trim high bits, check type and accumulate */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1366 ch &= 0xff;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1367 if (isascii(ch) && isxdigit(ch)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1368 value = (value << 4) + hexTable[ch];
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1369 gotone++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1370 } else if ((hexTable[ch]) < 0 && gotone)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1371 done++;
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 return value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1375 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1376
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1377
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1378 /*
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1379 * 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
1380 * 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
1381 * 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
1382 * like the Xlib routine XReadBitmapfile as possible.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1383 */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1384 int read_bitmap_data (fstream, width, height, datap, x_hot, y_hot)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1385 FILE *fstream; /* handle on file */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1386 unsigned int *width, *height; /* RETURNED */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1387 unsigned char **datap; /* RETURNED */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1388 int *x_hot, *y_hot; /* RETURNED */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1389 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1390 unsigned char *data = NULL; /* working variable */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1391 char line[MAX_SIZE]; /* input line from file */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1392 int size; /* number of bytes of data */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1393 char name_and_type[MAX_SIZE]; /* an input line */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1394 char *type; /* for parsing */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1395 int value; /* from an input line */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1396 int version10p; /* boolean, old format */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1397 int padding; /* to handle alignment */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1398 int bytes_per_line; /* per scanline of data */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1399 unsigned int ww = 0; /* width */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1400 unsigned int hh = 0; /* height */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1401 int hx = -1; /* x hotspot */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1402 int hy = -1; /* y hotspot */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1403
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1404 #define Xmalloc(size) malloc(size)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1405
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1406 /* first time initialization */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1407 if (initialized == FALSE) initHexTable();
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1408
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1409 /* error cleanup and return macro */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1410 #define RETURN(code) { if (data) free (data); return code; }
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 while (fgets(line, MAX_SIZE, fstream)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1413 if (strlen(line) == MAX_SIZE-1) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1414 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1415 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1416 if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1417 if (!(type = strrchr(name_and_type, '_')))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1418 type = name_and_type;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1419 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1420 type++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1421
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1422 if (!strcmp("width", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1423 ww = (unsigned int) value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1424 if (!strcmp("height", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1425 hh = (unsigned int) value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1426 if (!strcmp("hot", type)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1427 if (type-- == name_and_type || type-- == name_and_type)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1428 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1429 if (!strcmp("x_hot", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1430 hx = value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1431 if (!strcmp("y_hot", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1432 hy = value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1433 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1434 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1435 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1436
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1437 if (sscanf(line, "static short %s = {", name_and_type) == 1)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1438 version10p = 1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1439 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1440 version10p = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1441 else if (sscanf(line, "static char %s = {", name_and_type) == 1)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1442 version10p = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1443 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1444 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1445
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1446 if (!(type = strrchr(name_and_type, '_')))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1447 type = name_and_type;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1448 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1449 type++;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1450
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1451 if (strcmp("bits[]", type))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1452 continue;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1453
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1454 if (!ww || !hh)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1455 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1456
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1457 if ((ww % 16) && ((ww % 16) < 9) && version10p)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1458 padding = 1;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1459 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1460 padding = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1461
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1462 bytes_per_line = (ww+7)/8 + padding;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1463
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1464 size = bytes_per_line * hh;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1465 data = (unsigned char *) Xmalloc ((unsigned int) size);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1466 if (!data)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1467 RETURN (BitmapNoMemory);
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 if (version10p) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1470 unsigned char *ptr;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1471 int bytes;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1472
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1473 for (bytes=0, ptr=data; bytes<size; (bytes += 2)) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1474 if ((value = NextInt(fstream)) < 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1475 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1476 *(ptr++) = value;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1477 if (!padding || ((bytes+2) % bytes_per_line))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1478 *(ptr++) = value >> 8;
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 } else {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1481 unsigned char *ptr;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1482 int bytes;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1483
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1484 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1485 if ((value = NextInt(fstream)) < 0)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1486 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1487 *ptr=value;
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 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1490 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1491 } /* end while */
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 if (data == NULL) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1494 RETURN (BitmapFileInvalid);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1495 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1496
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1497 *datap = data;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1498 data = NULL;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1499 *width = ww;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1500 *height = hh;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1501 if (x_hot) *x_hot = hx;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1502 if (y_hot) *y_hot = hy;
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 RETURN (BitmapSuccess);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1505 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1506
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 int read_bitmap_data_from_file (CONST char *filename, unsigned int *width,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1509 unsigned int *height, unsigned char **datap,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1510 int *x_hot, int *y_hot)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1511 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1512 FILE *fstream;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1513 int status;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1514
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1515 if ((fstream = fopen (filename, "r")) == NULL) {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1516 return BitmapOpenFailed;
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 status = read_bitmap_data (fstream, width, height, datap, x_hot, y_hot);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1519 fclose (fstream);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1520 return status;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1521 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1522 #endif /* HAVE_X_WINDOWS */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1523
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1524 /* this table flips four bits around. */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1525 static int flip_table[] =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1526 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1527 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
1528 };
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1529
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1530 /* the bitmap data comes in the following format: Widths are padded to
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1531 a multiple of 8. Scan lines are stored in increasing byte order
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1532 from left to right, little-endian within a byte. 0 = white, 1 =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1533 black. It must be converted to the following format: Widths are
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1534 padded to a multiple of 16. Scan lines are stored in increasing
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1535 byte order from left to right, big-endian within a byte. 0 =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1536 black, 1 = white. */
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1537 HBITMAP
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1538 xbm_create_bitmap_from_data (HDC hdc, char *data,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1539 unsigned int width, unsigned int height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1540 int mask, COLORREF fg, COLORREF bg)
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1541 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1542 int old_width = (width + 7)/8;
331
c9ae480b1fff Import from CVS: tag r21-0-63
cvs
parents: 325
diff changeset
1543 int new_width = BPLINE (2*((width + 15)/16));
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1544 unsigned char *offset;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1545 void *bmp_buf = 0;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1546 unsigned char *new_data, *new_offset;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1547 int i, j;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1548 BITMAPINFO* bmp_info =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1549 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1550 HBITMAP bitmap;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1551
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1552 if (!bmp_info)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1553 return NULL;
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 new_data = (unsigned char *) xmalloc (height * new_width);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1556
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1557 if (!new_data)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1558 {
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1559 xfree (bmp_info);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1560 return NULL;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1561 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1562
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1563 for (i=0; i<height; i++)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1564 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1565 offset = data + i*old_width;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1566 new_offset = new_data + i*new_width;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1567
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1568 new_offset[new_width - 1] = 0; /* there may be an extra byte
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1569 that needs to be padded */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1570 for (j=0; j<old_width; j++)
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 int byte = offset[j];
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1573 new_offset[j] = ~ (unsigned char)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1574 ((flip_table[byte & 0xf] << 4) + flip_table[byte >> 4]);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1575 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1576 }
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1577
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1578 /* if we want a mask invert the bits */
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1579 if (!mask)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1580 {
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1581 new_offset = &new_data[height * new_width];
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1582 while (new_offset-- != new_data)
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 *new_offset ^= 0xff;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1585 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1586 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1587
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1588 bmp_info->bmiHeader.biWidth=width;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1589 bmp_info->bmiHeader.biHeight=-height;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1590 bmp_info->bmiHeader.biPlanes=1;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1591 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1592 bmp_info->bmiHeader.biBitCount=1;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1593 bmp_info->bmiHeader.biCompression=BI_RGB;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1594 bmp_info->bmiHeader.biClrUsed = 2;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1595 bmp_info->bmiHeader.biClrImportant = 2;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1596 bmp_info->bmiHeader.biSizeImage = height * new_width;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1597 bmp_info->bmiColors[0].rgbRed = GetRValue (fg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1598 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1599 bmp_info->bmiColors[0].rgbBlue = GetBValue (fg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1600 bmp_info->bmiColors[0].rgbReserved = 0;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1601 bmp_info->bmiColors[1].rgbRed = GetRValue (bg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1602 bmp_info->bmiColors[1].rgbGreen = GetGValue (bg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1603 bmp_info->bmiColors[1].rgbBlue = GetBValue (bg);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1604 bmp_info->bmiColors[1].rgbReserved = 0;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1605
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1606 bitmap = CreateDIBSection (hdc,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1607 bmp_info,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1608 DIB_RGB_COLORS,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1609 &bmp_buf,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1610 0,0);
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 (bmp_info);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1613
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1614 if (!bitmap || !bmp_buf)
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 xfree (new_data);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1617 return NULL;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1618 }
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1619
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1620 /* copy in the actual bitmap */
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1621 memcpy (bmp_buf, new_data, height * new_width);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1622 xfree (new_data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1623
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1624 return bitmap;
288
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
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1627 /* Given inline data for a mono pixmap, initialize the given
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1628 image instance accordingly. */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1629
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1630 static void
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1631 init_image_instance_from_xbm_inline (struct Lisp_Image_Instance *ii,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1632 int width, int height,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1633 /* Note that data is in ext-format! */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1634 CONST char *bits,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1635 Lisp_Object instantiator,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1636 Lisp_Object pointer_fg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1637 Lisp_Object pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1638 int dest_mask,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1639 HBITMAP mask,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1640 Lisp_Object mask_filename)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1641 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1642 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1643 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (device)));
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1644 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1645 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1646 enum image_instance_type type;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1647 COLORREF black = PALETTERGB (0,0,0);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1648 COLORREF white = PALETTERGB (255,255,255);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1649
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1650 HDC hdc = FRAME_MSWINDOWS_CDC (f);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1651
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1652 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1653 signal_simple_error ("Not an MS-Windows device", device);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1654
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1655 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) &&
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1656 (dest_mask & IMAGE_COLOR_PIXMAP_MASK))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1657 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1658 if (!NILP (foreground) || !NILP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1659 type = IMAGE_COLOR_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1660 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1661 type = IMAGE_MONO_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1662 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1663 else if (dest_mask & IMAGE_MONO_PIXMAP_MASK)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1664 type = IMAGE_MONO_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1665 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1666 type = IMAGE_COLOR_PIXMAP;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1667 else if (dest_mask & IMAGE_POINTER_MASK)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1668 type = IMAGE_POINTER;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1669 else
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1670 incompatible_image_types (instantiator, dest_mask,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1671 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1672 | IMAGE_POINTER_MASK);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1673
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1674 mswindows_initialize_dibitmap_image_instance (ii, type);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1675
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1676 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1677 find_keyword_in_vector (instantiator, Q_file);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1678 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1679 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1680 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1681 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1682 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1683 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask :
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1684 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1685 TRUE, black, white);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1686
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1687 switch (type)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1688 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1689 case IMAGE_MONO_PIXMAP:
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1690 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1691 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1692 FALSE, black, black);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1693 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1694
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1695 case IMAGE_COLOR_PIXMAP:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1696 {
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1697 COLORREF fg = black;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1698 COLORREF bg = white;
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1699
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1700 if (!NILP (foreground) && !COLOR_INSTANCEP (foreground))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1701 foreground =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1702 Fmake_color_instance (foreground, device,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1703 encode_error_behavior_flag (ERROR_ME));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1704
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1705 if (COLOR_INSTANCEP (foreground))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1706 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1707
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1708 if (!NILP (background) && !COLOR_INSTANCEP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1709 background =
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1710 Fmake_color_instance (background, device,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1711 encode_error_behavior_flag (ERROR_ME));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1712
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1713 if (COLOR_INSTANCEP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1714 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1715
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1716 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1717 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1718
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1719 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1720 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1721 FALSE, fg, black);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1722 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1723 break;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1724
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1725 case IMAGE_POINTER:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1726 {
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1727 COLORREF fg = black;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1728 COLORREF bg = white;
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1729
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1730 if (NILP (foreground))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1731 foreground = pointer_fg;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1732 if (NILP (background))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1733 background = pointer_bg;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1734
325
f2b5d7006b0a Import from CVS: tag r21-0-60
cvs
parents: 321
diff changeset
1735 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) =
f2b5d7006b0a Import from CVS: tag r21-0-60
cvs
parents: 321
diff changeset
1736 find_keyword_in_vector (instantiator, Q_hotspot_x);
f2b5d7006b0a Import from CVS: tag r21-0-60
cvs
parents: 321
diff changeset
1737 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) =
f2b5d7006b0a Import from CVS: tag r21-0-60
cvs
parents: 321
diff changeset
1738 find_keyword_in_vector (instantiator, Q_hotspot_y);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1739 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1740 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1741 if (COLOR_INSTANCEP (foreground))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1742 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1743 if (COLOR_INSTANCEP (background))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1744 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1745
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1746 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1747 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1748 TRUE, fg, black);
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1749 mswindows_initialize_image_instance_icon (ii, TRUE);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1750 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1751 break;
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 default:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1754 abort ();
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1755 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1756 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1757
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1758 static void
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1759 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1760 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1761 int dest_mask, int width, int height,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1762 /* Note that data is in ext-format! */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1763 CONST char *bits)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1764 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1765 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1766 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1767 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1768 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1769 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii))));
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1770 HDC hdc = FRAME_MSWINDOWS_CDC (f);
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1771 HBITMAP mask = 0;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1772 CONST char *gcc_may_you_rot_in_hell;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1773
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1774 if (!NILP (mask_data))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1775 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1776 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (mask_data))),
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 mask =
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1779 xbm_create_bitmap_from_data ( hdc,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1780 (unsigned char *)
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1781 gcc_may_you_rot_in_hell,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1782 XINT (XCAR (mask_data)),
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1783 XINT (XCAR (XCDR (mask_data))), FALSE,
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1784 PALETTERGB (0,0,0),
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1785 PALETTERGB (255,255,255));
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1786 }
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 init_image_instance_from_xbm_inline (ii, width, height, bits,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1789 instantiator, pointer_fg, pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1790 dest_mask, mask, mask_file);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1791 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1792
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1793 /* Instantiate method for XBM's. */
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1794
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1795 static void
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1796 mswindows_xbm_instantiate (Lisp_Object image_instance,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1797 Lisp_Object instantiator,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1798 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1799 int dest_mask, Lisp_Object domain)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1800 {
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1801 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1802 CONST char *gcc_go_home;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1803
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1804 assert (!NILP (data));
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1805
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1806 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (data))),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1807 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 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1810 pointer_bg, dest_mask, XINT (XCAR (data)),
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1811 XINT (XCAR (XCDR (data))), gcc_go_home);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1812 }
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1813
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1814
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1815 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1816 /* image instance methods */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1817 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1818
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1819 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1820 mswindows_print_image_instance (struct Lisp_Image_Instance *p,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1821 Lisp_Object printcharfun,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1822 int escapeflag)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1823 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1824 char buf[100];
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1825
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1826 switch (IMAGE_INSTANCE_TYPE (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1827 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1828 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1829 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1830 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1831 sprintf (buf, " (0x%lx",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1832 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1833 write_c_string (buf, printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1834 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1835 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1836 sprintf (buf, "/0x%lx",
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1837 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p));
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1838 write_c_string (buf, printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1839 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1840 write_c_string (")", printcharfun);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1841 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1842 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1843 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1844 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1845 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1846
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1847 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1848 mswindows_finalize_image_instance (struct Lisp_Image_Instance *p)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1849 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1850 if (!p->data)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1851 return;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1852
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1853 if (DEVICE_LIVE_P (XDEVICE (p->device)))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1854 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1855 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p))
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 267
diff changeset
1856 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1857 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p) = 0;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1858 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1859 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p));
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1860 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1861 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1862 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p));
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1863 IMAGE_INSTANCE_MSWINDOWS_ICON (p) = 0;
267
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 xfree (p->data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1867 p->data = 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1868 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1869
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1870 static int
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1871 mswindows_image_instance_equal (struct Lisp_Image_Instance *p1,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1872 struct Lisp_Image_Instance *p2, int depth)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1873 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1874 switch (IMAGE_INSTANCE_TYPE (p1))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1875 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1876 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1877 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1878 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1879 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1880 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1881 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1882 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1883 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1884 break;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1885 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1886
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1887 return 1;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1888 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1889
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1890 static unsigned long
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1891 mswindows_image_instance_hash (struct Lisp_Image_Instance *p, int depth)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1892 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1893 switch (IMAGE_INSTANCE_TYPE (p))
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1894 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1895 case IMAGE_MONO_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1896 case IMAGE_COLOR_PIXMAP:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1897 case IMAGE_POINTER:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1898 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1899 default:
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1900 return 0;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1901 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1902 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1903
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1904 /* Set all the slots in an image instance structure to reasonable
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1905 default values. This is used somewhere within an instantiate
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1906 method. It is assumed that the device slot within the image
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1907 instance is already set -- this is the case when instantiate
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1908 methods are called. */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1909
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1910 static void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1911 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1912 enum image_instance_type type)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1913 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1914 ii->data = xnew_and_zero (struct mswindows_image_instance_data);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1915 IMAGE_INSTANCE_TYPE (ii) = type;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1916 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1917 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1918 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1919 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1920 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1921 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1922 }
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 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1926 /* initialization */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1927 /************************************************************************/
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1928
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1929 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1930 syms_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1931 {
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1932 defkeyword (&Q_resource_id, ":resource-id");
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1933 defkeyword (&Q_resource_type, ":resource-type");
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1934 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1935
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1936 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1937 console_type_create_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1938 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1939 /* image methods */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1940
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1941 CONSOLE_HAS_METHOD (mswindows, print_image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1942 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1943 CONSOLE_HAS_METHOD (mswindows, image_instance_equal);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1944 CONSOLE_HAS_METHOD (mswindows, image_instance_hash);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1945 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
1946 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file);
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
1947 #ifdef HAVE_XPM
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
1948 CONSOLE_HAS_METHOD (mswindows, xpm_instantiate);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
1949 #endif
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1950 CONSOLE_HAS_METHOD (mswindows, xbm_instantiate);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1951 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1952
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1953 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1954 image_instantiator_format_create_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1955 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1956 /* image-instantiator types */
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1957
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1958 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp");
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1959
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1960 IIFORMAT_HAS_METHOD (bmp, validate);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1961 IIFORMAT_HAS_METHOD (bmp, normalize);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1962 IIFORMAT_HAS_METHOD (bmp, possible_dest_types);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1963 IIFORMAT_HAS_METHOD (bmp, instantiate);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1964
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1965 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string);
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1966 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1967
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1968 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource,
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1969 "mswindows-resource");
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1970
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1971 IIFORMAT_HAS_METHOD (mswindows_resource, validate);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1972 IIFORMAT_HAS_METHOD (mswindows_resource, normalize);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1973 IIFORMAT_HAS_METHOD (mswindows_resource, possible_dest_types);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1974 IIFORMAT_HAS_METHOD (mswindows_resource, instantiate);
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1975
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1976 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type,
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1977 check_valid_resource_symbol);
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1978 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id);
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1979 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1980 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1981
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1982 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1983 vars_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1984 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1985 Fprovide (Qbmp);
304
c6de09ad3017 Import from CVS: tag r21-0b50
cvs
parents: 298
diff changeset
1986 Fprovide (Qmswindows_resource);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1987 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /*
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1988 A list of the directories in which mswindows bitmap files may be found.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1989 This is used by the `make-image-instance' function.
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1990 */ );
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1991 Vmswindows_bitmap_file_path = Qnil;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1992 }
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1993
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1994 void
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1995 complex_vars_of_glyphs_mswindows (void)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1996 {
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents:
diff changeset
1997 }