emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: image size limit?


From: Kim F. Storm
Subject: Re: image size limit?
Date: Wed, 19 Oct 2005 14:51:33 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

David Kastrup <address@hidden> writes:

> It sounds to me like the limits should be configurable, with a
> somewhat conservative default.  Applications where larger dimensions
> might be appropriate (image viewers with provisions for panning, i.e.)
> can allow them in their own buffers using buffer-local settings of the
> variables limiting the size.

I think it makes sense for some purposes to allow max image size to be
specified in absolute pixels.  Here is a patch to do that:


*** image.c     19 Oct 2005 10:20:42 +0200      1.37
--- image.c     19 Oct 2005 11:50:56 +0200      
***************
*** 1163,1179 ****
       int width;
       int height;
  {
!   if (width <= 0 || height <=0)
!     return 0;
  
!   if (FLOATP (Vmax_image_size) && f
!       && ((width > (int)(XFLOAT_DATA (Vmax_image_size)
!                        * FRAME_PIXEL_WIDTH (f)))
!         || (height > (int)(XFLOAT_DATA (Vmax_image_size)
!                            * FRAME_PIXEL_HEIGHT (f)))))
      return 0;
  
!   return 1;
  }
  
  /* Prepare image IMG for display on frame F.  Must be called before
--- 1163,1191 ----
       int width;
       int height;
  {
!   int w, h;
  
!   if (width <= 0 || height <= 0)
      return 0;
  
!   if (INTEGERP (Vmax_image_size))
!     w = h = XINT (Vmax_image_size);
!   else if (FLOATP (Vmax_image_size))
!     {
!       if (f != NULL)
!       {
!         w = FRAME_PIXEL_WIDTH (f);
!         h = FRAME_PIXEL_HEIGHT (f);
!       }
!       else
!       w = h = 1024;  /* Arbitrary size for unknown frame. */
!       w = (int) (XFLOAT_DATA (Vmax_image_size) * w);
!       h = (int) (XFLOAT_DATA (Vmax_image_size) * h);
!     }
!   else
!     return 1;
! 
!   return (width <= w && height <= h);
  }
  
  /* Prepare image IMG for display on frame F.  Must be called before
***************
*** 8289,8300 ****
    Fput (intern ("image-library-alist"), Qrisky_local_variable, Qt);
  
    DEFVAR_LISP ("max-image-size", &Vmax_image_size,
!     doc: /* Maximum size of an image, relative to the selected frame.
  
! This is a floating point number that is multiplied by the width and
  height of the selected frame, to give the maximum width and height for
! images.  Emacs will not load an image into memory if its width or
! height exceeds this limit. */);
    Vmax_image_size = make_float (MAX_IMAGE_SIZE);
  
    Vimage_type_cache = Qnil;
--- 8301,8319 ----
    Fput (intern ("image-library-alist"), Qrisky_local_variable, Qt);
  
    DEFVAR_LISP ("max-image-size", &Vmax_image_size,
!     doc: /* Maximum size of images.
! Emacs will not load an image into memory if its pixel width or
! pixel height exceeds this limit.
! 
! If the value is an integer it specifies the absolute maximum pixel
! width and pixel height for images.
  
! If the value is a floating point number it specifies a limit relative
! to the selected frame, i.e. the value is multiplied by the width and
  height of the selected frame, to give the maximum width and height for
! images.
! 
! Otherwise, no limit is placed on images.   */);
    Vmax_image_size = make_float (MAX_IMAGE_SIZE);
  
    Vimage_type_cache = Qnil;


*** display.texi        19 Oct 2005 10:20:40 +0200      1.191
--- display.texi        19 Oct 2005 13:12:43 +0200      
***************
*** 4061,4070 ****
  @defvar max-image-size
  @tindex max-image-size
  This variable is used to define the maximum size of image that Emacs
! will load.  If its value is a floating point number, that number is
! multiplied by the width and height of the selected frame, in pixels,
! to give the maximum image width and height.  Emacs will refuse to load
! and display any image that is larger than this.
  
  The purpose of this variable is to prevent unreasonably large images
  from accidentally being loaded into Emacs.  It only takes effect the
--- 4061,4074 ----
  @defvar max-image-size
  @tindex max-image-size
  This variable is used to define the maximum size of image that Emacs
! will load.  Emacs will refuse to load (and display) any image that is
! larger than this limit.
! 
! If its value is an integer, it specifies the absolute maximum width
! and height, in pixels, for images.  If its value is a floating point
! number, that number is multiplied by the width and height of the
! selected frame, in pixels, to give the maximum image width and height.
! Otherwise, no limit is placed on images.
  
  The purpose of this variable is to prevent unreasonably large images
  from accidentally being loaded into Emacs.  It only takes effect the


-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]