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

Diff of /emacs/src/w32fns.c

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

revision 1.135 by kfstorm, Fri Nov 16 13:04:59 2001 UTC revision 1.136 by jasonr, Sun Nov 18 21:57:18 2001 UTC
# Line 820  x_set_frame_parameters (f, alist) Line 820  x_set_frame_parameters (f, alist)
820          {          {
821            register Lisp_Object param_index, old_value;            register Lisp_Object param_index, old_value;
822    
           param_index = Fget (prop, Qx_frame_parameter);  
823            old_value = get_frame_param (f, prop);            old_value = get_frame_param (f, prop);
824            store_frame_param (f, prop, val);  
825            if (NATNUMP (param_index)            if (NILP (Fequal (val, old_value)))
826                && (XFASTINT (param_index)              {
827                    < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))                store_frame_param (f, prop, val);
828              (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);                
829                  param_index = Fget (prop, Qx_frame_parameter);
830                  if (NATNUMP (param_index)
831                      && (XFASTINT (param_index)
832                          < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))
833                    (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);
834                }
835          }          }
836      }      }
837    
# Line 857  x_set_frame_parameters (f, alist) Line 862  x_set_frame_parameters (f, alist)
862          {          {
863            register Lisp_Object param_index, old_value;            register Lisp_Object param_index, old_value;
864    
           param_index = Fget (prop, Qx_frame_parameter);  
865            old_value = get_frame_param (f, prop);            old_value = get_frame_param (f, prop);
866    
867            store_frame_param (f, prop, val);            store_frame_param (f, prop, val);
868    
869              param_index = Fget (prop, Qx_frame_parameter);
870            if (NATNUMP (param_index)            if (NATNUMP (param_index)
871                && (XFASTINT (param_index)                && (XFASTINT (param_index)
872                    < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))                    < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))
# Line 2468  x_set_internal_border_width (f, arg, old Line 2475  x_set_internal_border_width (f, arg, old
2475        SET_FRAME_GARBAGED (f);        SET_FRAME_GARBAGED (f);
2476        do_pending_window_change (0);        do_pending_window_change (0);
2477      }      }
2478      else
2479        SET_FRAME_GARBAGED (f);
2480  }  }
2481    
2482  void  void
# Line 5414  This function is an internal primitive-- Line 5423  This function is an internal primitive--
5423      {      {
5424        int margin, relief, bar_height;        int margin, relief, bar_height;
5425                
5426        relief = (tool_bar_button_relief > 0        relief = (tool_bar_button_relief >= 0
5427                  ? tool_bar_button_relief                  ? tool_bar_button_relief
5428                  : DEFAULT_TOOL_BAR_BUTTON_RELIEF);                  : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
5429    
# Line 8179  image_ascent (img, face) Line 8188  image_ascent (img, face)
8188    
8189    
8190    
8191    /* Image background colors.  */
8192    
8193    static unsigned long
8194    four_corners_best (ximg, width, height)
8195         XImage *ximg;
8196         unsigned long width, height;
8197    {
8198    #if 0 /* TODO: Image support.  */
8199      unsigned long corners[4], best;
8200      int i, best_count;
8201    
8202      /* Get the colors at the corners of ximg.  */
8203      corners[0] = XGetPixel (ximg, 0, 0);
8204      corners[1] = XGetPixel (ximg, width - 1, 0);
8205      corners[2] = XGetPixel (ximg, width - 1, height - 1);
8206      corners[3] = XGetPixel (ximg, 0, height - 1);
8207    
8208      /* Choose the most frequently found color as background.  */
8209      for (i = best_count = 0; i < 4; ++i)
8210        {
8211          int j, n;
8212              
8213          for (j = n = 0; j < 4; ++j)
8214            if (corners[i] == corners[j])
8215              ++n;
8216    
8217          if (n > best_count)
8218            best = corners[i], best_count = n;
8219        }
8220    
8221      return best;
8222    #else
8223      return 0;
8224    #endif
8225    }
8226    
8227    /* Return the `background' field of IMG.  If IMG doesn't have one yet,
8228       it is guessed heuristically.  If non-zero, XIMG is an existing XImage
8229       object to use for the heuristic.  */
8230    
8231    unsigned long
8232    image_background (img, f, ximg)
8233         struct image *img;
8234         struct frame *f;
8235         XImage *ximg;
8236    {
8237      if (! img->background_valid)
8238        /* IMG doesn't have a background yet, try to guess a reasonable value.  */
8239        {
8240    #if 0 /* TODO: Image support.  */
8241          int free_ximg = !ximg;
8242    
8243          if (! ximg)
8244            ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap,
8245                              0, 0, img->width, img->height, ~0, ZPixmap);
8246    
8247          img->background = four_corners_best (ximg, img->width, img->height);
8248    
8249          if (free_ximg)
8250            XDestroyImage (ximg);
8251    
8252          img->background_valid = 1;
8253    #endif
8254        }
8255    
8256      return img->background;
8257    }
8258    
8259    /* Return the `background_transparent' field of IMG.  If IMG doesn't
8260       have one yet, it is guessed heuristically.  If non-zero, MASK is an
8261       existing XImage object to use for the heuristic.  */
8262    
8263    int
8264    image_background_transparent (img, f, mask)
8265         struct image *img;
8266         struct frame *f;
8267         XImage *mask;
8268    {
8269      if (! img->background_transparent_valid)
8270        /* IMG doesn't have a background yet, try to guess a reasonable value.  */
8271        {
8272    #if 0 /* TODO: Image support.  */
8273          if (img->mask)
8274            {
8275              int free_mask = !mask;
8276    
8277              if (! mask)
8278                mask = XGetImage (FRAME_X_DISPLAY (f), img->mask,
8279                                  0, 0, img->width, img->height, ~0, ZPixmap);
8280    
8281              img->background_transparent
8282                = !four_corners_best (mask, img->width, img->height);
8283    
8284              if (free_mask)
8285                XDestroyImage (mask);
8286            }
8287          else
8288    #endif
8289            img->background_transparent = 0;
8290    
8291          img->background_transparent_valid = 1;
8292        }
8293    
8294      return img->background_transparent;
8295    }
8296    
8297    
8298  /***********************************************************************  /***********************************************************************
8299                    Helper functions for X image types                    Helper functions for X image types
8300   ***********************************************************************/   ***********************************************************************/
8301    
8302    static void x_clear_image_1 P_ ((struct frame *, struct image *, int,
8303                                     int, int));
8304  static void x_clear_image P_ ((struct frame *f, struct image *img));  static void x_clear_image P_ ((struct frame *f, struct image *img));
8305  static unsigned long x_alloc_image_color P_ ((struct frame *f,  static unsigned long x_alloc_image_color P_ ((struct frame *f,
8306                                                struct image *img,                                                struct image *img,
8307                                                Lisp_Object color_name,                                                Lisp_Object color_name,
8308                                                unsigned long dflt));                                                unsigned long dflt));
8309    
8310    
8311    /* Clear X resources of image IMG on frame F.  PIXMAP_P non-zero means
8312       free the pixmap if any.  MASK_P non-zero means clear the mask
8313       pixmap if any.  COLORS_P non-zero means free colors allocated for
8314       the image, if any.  */
8315    
8316    static void
8317    x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p)
8318         struct frame *f;
8319         struct image *img;
8320         int pixmap_p, mask_p, colors_p;
8321    {
8322    #if 0
8323      if (pixmap_p && img->pixmap)
8324        {
8325          XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap);
8326          img->pixmap = None;
8327          img->background_valid = 0;
8328        }
8329    
8330      if (mask_p && img->mask)
8331        {
8332          XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
8333          img->mask = None;
8334          img->background_transparent_valid = 0;
8335        }
8336          
8337      if (colors_p && img->ncolors)
8338        {
8339          x_free_colors (f, img->colors, img->ncolors);
8340          xfree (img->colors);
8341          img->colors = NULL;
8342          img->ncolors = 0;
8343        }
8344    #endif
8345    }
8346    
8347  /* Free X resources of image IMG which is used on frame F.  */  /* Free X resources of image IMG which is used on frame F.  */
8348    
8349  static void  static void
# Line 8527  lookup_image (f, spec) Line 8682  lookup_image (f, spec)
8682        else        else
8683          {          {
8684            /* Handle image type independent image attributes            /* Handle image type independent image attributes
8685               `:ascent PERCENT', `:margin MARGIN', `:relief RELIEF'.  */               `:ascent PERCENT', `:margin MARGIN', `:relief RELIEF',
8686            Lisp_Object ascent, margin, relief;               `:background COLOR'.  */
8687              Lisp_Object ascent, margin, relief, bg;
8688    
8689            ascent = image_spec_value (spec, QCascent, NULL);            ascent = image_spec_value (spec, QCascent, NULL);
8690            if (INTEGERP (ascent))            if (INTEGERP (ascent))
# Line 8556  lookup_image (f, spec) Line 8712  lookup_image (f, spec)
8712                img->vmargin += abs (img->relief);                img->vmargin += abs (img->relief);
8713              }              }
8714    
8715              if (! img->background_valid)
8716                {
8717                  bg = image_spec_value (img->spec, QCbackground, NULL);
8718                  if (!NILP (bg))
8719                    {
8720                      img->background
8721                        = x_alloc_image_color (f, img, bg,
8722                                               FRAME_BACKGROUND_PIXEL (f));
8723                      img->background_valid = 1;
8724                    }
8725                }
8726    
8727            /* Do image transformations and compute masks, unless we            /* Do image transformations and compute masks, unless we
8728               don't have the image yet.  */               don't have the image yet.  */
8729            if (!EQ (*img->type->type, Qpostscript))            if (!EQ (*img->type->type, Qpostscript))
# Line 8672  x_create_x_image_and_pixmap (f, width, h Line 8840  x_create_x_image_and_pixmap (f, width, h
8840    xassert (interrupt_input_blocked);    xassert (interrupt_input_blocked);
8841    
8842    if (depth <= 0)    if (depth <= 0)
8843      depth = DefaultDepthOfScreen (screen);      depth = one_w32_display_info.n_cbits;
8844    *ximg = XCreateImage (display, DefaultVisualOfScreen (screen),    *ximg = XCreateImage (display, DefaultVisualOfScreen (screen),
8845                          depth, ZPixmap, 0, NULL, width, height,                          depth, ZPixmap, 0, NULL, width, height,
8846                          depth > 16 ? 32 : depth > 8 ? 16 : 8, 0);                          depth > 16 ? 32 : depth > 8 ? 16 : 8, 0);
# Line 8837  enum xbm_keyword_index Line 9005  enum xbm_keyword_index
9005    XBM_RELIEF,    XBM_RELIEF,
9006    XBM_ALGORITHM,    XBM_ALGORITHM,
9007    XBM_HEURISTIC_MASK,    XBM_HEURISTIC_MASK,
9008      XBM_MASK,
9009    XBM_LAST    XBM_LAST
9010  };  };
9011    
# Line 9265  xbm_load_image (f, img, contents, end) Line 9434  xbm_load_image (f, img, contents, end)
9434        value = image_spec_value (img->spec, QCforeground, NULL);        value = image_spec_value (img->spec, QCforeground, NULL);
9435        if (!NILP (value))        if (!NILP (value))
9436          foreground = x_alloc_image_color (f, img, value, foreground);          foreground = x_alloc_image_color (f, img, value, foreground);
         
9437        value = image_spec_value (img->spec, QCbackground, NULL);        value = image_spec_value (img->spec, QCbackground, NULL);
9438        if (!NILP (value))        if (!NILP (value))
9439          background = x_alloc_image_color (f, img, value, background);          {
9440              background = x_alloc_image_color (f, img, value, background);
9441              img->background = background;
9442              img->background_valid = 1;
9443            }
9444          
9445  #if 0 /* TODO : Port image display to W32 */  #if 0 /* TODO : Port image display to W32 */
9446        img->pixmap        img->pixmap
9447          = XCreatePixmapFromBitmapData (FRAME_W32_DISPLAY (f),          = XCreatePixmapFromBitmapData (FRAME_W32_DISPLAY (f),
# Line 9278  xbm_load_image (f, img, contents, end) Line 9450  xbm_load_image (f, img, contents, end)
9450                                         img->width, img->height,                                         img->width, img->height,
9451                                         foreground, background,                                         foreground, background,
9452                                         depth);                                         depth);
9453    #endif
9454        xfree (data);        xfree (data);
9455    
9456        if (img->pixmap == 0)        if (img->pixmap == 0)
# Line 9287  xbm_load_image (f, img, contents, end) Line 9460  xbm_load_image (f, img, contents, end)
9460          }          }
9461        else        else
9462          success_p = 1;          success_p = 1;
 #endif  
9463      }      }
9464    else    else
9465      image_error ("Error loading XBM image `%s'", img->spec, Qnil);      image_error ("Error loading XBM image `%s'", img->spec, Qnil);
# Line 9418  xbm_load (f, img) Line 9590  xbm_load (f, img)
9590              bits = XBOOL_VECTOR (data)->data;              bits = XBOOL_VECTOR (data)->data;
9591  #ifdef TODO /* image support.  */  #ifdef TODO /* image support.  */
9592            /* Create the pixmap.  */            /* Create the pixmap.  */
9593            depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));            depth = one_w32_display_info.n_cbits;
9594            img->pixmap            img->pixmap
9595              = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f),              = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f),
9596                                             FRAME_X_WINDOW (f),                                             FRAME_X_WINDOW (f),
# Line 9471  enum xpm_keyword_index Line 9643  enum xpm_keyword_index
9643    XPM_RELIEF,    XPM_RELIEF,
9644    XPM_ALGORITHM,    XPM_ALGORITHM,
9645    XPM_HEURISTIC_MASK,    XPM_HEURISTIC_MASK,
9646      XPM_MASK,
9647    XPM_COLOR_SYMBOLS,    XPM_COLOR_SYMBOLS,
9648      XPM_BACKGROUND,
9649    XPM_LAST    XPM_LAST
9650  };  };
9651    
# Line 9488  static struct image_keyword xpm_format[X Line 9662  static struct image_keyword xpm_format[X
9662    {":relief",           IMAGE_INTEGER_VALUE,                    0},    {":relief",           IMAGE_INTEGER_VALUE,                    0},
9663    {":conversion",       IMAGE_DONT_CHECK_VALUE_TYPE,            0},    {":conversion",       IMAGE_DONT_CHECK_VALUE_TYPE,            0},
9664    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0},    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0},
9665    {":color-symbols",    IMAGE_DONT_CHECK_VALUE_TYPE,            0}    {":mask",             IMAGE_DONT_CHECK_VALUE_TYPE,            0},
9666      {":color-symbols",    IMAGE_DONT_CHECK_VALUE_TYPE,            0},
9667      {":background",       IMAGE_STRING_OR_NIL_VALUE,              0}
9668  };  };
9669    
9670  /* Structure describing the image type XBM.  */  /* Structure describing the image type XBM.  */
# Line 10213  x_build_heuristic_mask (f, img, how) Line 10389  x_build_heuristic_mask (f, img, how)
10389  {  {
10390    Display *dpy = FRAME_W32_DISPLAY (f);    Display *dpy = FRAME_W32_DISPLAY (f);
10391    XImage *ximg, *mask_img;    XImage *ximg, *mask_img;
10392    int x, y, rc, look_at_corners_p;    int x, y, rc, use_img_background;
10393    unsigned long bg;    unsigned long bg = 0;
10394    
10395      if (img->mask)
10396        {
10397          XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
10398          img->mask = None;
10399          img->background_transparent_valid = 0;
10400        }
10401    
   BLOCK_INPUT;  
     
10402    /* Create an image and pixmap serving as mask.  */    /* Create an image and pixmap serving as mask.  */
10403    rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1,    rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1,
10404                                      &mask_img, &img->mask);                                      &mask_img, &img->mask);
10405    if (!rc)    if (!rc)
10406      {      return 0;
       UNBLOCK_INPUT;  
       return 0;  
     }  
