9726 |
loop: |
loop: |
9727 |
|
|
9728 |
/* Skip white space. */ |
/* Skip white space. */ |
9729 |
while (*s < end &&(c = *(*s)++, isspace (c))) |
while (*s < end && (c = *(*s)++, isspace (c))) |
9730 |
; |
; |
9731 |
|
|
9732 |
if (*s >= end) |
if (*s >= end) |
9818 |
} |
} |
9819 |
|
|
9820 |
|
|
9821 |
|
/* Create a Windows bitmap from X bitmap data. */ |
9822 |
|
static HBITMAP |
9823 |
|
w32_create_pixmap_from_bitmap_data (int width, int height, char *data) |
9824 |
|
{ |
9825 |
|
int i, j, w1, w2; |
9826 |
|
char *bits, *p; |
9827 |
|
HBITMAP bmp; |
9828 |
|
|
9829 |
|
w1 = (width + 7) / 8; /* nb of 8bits elt in X bitmap */ |
9830 |
|
w2 = ((width + 15) / 16) * 2; /* nb of 16bits elt in W32 bitmap */ |
9831 |
|
bits = (char *) xmalloc (height * w2); |
9832 |
|
bzero (bits, height * w2); |
9833 |
|
for (i = 0; i < height; i++) |
9834 |
|
{ |
9835 |
|
p = bits + i*w2; |
9836 |
|
for (j = 0; j < w1; j++) |
9837 |
|
*p++ = reflect_byte(*data++); |
9838 |
|
} |
9839 |
|
bmp = CreateBitmap (width, height, 1, 1, bits); |
9840 |
|
xfree (bits); |
9841 |
|
|
9842 |
|
return bmp; |
9843 |
|
} |
9844 |
|
|
9845 |
|
|
9846 |
/* Replacement for XReadBitmapFileData which isn't available under old |
/* Replacement for XReadBitmapFileData which isn't available under old |
9847 |
X versions. CONTENTS is a pointer to a buffer to parse; END is the |
X versions. CONTENTS is a pointer to a buffer to parse; END is the |
9848 |
buffer's end. Set *WIDTH and *HEIGHT to the width and height of |
buffer's end. Set *WIDTH and *HEIGHT to the width and height of |
9860 |
char buffer[BUFSIZ]; |
char buffer[BUFSIZ]; |
9861 |
int padding_p = 0; |
int padding_p = 0; |
9862 |
int v10 = 0; |
int v10 = 0; |
9863 |
int bytes_in_per_line, bytes_out_per_line, i, nbytes; |
int bytes_per_line, i, nbytes; |
9864 |
unsigned char *p; |
unsigned char *p; |
9865 |
int value; |
int value; |
9866 |
int LA1; |
int LA1; |
9913 |
expect_ident ("static"); |
expect_ident ("static"); |
9914 |
if (LA1 == XBM_TK_IDENT) |
if (LA1 == XBM_TK_IDENT) |
9915 |
{ |
{ |
|
/* On Windows, all images need padding to 16 bit boundaries. */ |
|
|
if (*width % 16 && *width % 16 < 9) |
|
|
padding_p = 1; |
|
|
|
|
9916 |
if (strcmp (buffer, "unsigned") == 0) |
if (strcmp (buffer, "unsigned") == 0) |
9917 |
{ |
{ |
9918 |
match (); |
match (); |
9922 |
{ |
{ |
9923 |
match (); |
match (); |
9924 |
v10 = 1; |
v10 = 1; |
9925 |
|
if (*width % 16 && *width % 16 < 9) |
9926 |
|
padding_p = 1; |
9927 |
} |
} |
9928 |
else if (strcmp (buffer, "char") == 0) |
else if (strcmp (buffer, "char") == 0) |
9929 |
match (); |
match (); |
9939 |
expect ('='); |
expect ('='); |
9940 |
expect ('{'); |
expect ('{'); |
9941 |
|
|
9942 |
/* Bytes per line on input. Only count padding for v10 XBMs. */ |
bytes_per_line = (*width + 7) / 8 + padding_p; |
9943 |
bytes_in_per_line = (*width + 7) / 8 + (v10 ? padding_p : 0); |
nbytes = bytes_per_line * *height; |
9944 |
bytes_out_per_line = (*width + 7) / 8 + padding_p; |
p = *data = (char *) xmalloc (nbytes); |
|
|
|
|
nbytes = bytes_in_per_line * *height; |
|
|
p = *data = (char *) xmalloc (bytes_out_per_line * *height); |
|
9945 |
|
|
9946 |
if (v10) |
if (v10) |
9947 |
{ |
{ |
9950 |
int val = value; |
int val = value; |
9951 |
expect (XBM_TK_NUMBER); |
expect (XBM_TK_NUMBER); |
9952 |
|
|
9953 |
*p++ = reflect_byte (val); |
*p++ = val; |
9954 |
if (!padding_p || ((i + 2) % bytes_in_per_line)) |
if (!padding_p || ((i + 2) % bytes_per_line)) |
9955 |
*p++ = reflect_byte (value >> 8); |
*p++ = value >> 8; |
9956 |
|
|
9957 |
if (LA1 == ',' || LA1 == '}') |
if (LA1 == ',' || LA1 == '}') |
9958 |
match (); |
match (); |
9967 |
int val = value; |
int val = value; |
9968 |
expect (XBM_TK_NUMBER); |
expect (XBM_TK_NUMBER); |
9969 |
|
|
9970 |
*p++ = reflect_byte (val); |
*p++ = val; |
|
if (padding_p && ((i + 1) % bytes_in_per_line) == 0) |
|
|
*p++ = 0; |
|
9971 |
|
|
9972 |
if (LA1 == ',' || LA1 == '}') |
if (LA1 == ',' || LA1 == '}') |
9973 |
match (); |
match (); |
10029 |
img->background_valid = 1; |
img->background_valid = 1; |
10030 |
} |
} |
10031 |
img->pixmap |
img->pixmap |
10032 |
= CreateBitmap (img->width, img->height, 1, 1, data); |
= w32_create_pixmap_from_bitmap_data (img->width, img->height, data); |
10033 |
|
|
10034 |
xfree (data); |
xfree (data); |
10035 |
|
|
10169 |
bits = XSTRING (data)->data; |
bits = XSTRING (data)->data; |
10170 |
else |
else |
10171 |
bits = XBOOL_VECTOR (data)->data; |
bits = XBOOL_VECTOR (data)->data; |
10172 |
#ifdef TODO /* full image support. */ |
|
10173 |
/* Create the pixmap. */ |
/* Create the pixmap. */ |
10174 |
depth = one_w32_display_info.n_cbits; |
depth = one_w32_display_info.n_cbits; |
10175 |
img->pixmap |
img->pixmap |
10176 |
= XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f), |
= w32_create_pixmap_from_bitmap_data (img->width, img->height, |
10177 |
FRAME_X_WINDOW (f), |
bits); |
10178 |
bits, |
|
|
img->width, img->height, |
|
|
foreground, background, |
|
|
depth); |
|
|
#endif |
|
10179 |
if (img->pixmap) |
if (img->pixmap) |
10180 |
success_p = 1; |
success_p = 1; |
10181 |
else |
else |