[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Improved w32 XBM image support
From: |
David Ponce |
Subject: |
Improved w32 XBM image support |
Date: |
Fri, 29 Mar 2002 07:09:35 -0500 |
Hi Jason,
I worked a little bit on Emacs 21 image support on Windows (within
the limits of my competence ;-).
Attached you will find a patch for w32fns.c which add support for XBM
in line images (via image :data property). This feature is required
in wid-edit.el for checkboxes :on-glyph, :off-glyph images.
Here is a change log:
(w32_create_pixmap_from_bitmap_data): New function.
(xbm_load_image): Use it.
(xbm_load): Ditto.
(xbm_read_bitmap_data): Reverted to xfns.c version.
Hope this will help!
Sincerely,
David
__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience
the convenience of buying online with address@hidden
http://shopnow.netscape.com/
Get your own FREE, personal Netscape Mail account today at
http://webmail.netscape.com/
*** w32fns.c.ori Sun Mar 24 17:34:10 2002
--- w32fns.c Fri Mar 29 12:48:23 2002
***************
*** 9711,9717 ****
loop:
/* Skip white space. */
! while (*s < end &&(c = *(*s)++, isspace (c)))
;
if (*s >= end)
--- 9711,9717 ----
loop:
/* Skip white space. */
! while (*s < end && (c = *(*s)++, isspace (c)))
;
if (*s >= end)
***************
*** 9802,9807 ****
--- 9802,9830 ----
return reflected;
}
+ /* Create a Windows bitmap from X bitmap data. */
+ static HBITMAP
+ w32_create_pixmap_from_bitmap_data (int width, int height, char *data)
+ {
+ int i, j, w1, w2;
+ char *bits, *p;
+ HBITMAP bmp;
+
+ w1 = (width + 7) / 8; /* nb of 8bits elt in X bitmap */
+ w2 = ((width + 15) / 16) * 2; /* nb of 16bits elt in W32 bitmap */
+ bits = (char *) xmalloc (height * w2);
+ bzero (bits, height * w2);
+ for (i = 0; i < height; i++)
+ {
+ p = bits + i*w2;
+ for (j = 0; j < w1; j++)
+ *p++ = reflect_byte(*data++);
+ }
+ bmp = CreateBitmap (width, height, 1, 1, bits);
+ xfree (bits);
+
+ return bmp;
+ }
/* Replacement for XReadBitmapFileData which isn't available under old
X versions. CONTENTS is a pointer to a buffer to parse; END is the
***************
*** 9820,9826 ****
char buffer[BUFSIZ];
int padding_p = 0;
int v10 = 0;
! int bytes_in_per_line, bytes_out_per_line, i, nbytes;
unsigned char *p;
int value;
int LA1;
--- 9843,9849 ----
char buffer[BUFSIZ];
int padding_p = 0;
int v10 = 0;
! int bytes_per_line, i, nbytes;
unsigned char *p;
int value;
int LA1;
***************
*** 9873,9882 ****
expect_ident ("static");
if (LA1 == XBM_TK_IDENT)
{
- /* On Windows, all images need padding to 16 bit boundaries. */
- if (*width % 16 && *width % 16 < 9)
- padding_p = 1;
-
if (strcmp (buffer, "unsigned") == 0)
{
match ();
--- 9896,9901 ----
***************
*** 9886,9891 ****
--- 9905,9912 ----
{
match ();
v10 = 1;
+ if (*width % 16 && *width % 16 < 9)
+ padding_p = 1;
}
else if (strcmp (buffer, "char") == 0)
match ();
***************
*** 9901,9912 ****
expect ('=');
expect ('{');
! /* Bytes per line on input. Only count padding for v10 XBMs. */
! bytes_in_per_line = (*width + 7) / 8 + (v10 ? padding_p : 0);
! bytes_out_per_line = (*width + 7) / 8 + padding_p;
!
! nbytes = bytes_in_per_line * *height;
! p = *data = (char *) xmalloc (bytes_out_per_line * *height);
if (v10)
{
--- 9922,9930 ----
expect ('=');
expect ('{');
! bytes_per_line = (*width + 7) / 8 + padding_p;
! nbytes = bytes_per_line * *height;
! p = *data = (char *) xmalloc (nbytes);
if (v10)
{
***************
*** 9915,9923 ****
int val = value;
expect (XBM_TK_NUMBER);
! *p++ = reflect_byte (val);
! if (!padding_p || ((i + 2) % bytes_in_per_line))
! *p++ = reflect_byte (value >> 8);
if (LA1 == ',' || LA1 == '}')
match ();
--- 9933,9941 ----
int val = value;
expect (XBM_TK_NUMBER);
! *p++ = val;
! if (!padding_p || ((i + 2) % bytes_per_line))
! *p++ = value >> 8;
if (LA1 == ',' || LA1 == '}')
match ();
***************
*** 9932,9941 ****
int val = value;
expect (XBM_TK_NUMBER);
! *p++ = reflect_byte (val);
! if (padding_p && ((i + 1) % bytes_in_per_line) == 0)
! *p++ = 0;
!
if (LA1 == ',' || LA1 == '}')
match ();
else
--- 9950,9957 ----
int val = value;
expect (XBM_TK_NUMBER);
! *p++ = val;
!
if (LA1 == ',' || LA1 == '}')
match ();
else
***************
*** 9947,9953 ****
return 1;
failure:
!
if (data && *data)
{
xfree (*data);
--- 9963,9969 ----
return 1;
failure:
!
if (data && *data)
{
xfree (*data);
***************
*** 9960,9966 ****
#undef expect_ident
}
-
/* Load XBM image IMG which will be displayed on frame F from buffer
CONTENTS. END is the end of the buffer. Value is non-zero if
successful. */
--- 9976,9981 ----
***************
*** 9995,10002 ****
img->background = background;
img->background_valid = 1;
}
! img->pixmap
! = CreateBitmap (img->width, img->height, 1, 1, data);
xfree (data);
--- 10010,10017 ----
img->background = background;
img->background_valid = 1;
}
! img->pixmap
! = w32_create_pixmap_from_bitmap_data (img->width, img->height, data);
xfree (data);
***************
*** 10136,10152 ****
bits = XSTRING (data)->data;
else
bits = XBOOL_VECTOR (data)->data;
! #ifdef TODO /* full image support. */
/* Create the pixmap. */
depth = one_w32_display_info.n_cbits;
! img->pixmap
! = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f),
! FRAME_X_WINDOW (f),
! bits,
! img->width, img->height,
! foreground, background,
! depth);
! #endif
if (img->pixmap)
success_p = 1;
else
--- 10151,10162 ----
bits = XSTRING (data)->data;
else
bits = XBOOL_VECTOR (data)->data;
!
!
/* Create the pixmap. */
depth = one_w32_display_info.n_cbits;
! img->pixmap
! = w32_create_pixmap_from_bitmap_data (img->width, img->height,
bits);
if (img->pixmap)
success_p = 1;
else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Improved w32 XBM image support,
David Ponce <=