10407    
10408    /* Get the X image of IMG->pixmap.  */    /* Get the X image of IMG->pixmap.  */
10409    ximg = XGetImage (dpy, img->pixmap, 0, 0, img->width, img->height,    ximg = XGetImage (dpy, img->pixmap, 0, 0, img->width, img->height,
10410                      ~0, ZPixmap);                      ~0, ZPixmap);
10411    
10412    /* Determine the background color of ximg.  If HOW is `(R G B)'    /* Determine the background color of ximg.  If HOW is `(R G B)'
10413       take that as color.  Otherwise, try to determine the color       take that as color.  Otherwise, use the image's background color.  */
10414       heuristically. */    use_img_background = 1;
   look_at_corners_p = 1;  
10415        
10416    if (CONSP (how))    if (CONSP (how))
10417      {      {
10418        int rgb[3], i = 0;        int rgb[3], i;
10419    
10420        while (i < 3        for (i = 0; i < 3 && CONSP (how) && NATNUMP (XCAR (how)); ++i)
              && CONSP (how)  
              && NATNUMP (XCAR (how)))  
10421          {          {
10422            rgb[i] = XFASTINT (XCAR (how)) & 0xffff;            rgb[i] = XFASTINT (XCAR (how)) & 0xffff;
10423            how = XCDR (how);            how = XCDR (how);
# Line 10251  x_build_heuristic_mask (f, img, how) Line 10426  x_build_heuristic_mask (f, img, how)
10426        if (i == 3 && NILP (how))        if (i == 3 && NILP (how))
10427          {          {
10428            char color_name[30];            char color_name[30];
           XColor exact, color;  
           Colormap cmap;  
   
10429            sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);            sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
10430                        bg = x_alloc_image_color (f, img, build_string (color_name), 0);
10431            cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));            use_img_background = 0;
           if (XLookupColor (dpy, cmap, color_name, &exact, &color))  
             {  
               bg = color.pixel;  
               look_at_corners_p = 0;  
             }  
10432          }          }
10433      }      }
10434        
10435    if (look_at_corners_p)    if (use_img_background)
10436      {      bg = four_corners_best (ximg, img->width, img->height);
       unsigned long corners[4];  
       int i, best_count;  
   
       /* Get the colors at the corners of ximg.  */  
       corners[0] = XGetPixel (ximg, 0, 0);  
       corners[1] = XGetPixel (ximg, img->width - 1, 0);  
       corners[2] = XGetPixel (ximg, img->width - 1, img->height - 1);  
       corners[3] = XGetPixel (ximg, 0, img->height - 1);  
   
       /* Choose the most frequently found color as background.  */  
       for (i = best_count = 0; i < 4; ++i)  
         {  
           int j, n;  
             
           for (j = n = 0; j < 4; ++j)  
             if (corners[i] == corners[j])  
               ++n;  
   
           if (n > best_count)  
             bg = corners[i], best_count = n;  
         }  
     }  
