From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: ponced16@netscape.net (David Ponce) Newsgroups: gmane.emacs.devel Subject: Improved w32 XBM image support Date: Fri, 29 Mar 2002 07:09:35 -0500 Sender: emacs-devel-admin@gnu.org Message-ID: <2498CBF7.73409F4C.00A66750@netscape.net> NNTP-Posting-Host: localhost.gmane.org Content-Type: multipart/mixed; boundary=-------2499a45f734177b42499a45f734177b4 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1017403976 6287 127.0.0.1 (29 Mar 2002 12:12:56 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 29 Mar 2002 12:12:56 +0000 (UTC) Cc: emacs-devel@gnu.org Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16qvFX-0001dI-00 for ; Fri, 29 Mar 2002 13:12:55 +0100 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 16qvPN-00061L-00 for ; Fri, 29 Mar 2002 13:23:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16qvEs-0005N0-00; Fri, 29 Mar 2002 07:12:14 -0500 Original-Received: from imo-d06.mx.aol.com ([205.188.157.38]) by fencepost.gnu.org with smtp (Exim 3.34 #1 (Debian)) id 16qvC6-00051E-00; Fri, 29 Mar 2002 07:09:22 -0500 Original-Received: from ponced16@netscape.net by imo-d06.mx.aol.com (mail_out_v32.5.) id 7.101.3551849 (22681); Fri, 29 Mar 2002 07:09:01 -0500 (EST) Original-Received: from netscape.com (mow-m18.webmail.aol.com [64.12.180.134]) by air-in04.mx.aol.com (v84.14) with ESMTP id MAILININ42-0329070901; Fri, 29 Mar 2002 07:09:01 -0500 Original-To: jasonr@gnu.org X-Mailer: Atlas Mailer 2.0 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:2249 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:2249 ---------2499a45f734177b42499a45f734177b4 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-Disposition: inline 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/ ---------2499a45f734177b42499a45f734177b4 Content-Type: text/x-patch; charset=iso-8859-1; name="w32fns.c.diff" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="w32fns.c.diff" Content-Description: w32fns.c.diff *** 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 ---------2499a45f734177b42499a45f734177b4-- _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel