/[emacs]/emacs/src/image.c
ViewVC logotype

Diff of /emacs/src/image.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.32 by rms, Mon Aug 15 01:47:01 2005 UTC revision 1.33 by mituharu, Wed Aug 31 08:35:28 2005 UTC
# Line 54  typedef struct x_bitmap_record Bitmap_Re Line 54  typedef struct x_bitmap_record Bitmap_Re
54    
55  #define RGB_PIXEL_COLOR unsigned long  #define RGB_PIXEL_COLOR unsigned long
56    
57  #define PIX_MASK_RETAIN(f) 0  #define PIX_MASK_RETAIN 0
58  #define PIX_MASK_DRAW(f) 1  #define PIX_MASK_DRAW   1
59  #endif /* HAVE_X_WINDOWS */  #endif /* HAVE_X_WINDOWS */
60    
61    
# Line 71  typedef struct w32_bitmap_record Bitmap_ Line 71  typedef struct w32_bitmap_record Bitmap_
71    
72  #define RGB_PIXEL_COLOR COLORREF  #define RGB_PIXEL_COLOR COLORREF
73    
74  #define PIX_MASK_RETAIN(f) 0  #define PIX_MASK_RETAIN 0
75  #define PIX_MASK_DRAW(f) 1  #define PIX_MASK_DRAW   1
76    
77  #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual  #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual
78  #define x_defined_color w32_defined_color  #define x_defined_color w32_defined_color
# Line 112  typedef struct mac_bitmap_record Bitmap_ Line 112  typedef struct mac_bitmap_record Bitmap_
112    
113  #define RGB_PIXEL_COLOR unsigned long  #define RGB_PIXEL_COLOR unsigned long
114    
115    /* A black pixel in a mask bitmap/pixmap means ``draw a source
116       pixel''.  A white pixel means ``retain the current pixel''. */
117    #define PIX_MASK_DRAW   RGB_TO_ULONG(0,0,0)
118    #define PIX_MASK_RETAIN RGB_TO_ULONG(255,255,255)
119    
120  #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual  #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual
121  #define x_defined_color mac_defined_color  #define x_defined_color mac_defined_color
122  #define DefaultDepthOfScreen(screen) (one_mac_display_info.n_planes)  #define DefaultDepthOfScreen(screen) (one_mac_display_info.n_planes)
# Line 181  XPutPixel (ximage, x, y, pixel) Line 186  XPutPixel (ximage, x, y, pixel)
186       int x, y;       int x, y;
187       unsigned long pixel;       unsigned long pixel;
188  {  {
189    CGrafPtr old_port;    PixMapHandle pixmap = GetGWorldPixMap (ximage);
190    GDHandle old_gdh;    short depth = GetPixDepth (pixmap);
191    RGBColor color;  
192      if (depth == 32)
193    GetGWorld (&old_port, &old_gdh);      {
194    SetGWorld (ximage, NULL);        char *base_addr = GetPixBaseAddr (pixmap);
195          short row_bytes = GetPixRowBytes (pixmap);
196    color.red = RED16_FROM_ULONG (pixel);  
197    color.green = GREEN16_FROM_ULONG (pixel);        ((unsigned long *) (base_addr + y * row_bytes))[x] = pixel;
198    color.blue = BLUE16_FROM_ULONG (pixel);      }
199    SetCPixel (x, y, &color);    else if (depth == 1)
200        {
201          char *base_addr = GetPixBaseAddr (pixmap);
202          short row_bytes = GetPixRowBytes (pixmap);
203    
204          if (pixel == PIX_MASK_DRAW)
205            base_addr[y * row_bytes + x / 8] |= (1 << 7) >> (x & 7);
206          else
207            base_addr[y * row_bytes + x / 8] &= ~((1 << 7) >> (x & 7));
208        }
209      else
210        {
211          CGrafPtr old_port;
212          GDHandle old_gdh;
213          RGBColor color;
214    
215          GetGWorld (&old_port, &old_gdh);
216          SetGWorld (ximage, NULL);
217    
218          color.red = RED16_FROM_ULONG (pixel);
219          color.green = GREEN16_FROM_ULONG (pixel);
220          color.blue = BLUE16_FROM_ULONG (pixel);
221    
222    SetGWorld (old_port, old_gdh);        SetCPixel (x, y, &color);
223    
224          SetGWorld (old_port, old_gdh);
225        }
226  }  }
227    
228  static unsigned long  static unsigned long
# Line 201  XGetPixel (ximage, x, y) Line 230  XGetPixel (ximage, x, y)
230       XImagePtr ximage;       XImagePtr ximage;
231       int x, y;       int x, y;
232  {  {
233    CGrafPtr old_port;    PixMapHandle pixmap = GetGWorldPixMap (ximage);
234    GDHandle old_gdh;    short depth = GetPixDepth (pixmap);
235    RGBColor color;  
236      if (depth == 32)
237        {
238          char *base_addr = GetPixBaseAddr (pixmap);
239          short row_bytes = GetPixRowBytes (pixmap);
240    
241          return ((unsigned long *) (base_addr + y * row_bytes))[x];
242        }
243      else if (depth == 1)
244        {
245          char *base_addr = GetPixBaseAddr (pixmap);
246          short row_bytes = GetPixRowBytes (pixmap);
247    
248          if (base_addr[y * row_bytes + x / 8] & (1 << (~x & 7)))
249            return PIX_MASK_DRAW;
250          else
251            return PIX_MASK_RETAIN;
252        }
253      else
254        {
255          CGrafPtr old_port;
256          GDHandle old_gdh;
257          RGBColor color;
258    
259    GetGWorld (&old_port, &old_gdh);        GetGWorld (&old_port, &old_gdh);
260    SetGWorld (ximage, NULL);        SetGWorld (ximage, NULL);
261    
262    GetCPixel (x, y, &color);        GetCPixel (x, y, &color);
263    
264    SetGWorld (old_port, old_gdh);        SetGWorld (old_port, old_gdh);
265    return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8);        return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8);
266        }
267  }  }
268    
269  static void  static void
# Line 1300  image_background_transparent (img, f, ma Line 1352  image_background_transparent (img, f, ma
1352              }              }
1353    
1354            img->background_transparent            img->background_transparent
1355              = (four_corners_best (mask, img->width, img->height) == PIX_MASK_RETAIN (f));              = (four_corners_best (mask, img->width, img->height) == PIX_MASK_RETAIN);
1356    
1357            if (free_mask)            if (free_mask)
1358              Destroy_Image (mask, prev);              Destroy_Image (mask, prev);
# Line 2003  x_create_x_image_and_pixmap (f, width, h Line 2055  x_create_x_image_and_pixmap (f, width, h
2055    *pixmap = XCreatePixmap (display, window, width, height, depth);    *pixmap = XCreatePixmap (display, window, width, height, depth);
2056    if (*pixmap == NO_PIXMAP)    if (*pixmap == NO_PIXMAP)
2057      {      {
       x_destroy_x_image (*ximg);  
2058        *ximg = NULL;        *ximg = NULL;
2059        image_error ("Unable to create X pixmap", Qnil, Qnil);        image_error ("Unable to create X pixmap", Qnil, Qnil);
2060        return 0;        return 0;
# Line 2166  find_image_fsspec (specified_file, file, Line 2217  find_image_fsspec (specified_file, file,
2217       Lisp_Object specified_file, *file;       Lisp_Object specified_file, *file;
2218       FSSpec *fss;       FSSpec *fss;
2219  {  {
2220  #if TARGET_API_MAC_CARBON  #if MAC_OSX
2221    FSRef fsr;    FSRef fsr;
 #else  
   Str255 mac_pathname;  
2222  #endif  #endif
2223    OSErr err;    OSErr err;
2224    
# Line 2178  find_image_fsspec (specified_file, file, Line 2227  find_image_fsspec (specified_file, file,
2227      return fnfErr;              /* file or directory not found;      return fnfErr;              /* file or directory not found;
2228                                     incomplete pathname */                                     incomplete pathname */
2229    /* Try to open the image file.  */    /* Try to open the image file.  */
2230  #if TARGET_API_MAC_CARBON  #if MAC_OSX
2231    err = FSPathMakeRef (SDATA (*file), &fsr, NULL);    err = FSPathMakeRef (SDATA (*file), &fsr, NULL);
2232    if (err == noErr)    if (err == noErr)
2233      err = FSGetCatalogInfo (&fsr, kFSCatInfoNone, NULL, NULL, fss, NULL);      err = FSGetCatalogInfo (&fsr, kFSCatInfoNone, NULL, NULL, fss, NULL);
2234  #else  #else
2235    if (posix_to_mac_pathname (SDATA (*file), mac_pathname, MAXPATHLEN+1) == 0)    err = posix_pathname_to_fsspec (SDATA (*file), fss);
     return fnfErr;  
   c2pstr (mac_pathname);  
   err = FSMakeFSSpec (0, 0, mac_pathname, fss);  
2236  #endif  #endif
2237    return err;    return err;
2238  }  }
# Line 3850  xpm_load (f, img) Line 3896  xpm_load (f, img)
3896     Only XPM version 3 (without any extensions) is supported.  */     Only XPM version 3 (without any extensions) is supported.  */
3897    
3898  static int xpm_scan P_ ((unsigned char **, unsigned char *,  static int xpm_scan P_ ((unsigned char **, unsigned char *,
3899                         unsigned char **, int *));                           unsigned char **, int *));
3900  static Lisp_Object xpm_make_color_table_v  static Lisp_Object xpm_make_color_table_v
3901    P_ ((void (**) (Lisp_Object, unsigned char *, int, Lisp_Object),    P_ ((void (**) (Lisp_Object, unsigned char *, int, Lisp_Object),
3902         Lisp_Object (**) (Lisp_Object, unsigned char *, int)));         Lisp_Object (**) (Lisp_Object, unsigned char *, int)));
3903  static void xpm_put_color_table_v P_ ((Lisp_Object, unsigned char *,  static void xpm_put_color_table_v P_ ((Lisp_Object, unsigned char *,
3904                                       int, Lisp_Object));                                         int, Lisp_Object));
3905  static Lisp_Object xpm_get_color_table_v P_ ((Lisp_Object,  static Lisp_Object xpm_get_color_table_v P_ ((Lisp_Object,
3906                                              unsigned char *, int));                                                unsigned char *, int));
3907  static Lisp_Object xpm_make_color_table_h  static Lisp_Object xpm_make_color_table_h
3908    P_ ((void (**) (Lisp_Object, unsigned char *, int, Lisp_Object),    P_ ((void (**) (Lisp_Object, unsigned char *, int, Lisp_Object),
3909         Lisp_Object (**) (Lisp_Object, unsigned char *, int)));         Lisp_Object (**) (Lisp_Object, unsigned char *, int)));
3910  static void xpm_put_color_table_h P_ ((Lisp_Object, unsigned char *,  static void xpm_put_color_table_h P_ ((Lisp_Object, unsigned char *,
3911                                       int, Lisp_Object));                                         int, Lisp_Object));
3912  static Lisp_Object xpm_get_color_table_h P_ ((Lisp_Object,  static Lisp_Object xpm_get_color_table_h P_ ((Lisp_Object,
3913                                              unsigned char *, int));                                                unsigned char *, int));
3914  static int xpm_str_to_color_key P_ ((char *));  static int xpm_str_to_color_key P_ ((char *));
3915  static int xpm_load_image P_ ((struct frame *, struct image *,  static int xpm_load_image P_ ((struct frame *, struct image *,
3916                               unsigned char *, unsigned char *));                                 unsigned char *, unsigned char *));
3917    
3918  /* Tokens returned from xpm_scan.  */  /* Tokens returned from xpm_scan.  */
3919    
# Line 3896  xpm_scan (s, end, beg, len) Line 3942  xpm_scan (s, end, beg, len)
3942      {      {
3943        /* Skip white-space.  */        /* Skip white-space.  */
3944        while (*s < end && (c = *(*s)++, isspace (c)))        while (*s < end && (c = *(*s)++, isspace (c)))
3945        ;          ;
3946    
3947        /* gnus-pointer.xpm uses '-' in its identifier.        /* gnus-pointer.xpm uses '-' in its identifier.
3948         sb-dir-plus.xpm uses '+' in its identifier.  */           sb-dir-plus.xpm uses '+' in its identifier.  */
3949        if (isalpha (c) || c == '_' || c == '-' || c == '+')        if (isalpha (c) || c == '_' || c == '-' || c == '+')
3950        {          {
3951          *beg = *s - 1;            *beg = *s - 1;
3952          while (*s < end &&            while (*s < end &&
3953                 (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+'))                   (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+'))
3954              ++*s;                ++*s;
3955          *len = *s - *beg;            *len = *s - *beg;
3956          return XPM_TK_IDENT;            return XPM_TK_IDENT;
3957        }          }
3958        else if (c == '"')        else if (c == '"')
3959        {          {
3960          *beg = *s;            *beg = *s;
3961          while (*s < end && **s != '"')            while (*s < end && **s != '"')
3962            ++*s;              ++*s;
3963          *len = *s - *beg;            *len = *s - *beg;
3964          if (*s < end)            if (*s < end)
3965            ++*s;              ++*s;
3966          return XPM_TK_STRING;            return XPM_TK_STRING;
3967        }          }
3968        else if (c == '/')        else if (c == '/')
3969        {          {
3970          if (*s < end && **s == '*')            if (*s < end && **s == '*')
3971            {              {
3972              /* C-style comment.  */                /* C-style comment.  */
3973              ++*s;                ++*s;
3974              do                do
3975                {                  {
3976                  while (*s < end && *(*s)++ != '*')                    while (*s < end && *(*s)++ != '*')
3977                    ;                      ;
3978                }                  }
3979              while (*s < end && **s != '/');                while (*s < end && **s != '/');
3980              if (*s < end)                if (*s < end)
3981                ++*s;                  ++*s;
3982            }              }
3983          else            else
3984            return c;              return c;
3985        }          }
3986        else        else
3987        return c;          return c;
3988      }      }
3989    
3990    return XPM_TK_EOF;    return XPM_TK_EOF;
# Line 3988  xpm_make_color_table_h (put_func, get_fu Line 4034  xpm_make_color_table_h (put_func, get_fu
4034    *put_func = xpm_put_color_table_h;    *put_func = xpm_put_color_table_h;
4035    *get_func = xpm_get_color_table_h;    *get_func = xpm_get_color_table_h;
4036    return make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),    return make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
4037                          make_float (DEFAULT_REHASH_SIZE),                            make_float (DEFAULT_REHASH_SIZE),
4038                          make_float (DEFAULT_REHASH_THRESHOLD),                            make_float (DEFAULT_REHASH_THRESHOLD),
4039                          Qnil, Qnil, Qnil);                            Qnil, Qnil, Qnil);
4040  }  }
4041    
4042  static void  static void
# Line 4016  xpm_get_color_table_h (color_table, char Line 4062  xpm_get_color_table_h (color_table, char
4062  {  {
4063    struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);    struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
4064    int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len),    int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len),
4065                       NULL);                         NULL);
4066    
4067    return i >= 0 ? HASH_VALUE (table, i) : Qnil;    return i >= 0 ? HASH_VALUE (table, i) : Qnil;
4068  }  }
# Line 4065  xpm_load_image (f, img, contents, end) Line 4111  xpm_load_image (f, img, contents, end)
4111  #define match() \  #define match() \
4112       LA1 = xpm_scan (&s, end, &beg, &len)       LA1 = xpm_scan (&s, end, &beg, &len)
4113    
4114  #define expect(TOKEN)         \  #define expect(TOKEN)           \
4115       if (LA1 != (TOKEN))      \       if (LA1 != (TOKEN))        \
4116         goto failure;          \         goto failure;            \
4117       else                     \       else                       \
4118         match ()         match ()
4119    
4120  #define expect_ident(IDENT)                                   \  #define expect_ident(IDENT)                                     \
4121       if (LA1 == XPM_TK_IDENT \       if (LA1 == XPM_TK_IDENT \
4122           && strlen ((IDENT)) == len && memcmp ((IDENT), beg, len) == 0)  \           && strlen ((IDENT)) == len && memcmp ((IDENT), beg, len) == 0) \
4123          match ();                                              \         match ();                                                \
4124       else                                                     \       else                                                       \
4125         goto failure         goto failure
4126    
4127    if (!(end - s >= 9 && memcmp (s, "/* XPM */", 9) == 0))    if (!(end - s >= 9 && memcmp (s, "/* XPM */", 9) == 0))
# Line 4096  xpm_load_image (f, img, contents, end) Line 4142  xpm_load_image (f, img, contents, end)
4142    memcpy (buffer, beg, len);    memcpy (buffer, beg, len);
4143    buffer[len] = '\0';    buffer[len] = '\0';
4144    if (sscanf (buffer, "%d %d %d %d", &width, &height,    if (sscanf (buffer, "%d %d %d %d", &width, &height,
4145              &num_colors, &chars_per_pixel) != 4                &num_colors, &chars_per_pixel) != 4
4146        || width <= 0 || height <= 0        || width <= 0 || height <= 0
4147        || num_colors <= 0 || chars_per_pixel <= 0)        || num_colors <= 0 || chars_per_pixel <= 0)
4148      goto failure;      goto failure;
# Line 4107  xpm_load_image (f, img, contents, end) Line 4153  xpm_load_image (f, img, contents, end)
4153      best_key = XPM_COLOR_KEY_C;      best_key = XPM_COLOR_KEY_C;
4154    else if (!NILP (Fx_display_grayscale_p (frame)))    else if (!NILP (Fx_display_grayscale_p (frame)))
4155      best_key = (XFASTINT (Fx_display_planes (frame)) > 2      best_key = (XFASTINT (Fx_display_planes (frame)) > 2
4156                ? XPM_COLOR_KEY_G : XPM_COLOR_KEY_G4);                  ? XPM_COLOR_KEY_G : XPM_COLOR_KEY_G4);
4157    else    else
4158      best_key = XPM_COLOR_KEY_M;      best_key = XPM_COLOR_KEY_M;
4159    
4160    color_symbols = image_spec_value (img->spec, QCcolor_symbols, NULL);    color_symbols = image_spec_value (img->spec, QCcolor_symbols, NULL);
4161    if (chars_per_pixel == 1)    if (chars_per_pixel == 1)
4162      color_table = xpm_make_color_table_v (&put_color_table,      color_table = xpm_make_color_table_v (&put_color_table,
4163                                          &get_color_table);                                            &get_color_table);
4164    else    else
4165      color_table = xpm_make_color_table_h (&put_color_table,      color_table = xpm_make_color_table_h (&put_color_table,
4166                                          &get_color_table);                                            &get_color_table);
4167    
4168    while (num_colors-- > 0)    while (num_colors-- > 0)
4169      {      {
# Line 4128  xpm_load_image (f, img, contents, end) Line 4174  xpm_load_image (f, img, contents, end)
4174    
4175        expect (XPM_TK_STRING);        expect (XPM_TK_STRING);
4176        if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel)        if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel)
4177        goto failure;          goto failure;
4178        memcpy (buffer, beg + chars_per_pixel, len - chars_per_pixel);        memcpy (buffer, beg + chars_per_pixel, len - chars_per_pixel);
4179        buffer[len - chars_per_pixel] = '\0';        buffer[len - chars_per_pixel] = '\0';
4180    
4181        str = strtok (buffer, " \t");        str = strtok (buffer, " \t");
4182        if (str == NULL)        if (str == NULL)
4183        goto failure;          goto failure;
4184        key = xpm_str_to_color_key (str);        key = xpm_str_to_color_key (str);
4185        if (key < 0)        if (key < 0)
4186        goto failure;          goto failure;
4187        do        do
4188        {          {
4189          color = strtok (NULL, " \t");            color = strtok (NULL, " \t");
4190          if (color == NULL)            if (color == NULL)
4191            goto failure;              goto failure;
4192    
4193          while (str = strtok (NULL, " \t"))            while (str = strtok (NULL, " \t"))
4194            {              {
4195              next_key = xpm_str_to_color_key (str);                next_key = xpm_str_to_color_key (str);
4196              if (next_key >= 0)                if (next_key >= 0)
4197                break;                  break;
4198              color[strlen (color)] = ' ';                color[strlen (color)] = ' ';
4199            }              }
4200    
4201          if (key == XPM_COLOR_KEY_S)            if (key == XPM_COLOR_KEY_S)
4202            {              {
4203              if (NILP (symbol_color))                if (NILP (symbol_color))
4204                symbol_color = build_string (color);                  symbol_color = build_string (color);
4205            }              }
4206          else if (max_key < key && key <= best_key)            else if (max_key < key && key <= best_key)
4207            {              {
4208              max_key = key;                max_key = key;
4209              max_color = color;                max_color = color;
4210            }              }
4211          key = next_key;            key = next_key;
4212        }          }
4213        while (str);        while (str);
4214    
4215        color_val = Qnil;        color_val = Qnil;
4216        if (!NILP (color_symbols) && !NILP (symbol_color))        if (!NILP (color_symbols) && !NILP (symbol_color))
4217        {          {
4218          Lisp_Object specified_color = Fassoc (symbol_color, color_symbols);            Lisp_Object specified_color = Fassoc (symbol_color, color_symbols);
4219    
4220          if (CONSP (specified_color) && STRINGP (XCDR (specified_color)))            if (CONSP (specified_color) && STRINGP (XCDR (specified_color)))
4221            if (xstricmp (SDATA (XCDR (specified_color)), "None") == 0)              if (xstricmp (SDATA (XCDR (specified_color)), "None") == 0)
4222              color_val = Qt;                color_val = Qt;
4223            else if (x_defined_color (f, SDATA (XCDR (specified_color)),              else if (x_defined_color (f, SDATA (XCDR (specified_color)),
4224                                      &cdef, 0))                                        &cdef, 0))
4225              color_val = make_number (cdef.pixel);                color_val = make_number (cdef.pixel);
4226        }          }
4227        if (NILP (color_val) && max_key > 0)        if (NILP (color_val) && max_key > 0)
4228        if (xstricmp (max_color, "None") == 0)          if (xstricmp (max_color, "None") == 0)
4229          color_val = Qt;            color_val = Qt;
4230        else if (x_defined_color (f, max_color, &cdef, 0))          else if (x_defined_color (f, max_color, &cdef, 0))
4231          color_val = make_number (cdef.pixel);            color_val = make_number (cdef.pixel);
4232        if (!NILP (color_val))        if (!NILP (color_val))
4233        (*put_color_table) (color_table, beg, chars_per_pixel, color_val);          (*put_color_table) (color_table, beg, chars_per_pixel, color_val);
4234    
4235        expect (',');        expect (',');
4236      }      }
4237    
4238    if (!x_create_x_image_and_pixmap (f, width, height, 0,    if (!x_create_x_image_and_pixmap (f, width, height, 0,
4239                                    &ximg, &img->pixmap)                                      &ximg, &img->pixmap)
4240        || !x_create_x_image_and_pixmap (f, width, height, 1,        || !x_create_x_image_and_pixmap (f, width, height, 1,
4241                                       &mask_img, &img->mask))                                         &mask_img, &img->mask))
4242      {      {
4243        image_error ("Out of memory (%s)", img->spec, Qnil);        image_error ("Out of memory (%s)", img->spec, Qnil);
4244        goto error;        goto error;
# Line 4203  xpm_load_image (f, img, contents, end) Line 4249  xpm_load_image (f, img, contents, end)
4249        expect (XPM_TK_STRING);        expect (XPM_TK_STRING);
4250        str = beg;        str = beg;
4251        if (len < width * chars_per_pixel)        if (len < width * chars_per_pixel)
4252        goto failure;          goto failure;
4253        for (x = 0; x < width; x++, str += chars_per_pixel)        for (x = 0; x < width; x++, str += chars_per_pixel)
4254        {          {
4255          Lisp_Object color_val =            Lisp_Object color_val =
4256            (*get_color_table) (color_table, str, chars_per_pixel);              (*get_color_table) (color_table, str, chars_per_pixel);
4257    
4258          XPutPixel (ximg, x, y,            XPutPixel (ximg, x, y,
4259                     (INTEGERP (color_val) ? XINT (color_val)                       (INTEGERP (color_val) ? XINT (color_val)
4260                      : FRAME_FOREGROUND_PIXEL (f)));                        : FRAME_FOREGROUND_PIXEL (f)));
4261          XPutPixel (mask_img, x, y,            XPutPixel (mask_img, x, y,
4262                     (!EQ (color_val, Qt) ? PIX_MASK_DRAW (f)                       (!EQ (color_val, Qt) ? PIX_MASK_DRAW
4263                      : (have_mask = 1, PIX_MASK_RETAIN (f))));                        : (have_mask = 1, PIX_MASK_RETAIN)));
4264        }          }
4265        if (y + 1 < height)        if (y + 1 < height)
4266        expect (',');          expect (',');
4267      }      }
4268    
4269    img->width = width;    img->width = width;
# Line 4227  xpm_load_image (f, img, contents, end) Line 4273  xpm_load_image (f, img, contents, end)
4273    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
4274    if (have_mask)    if (have_mask)
4275      {      {
4276          /* Fill in the background_transparent field while we have the
4277             mask handy.  */
4278          image_background_transparent (img, f, mask_img);
4279    
4280        x_put_x_image (f, mask_img, img->mask, width, height);        x_put_x_image (f, mask_img, img->mask, width, height);
4281        x_destroy_x_image (mask_img);        x_destroy_x_image (mask_img);
4282      }      }
# Line 4272  xpm_load (f, img) Line 4322  xpm_load (f, img)
4322        file = x_find_image_file (file_name);        file = x_find_image_file (file_name);
4323        GCPRO1 (file);        GCPRO1 (file);
4324        if (!STRINGP (file))        if (!STRINGP (file))
4325        {          {
4326          image_error ("Cannot find image file `%s'", file_name, Qnil);            image_error ("Cannot find image file `%s'", file_name, Qnil);
4327          UNGCPRO;            UNGCPRO;
4328          return 0;            return 0;
4329        }          }
4330    
4331        contents = slurp_file (SDATA (file), &size);        contents = slurp_file (SDATA (file), &size);
4332        if (contents == NULL)        if (contents == NULL)
4333        {          {
4334          image_error ("Error loading XPM image `%s'", img->spec, Qnil);            image_error ("Error loading XPM image `%s'", img->spec, Qnil);
4335          UNGCPRO;            UNGCPRO;
4336          return 0;            return 0;
4337        }          }
4338    
4339        success_p = xpm_load_image (f, img, contents, contents + size);        success_p = xpm_load_image (f, img, contents, contents + size);
4340        xfree (contents);        xfree (contents);
# Line 4296  xpm_load (f, img) Line 4346  xpm_load (f, img)
4346    
4347        data = image_spec_value (img->spec, QCdata, NULL);        data = image_spec_value (img->spec, QCdata, NULL);
4348        success_p = xpm_load_image (f, img, SDATA (data),        success_p = xpm_load_image (f, img, SDATA (data),
4349                                  SDATA (data) + SBYTES (data));                                    SDATA (data) + SBYTES (data));
4350      }      }
4351    
4352    return success_p;    return success_p;
# Line 4973  x_disable_image (f, img) Line 5023  x_disable_image (f, img)
5023    
5024  #ifdef MAC_OS  #ifdef MAC_OS
5025  #define XCreateGC_pixmap(dpy, pixmap) XCreateGC (dpy, NULL, 0, NULL)  #define XCreateGC_pixmap(dpy, pixmap) XCreateGC (dpy, NULL, 0, NULL)
5026  #define MaskForeground(f)  PIX_MASK_DRAW (f)  #define MaskForeground(f)  PIX_MASK_DRAW
5027  #else  #else
5028  #define XCreateGC_pixmap(dpy, pixmap) XCreateGC (dpy, pixmap, 0, NULL)  #define XCreateGC_pixmap(dpy, pixmap) XCreateGC (dpy, pixmap, 0, NULL)
5029  #define MaskForeground(f)  WHITE_PIX_DEFAULT (f)  #define MaskForeground(f)  WHITE_PIX_DEFAULT (f)
# Line 5121  x_build_heuristic_mask (f, img, how) Line 5171  x_build_heuristic_mask (f, img, how)
5171    for (y = 0; y < img->height; ++y)    for (y = 0; y < img->height; ++y)
5172      for (x = 0; x < img->width; ++x)      for (x = 0; x < img->width; ++x)
5173        XPutPixel (mask_img, x, y, (XGetPixel (ximg, x, y) != bg        XPutPixel (mask_img, x, y, (XGetPixel (ximg, x, y) != bg
5174                                    ? PIX_MASK_DRAW (f) : PIX_MASK_RETAIN (f)));                                    ? PIX_MASK_DRAW : PIX_MASK_RETAIN));
5175    
5176    /* Fill in the background_transparent field while we have the mask handy. */    /* Fill in the background_transparent field while we have the mask handy. */
5177    image_background_transparent (img, f, mask_img);    image_background_transparent (img, f, mask_img);
# Line 6123  png_load (f, img) Line 6173  png_load (f, img)
6173            if (channels == 4)            if (channels == 4)
6174              {              {
6175                if (mask_img)                if (mask_img)
6176                  XPutPixel (mask_img, x, y, *p > 0 ? PIX_MASK_DRAW (f) : PIX_MASK_RETAIN (f));                  XPutPixel (mask_img, x, y, *p > 0 ? PIX_MASK_DRAW : PIX_MASK_RETAIN);
6177                ++p;                ++p;
6178              }              }
6179          }          }

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26