10437    
10438    /* Set all bits in mask_img to 1 whose color in ximg is different    /* Set all bits in mask_img to 1 whose color in ximg is different
10439       from the background color bg.  */       from the background color bg.  */
# Line 10296  x_build_heuristic_mask (f, img, how) Line 10441  x_build_heuristic_mask (f, img, how)
10441      for (x = 0; x < img->width; ++x)      for (x = 0; x < img->width; ++x)
10442        XPutPixel (mask_img, x, y, XGetPixel (ximg, x, y) != bg);        XPutPixel (mask_img, x, y, XGetPixel (ximg, x, y) != bg);
10443    
10444      /* Fill in the background_transparent field while we have the mask handy. */
10445      image_background_transparent (img, f, mask_img);
10446    
10447    /* Put mask_img into img->mask.  */    /* Put mask_img into img->mask.  */
10448    x_put_x_image (f, mask_img, img->mask, img->width, img->height);    x_put_x_image (f, mask_img, img->mask, img->width, img->height);
10449    x_destroy_x_image (mask_img);    x_destroy_x_image (mask_img);
10450    XDestroyImage (ximg);    XDestroyImage (ximg);
     
   UNBLOCK_INPUT;  
10451    
10452    return 1;    return 1;
10453  }  }
# Line 10333  enum pbm_keyword_index Line 10479  enum pbm_keyword_index
10479    PBM_RELIEF,    PBM_RELIEF,
10480    PBM_ALGORITHM,    PBM_ALGORITHM,
10481    PBM_HEURISTIC_MASK,    PBM_HEURISTIC_MASK,
10482      PBM_MASK,
10483      PBM_FOREGROUND,
10484      PBM_BACKGROUND,
10485    PBM_LAST    PBM_LAST
10486  };  };
10487    
# Line 10592  pbm_load (f, img) Line 10741  pbm_load (f, img)
10741          fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg);          fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg);
10742        if (fmt[PBM_BACKGROUND].count        if (fmt[PBM_BACKGROUND].count
10743            && STRINGP (fmt[PBM_BACKGROUND].value))            && STRINGP (fmt[PBM_BACKGROUND].value))
10744          bg = x_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg);          {
10745                    bg = x_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg);
10746              img->background = bg;
10747              img->background_valid = 1;
10748            }
10749    
10750        for (y = 0; y < height; ++y)        for (y = 0; y < height; ++y)
10751          for (x = 0; x < width; ++x)          for (x = 0; x < width; ++x)
10752            {            {
# Line 10656  pbm_load (f, img) Line 10809  pbm_load (f, img)
10809    img->colors = colors_in_color_table (&img->ncolors);    img->colors = colors_in_color_table (&img->ncolors);
10810    free_color_table ();    free_color_table ();
10811        
10812      /* Maybe fill in the background field while we have ximg handy.  */
10813      if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
10814        IMAGE_BACKGROUND (img, f, ximg);
10815      
10816    /* Put the image into a pixmap.  */    /* Put the image into a pixmap.  */
10817    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
10818    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
# Line 10699  enum png_keyword_index Line 10856  enum png_keyword_index
10856    PNG_RELIEF,    PNG_RELIEF,
10857    PNG_ALGORITHM,    PNG_ALGORITHM,
10858    PNG_HEURISTIC_MASK,    PNG_HEURISTIC_MASK,
10859      PNG_MASK,
10860      PNG_BACKGROUND,
10861    PNG_LAST    PNG_LAST
10862  };  };
10863    
# Line 10714  static struct image_keyword png_format[P Line 10873  static struct image_keyword png_format[P
10873    {":margin",           IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR,   0},    {":margin",           IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR,   0},
10874    {":relief",           IMAGE_INTEGER_VALUE,                    0},    {":relief",           IMAGE_INTEGER_VALUE,                    0},
10875    {":conversion",       IMAGE_DONT_CHECK_VALUE_TYPE,            0},    {":conversion",       IMAGE_DONT_CHECK_VALUE_TYPE,            0},
10876    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0}    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0},
10877      {":mask",             IMAGE_DONT_CHECK_VALUE_TYPE,            0},
10878      {":background",       IMAGE_STRING_OR_NIL_VALUE,              0}
10879  };  };
10880    
10881  /* Structure describing the image type `png'.  */  /* Structure describing the image type `png'.  */
# Line 10816  png_load (f, img) Line 10977  png_load (f, img)
10977    struct gcpro gcpro1;    struct gcpro gcpro1;
10978    png_struct *png_ptr = NULL;    png_struct *png_ptr = NULL;
10979    png_info *info_ptr = NULL, *end_info = NULL;    png_info *info_ptr = NULL, *end_info = NULL;
10980    FILE *fp = NULL;    FILE *volatile fp = NULL;
10981    png_byte sig[8];    png_byte sig[8];
10982    png_byte *pixels = NULL;    png_byte *volatile pixels = NULL;
10983    png_byte **rows = NULL;    png_byte **volatile rows = NULL;
10984    png_uint_32 width, height;    png_uint_32 width, height;
10985    int bit_depth, color_type, interlace_type;    int bit_depth, color_type, interlace_type;
10986    png_byte channels;    png_byte channels;
# Line 10988  png_load (f, img) Line 11149  png_load (f, img)
11149    if (!transparent_p)    if (!transparent_p)
11150      {      {
11151        png_color_16 *image_background;        png_color_16 *image_background;
11152          Lisp_Object specified_bg
11153            = image_spec_value (img->spec, QCbackground, NULL);
11154    
11155    
11156          if (STRINGP (specified_bg))
11157            /* The user specified `:background', use that.  */
11158            {
11159              COLORREF color;
11160              if (w32_defined_color (f, XSTRING (specified_bg)->data, &color, 0))
11161                {
11162                  png_color_16 user_bg;
11163    
11164                  bzero (&user_bg, sizeof user_bg);
11165                  user_bg.red = color.red;
11166                  user_bg.green = color.green;
11167                  user_bg.blue = color.blue;
11168    
11169        if (png_get_bKGD (png_ptr, info_ptr, &image_background))                png_set_background (png_ptr, &user_bg,
11170                                      PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
11171                }
11172            }
11173          else if (png_get_bKGD (png_ptr, info_ptr, &image_background))
11174          /* Image contains a background color with which to          /* Image contains a background color with which to
11175             combine the image.  */             combine the image.  */
11176          png_set_background (png_ptr, image_background,          png_set_background (png_ptr, image_background,
# Line 11003  png_load (f, img) Line 11184  png_load (f, img)
11184            Colormap cmap;            Colormap cmap;
11185            png_color_16 frame_background;            png_color_16 frame_background;
11186    
11187            BLOCK_INPUT;            cmap = FRAME_X_COLORMAP (f);
           cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));  
11188            color.pixel = FRAME_BACKGROUND_PIXEL (f);            color.pixel = FRAME_BACKGROUND_PIXEL (f);
11189            XQueryColor (FRAME_W32_DISPLAY (f), cmap, &color);            x_query_color (f, &color);
           UNBLOCK_INPUT;  
11190    
11191            bzero (&frame_background, sizeof frame_background);            bzero (&frame_background, sizeof frame_background);
11192            frame_background.red = color.red;            frame_background.red = color.red;
# Line 11048  png_load (f, img) Line 11227  png_load (f, img)
11227        fp = NULL;        fp = NULL;
11228      }      }
11229    
   BLOCK_INPUT;  
   
11230    /* Create the X image and pixmap.  */    /* Create the X image and pixmap.  */
11231    if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,    if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,
11232                                      &img->pixmap))                                      &img->pixmap))
11233      {      goto error;
       UNBLOCK_INPUT;  
       goto error;  
     }  
