all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ponced16@netscape.net (David Ponce)
Cc: emacs-devel@gnu.org
Subject: Improved w32 XBM image support
Date: Fri, 29 Mar 2002 07:09:35 -0500	[thread overview]
Message-ID: <2498CBF7.73409F4C.00A66750@netscape.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

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 Shop@Netscape! http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

[-- Attachment #2: w32fns.c.diff --]
[-- Type: text/x-patch, Size: 5633 bytes --]

*** 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

             reply	other threads:[~2002-03-29 12:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-29 12:09 David Ponce [this message]
2002-04-03 16:49 ` Improved w32 XBM image support Jason Rumney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2498CBF7.73409F4C.00A66750@netscape.net \
    --to=ponced16@netscape.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.