11234        
11235    /* Create an image and pixmap serving as mask if the PNG image    /* Create an image and pixmap serving as mask if the PNG image
11236       contains an alpha channel.  */       contains an alpha channel.  */
# Line 11068  png_load (f, img) Line 11242  png_load (f, img)
11242        x_destroy_x_image (ximg);        x_destroy_x_image (ximg);
11243        XFreePixmap (FRAME_W32_DISPLAY (f), img->pixmap);        XFreePixmap (FRAME_W32_DISPLAY (f), img->pixmap);
11244        img->pixmap = 0;        img->pixmap = 0;
       UNBLOCK_INPUT;  
11245        goto error;        goto error;
11246      }      }
11247    
# Line 11113  png_load (f, img) Line 11286  png_load (f, img)
11286          }          }
11287      }      }
11288    
11289      if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
11290        /* Set IMG's background color from the PNG image, unless the user
11291           overrode it.  */
11292        {
11293          png_color_16 *bg;
11294          if (png_get_bKGD (png_ptr, info_ptr, &bg))
11295            {
11296              img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue);
11297              img->background_valid = 1;
11298            }
11299        }
11300    
11301    /* Remember colors allocated for this image.  */    /* Remember colors allocated for this image.  */
11302    img->colors = colors_in_color_table (&img->ncolors);    img->colors = colors_in_color_table (&img->ncolors);
11303    free_color_table ();    free_color_table ();
# Line 11125  png_load (f, img) Line 11310  png_load (f, img)
11310    img->width = width;    img->width = width;
11311    img->height = height;    img->height = height;
11312    
11313      /* Maybe fill in the background field while we have ximg handy. */
11314      IMAGE_BACKGROUND (img, f, ximg);
11315    
11316    /* Put the image into the pixmap, then free the X image and its buffer.  */    /* Put the image into the pixmap, then free the X image and its buffer.  */
11317    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
11318    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
# Line 11132  png_load (f, img) Line 11320  png_load (f, img)
11320    /* Same for the mask.  */    /* Same for the mask.  */
11321    if (mask_img)    if (mask_img)
11322      {      {
11323          /* Fill in the background_transparent field while we have the mask
11324             handy. */
11325          image_background_transparent (img, f, mask_img);
11326    
11327        x_put_x_image (f, mask_img, img->mask, img->width, img->height);        x_put_x_image (f, mask_img, img->mask, img->width, img->height);
11328        x_destroy_x_image (mask_img);        x_destroy_x_image (mask_img);
11329      }      }
11330    
   UNBLOCK_INPUT;  
11331    UNGCPRO;    UNGCPRO;
11332    return 1;    return 1;
11333  }  }
# Line 11185  enum jpeg_keyword_index Line 11376  enum jpeg_keyword_index
11376    JPEG_RELIEF,    JPEG_RELIEF,
11377    JPEG_ALGORITHM,    JPEG_ALGORITHM,
11378    JPEG_HEURISTIC_MASK,    JPEG_HEURISTIC_MASK,
11379      JPEG_MASK,
11380      JPEG_BACKGROUND,
11381    JPEG_LAST    JPEG_LAST
11382  };  };
11383    
# Line 11199  static struct image_keyword jpeg_format[ Line 11392  static struct image_keyword jpeg_format[
11392    {":ascent",           IMAGE_NON_NEGATIVE_INTEGER_VALUE,       0},    {":ascent",           IMAGE_NON_NEGATIVE_INTEGER_VALUE,       0},
11393    {":margin",           IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR,   0},    {":margin",           IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR,   0},
11394    {":relief",           IMAGE_INTEGER_VALUE,                    0},    {":relief",           IMAGE_INTEGER_VALUE,                    0},
11395    {":conversion",       IMAGE_DONT_CHECK_VALUE_TYPE,            0},    {":conversions",      IMAGE_DONT_CHECK_VALUE_TYPE,            0},
11396    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0}    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0},
11397      {":mask",             IMAGE_DONT_CHECK_VALUE_TYPE,            0},
11398      {":background",       IMAGE_STRING_OR_NIL_VALUE,              0}
11399  };  };
11400    
11401  /* Structure describing the image type `jpeg'.  */  /* Structure describing the image type `jpeg'.  */
# Line 11357  jpeg_load (f, img) Line 11552  jpeg_load (f, img)
11552    struct my_jpeg_error_mgr mgr;    struct my_jpeg_error_mgr mgr;
11553    Lisp_Object file, specified_file;    Lisp_Object file, specified_file;
11554    Lisp_Object specified_data;    Lisp_Object specified_data;
11555    FILE *fp = NULL;    FILE * volatile fp = NULL;
11556    JSAMPARRAY buffer;    JSAMPARRAY buffer;
11557    int row_stride, x, y;    int row_stride, x, y;
11558    XImage *ximg = NULL;    XImage *ximg = NULL;
# Line 11393  jpeg_load (f, img) Line 11588  jpeg_load (f, img)
11588        
11589    /* Customize libjpeg's error handling to call my_error_exit when an    /* Customize libjpeg's error handling to call my_error_exit when an
11590       error is detected. This function will perform a longjmp. */       error is detected. This function will perform a longjmp. */
   mgr.pub.error_exit = my_error_exit;  
11591    cinfo.err = jpeg_std_error (&mgr.pub);    cinfo.err = jpeg_std_error (&mgr.pub);
11592      mgr.pub.error_exit = my_error_exit;
11593        
11594    if ((rc = setjmp (mgr.setjmp_buffer)) != 0)    if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
11595      {      {
# Line 11411  jpeg_load (f, img) Line 11606  jpeg_load (f, img)
11606        if (fp)        if (fp)
11607          fclose (fp);          fclose (fp);
11608        jpeg_destroy_decompress (&cinfo);        jpeg_destroy_decompress (&cinfo);
   
       BLOCK_INPUT;  
11609                
11610        /* If we already have an XImage, free that.  */        /* If we already have an XImage, free that.  */
11611        x_destroy_x_image (ximg);        x_destroy_x_image (ximg);
# Line 11420  jpeg_load (f, img) Line 11613  jpeg_load (f, img)
11613        /* Free pixmap and colors.  */        /* Free pixmap and colors.  */
11614        x_clear_image (f, img);        x_clear_image (f, img);
11615                
       UNBLOCK_INPUT;  
11616        UNGCPRO;        UNGCPRO;
11617        return 0;        return 0;
11618      }      }
# Line 11444  jpeg_load (f, img) Line 11636  jpeg_load (f, img)
11636    width = img->width = cinfo.output_width;    width = img->width = cinfo.output_width;
11637    height = img->height = cinfo.output_height;    height = img->height = cinfo.output_height;
11638    
   BLOCK_INPUT;  
   
11639    /* Create X image and pixmap.  */    /* Create X image and pixmap.  */
11640    if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,    if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,
11641                                      &img->pixmap))                                      &img->pixmap))
11642      {      longjmp (mgr.setjmp_buffer, 2);
       UNBLOCK_INPUT;  
       longjmp (mgr.setjmp_buffer, 2);  
     }  
11643    
11644    /* Allocate colors.  When color quantization is used,    /* Allocate colors.  When color quantization is used,
11645       cinfo.actual_number_of_colors has been set with the number of       cinfo.actual_number_of_colors has been set with the number of
# Line 11509  jpeg_load (f, img) Line 11696  jpeg_load (f, img)
11696    if (fp)    if (fp)
11697      fclose (fp);      fclose (fp);
11698        
11699      /* Maybe fill in the background field while we have ximg handy. */
11700      if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
11701        IMAGE_BACKGROUND (img, f, ximg);
11702      
11703    /* Put the image into the pixmap.  */    /* Put the image into the pixmap.  */
11704    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
11705    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
# Line 11548  enum tiff_keyword_index Line 11739  enum tiff_keyword_index
11739    TIFF_RELIEF,    TIFF_RELIEF,
11740    TIFF_ALGORITHM,    TIFF_ALGORITHM,
11741    TIFF_HEURISTIC_MASK,    TIFF_HEURISTIC_MASK,
11742      TIFF_MASK,
11743      TIFF_BACKGROUND,
11744    TIFF_LAST    TIFF_LAST
11745  };  };
11746    
# Line 11562  static struct image_keyword tiff_format[ Line 11755  static struct image_keyword tiff_format[
11755    {":ascent",           IMAGE_NON_NEGATIVE_INTEGER_VALUE,       0},    {":ascent",           IMAGE_NON_NEGATIVE_INTEGER_VALUE,       0},
11756    {":margin",           IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR,   0},    {":margin",           IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR,   0},
11757    {":relief",           IMAGE_INTEGER_VALUE,                    0},    {":relief",           IMAGE_INTEGER_VALUE,                    0},
11758    {":conversion",       IMAGE_DONT_CHECK_VALUE_TYPE,            0},    {":conversions",      IMAGE_DONT_CHECK_VALUE_TYPE,            0},
11759    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0}    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0},
11760      {":mask",             IMAGE_DONT_CHECK_VALUE_TYPE,            0},
11761      {":background",       IMAGE_STRING_OR_NIL_VALUE,              0}
11762  };  };
11763    
11764  /* Structure describing the image type `tiff'.  */  /* Structure describing the image type `tiff'.  */
# Line 11851  tiff_load (f, img) Line 12046  tiff_load (f, img)
12046    img->colors = colors_in_color_table (&img->ncolors);    img->colors = colors_in_color_table (&img->ncolors);
12047    free_color_table ();    free_color_table ();
12048    
12049      img->width = width;
12050      img->height = height;
12051    
12052      /* Maybe fill in the background field while we have ximg handy. */
12053      if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
12054        IMAGE_BACKGROUND (img, f, ximg);
12055    
12056    /* Put the image into the pixmap, then free the X image and its buffer.  */    /* Put the image into the pixmap, then free the X image and its buffer.  */
12057    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
12058    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
12059    xfree (buf);    xfree (buf);
         
   img->width = width;  
   img->height = height;  
12060    
12061    UNGCPRO;    UNGCPRO;
12062    return 1;    return 1;
# Line 11894  enum gif_keyword_index Line 12093  enum gif_keyword_index
12093    GIF_RELIEF,    GIF_RELIEF,
12094    GIF_ALGORITHM,    GIF_ALGORITHM,
12095    GIF_HEURISTIC_MASK,    GIF_HEURISTIC_MASK,
12096      GIF_MASK,
12097    GIF_IMAGE,    GIF_IMAGE,
12098      GIF_BACKGROUND,
12099    GIF_LAST    GIF_LAST
12100  };  };
12101    
# Line 11911  static struct image_keyword gif_format[G Line 12112  static struct image_keyword gif_format[G
12112    {":relief",           IMAGE_INTEGER_VALUE,                    0},    {":relief",           IMAGE_INTEGER_VALUE,                    0},
12113    {":conversion",       IMAGE_DONT_CHECK_VALUE_TYPE,            0},    {":conversion",       IMAGE_DONT_CHECK_VALUE_TYPE,            0},
12114    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0},    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0},
12115    {":image",            IMAGE_NON_NEGATIVE_INTEGER_VALUE,       0}    {":mask",             IMAGE_DONT_CHECK_VALUE_TYPE,            0},
12116      {":image",            IMAGE_NON_NEGATIVE_INTEGER_VALUE,       0},
12117      {":background",       IMAGE_STRING_OR_NIL_VALUE,              0}
12118  };  };
12119    
12120  /* Structure describing the image type `gif'.  */  /* Structure describing the image type `gif'.  */
# Line 12062  gif_load (f, img) Line 12265  gif_load (f, img)
12265    width = img->width = gif->SWidth;    width = img->width = gif->SWidth;
12266    height = img->height = gif->SHeight;    height = img->height = gif->SHeight;
12267    
   BLOCK_INPUT;  
   
12268    /* Create the X image and pixmap.  */    /* Create the X image and pixmap.  */
12269    if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))    if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
12270      {      {
       UNBLOCK_INPUT;  
12271        DGifCloseFile (gif);        DGifCloseFile (gif);
12272        UNGCPRO;        UNGCPRO;
12273        return 0;        return 0;
# Line 12126  gif_load (f, img) Line 12326  gif_load (f, img)
12326      {      {
12327        static int interlace_start[] = {0, 4, 2, 1};        static int interlace_start[] = {0, 4, 2, 1};
12328        static int interlace_increment[] = {8, 8, 4, 2};        static int interlace_increment[] = {8, 8, 4, 2};
12329        int pass, inc;        int pass;
12330        int row = interlace_start[0];        int row = interlace_start[0];
12331    
12332        pass = 0;        pass = 0;
# Line 12161  gif_load (f, img) Line 12361  gif_load (f, img)
12361      }      }
12362        
12363    DGifCloseFile (gif);    DGifCloseFile (gif);
12364      
12365      /* Maybe fill in the background field while we have ximg handy. */
12366      if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
12367        IMAGE_BACKGROUND (img, f, ximg);
12368    
12369    /* Put the image into the pixmap, then free the X image and its buffer.  */    /* Put the image into the pixmap, then free the X image and its buffer.  */
12370    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
12371    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
   UNBLOCK_INPUT;  
12372                
12373    UNGCPRO;    UNGCPRO;
12374    return 1;    return 1;
# Line 12207  enum gs_keyword_index Line 12410  enum gs_keyword_index
12410    GS_RELIEF,    GS_RELIEF,
12411    GS_ALGORITHM,    GS_ALGORITHM,
12412    GS_HEURISTIC_MASK,    GS_HEURISTIC_MASK,
12413      GS_MASK,
12414      GS_BACKGROUND,
12415    GS_LAST    GS_LAST
12416  };  };
12417    
# Line 12225  static struct image_keyword gs_format[GS Line 12430  static struct image_keyword gs_format[GS
12430    {":margin",           IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR,   0},    {":margin",           IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR,   0},
12431    {":relief",           IMAGE_INTEGER_VALUE,                    0},    {":relief",           IMAGE_INTEGER_VALUE,                    0},
12432    {":conversion",       IMAGE_DONT_CHECK_VALUE_TYPE,            0},    {":conversion",       IMAGE_DONT_CHECK_VALUE_TYPE,            0},
12433    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0}    {":heuristic-mask",   IMAGE_DONT_CHECK_VALUE_TYPE,            0},
12434      {":mask",             IMAGE_DONT_CHECK_VALUE_TYPE,            0},
12435      {":background",       IMAGE_STRING_OR_NIL_VALUE,              0}
12436  };  };
12437    
12438  /* Structure describing the image type `ghostscript'.  */  /* Structure describing the image type `ghostscript'.  */
# Line 12327  gs_load (f, img) Line 12534  gs_load (f, img)
12534    xassert (img->pixmap == 0);    xassert (img->pixmap == 0);
12535    img->pixmap = XCreatePixmap (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),    img->pixmap = XCreatePixmap (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
12536                                 img->width, img->height,                                 img->width, img->height,
12537                                 DefaultDepthOfScreen (FRAME_X_SCREEN (f)));                                 one_w32_display_info.n_cbits);
12538    UNBLOCK_INPUT;    UNBLOCK_INPUT;
12539    
12540    if (!img->pixmap)    if (!img->pixmap)
# Line 13175  Text larger than the specified size is c Line 13382  Text larger than the specified size is c
13382  {  {
13383    struct frame *f;    struct frame *f;
13384    struct window *w;    struct window *w;
   Lisp_Object buffer, top, left, max_width, max_height;  
13385    int root_x, root_y;    int root_x, root_y;
13386    struct buffer *old_buffer;    struct buffer *old_buffer;
13387    struct text_pos pos;    struct text_pos pos;

Legend:
Removed from v.1.135  
changed lines
  Added in v.1.136

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