From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: image size limit? Date: Wed, 19 Oct 2005 14:51:33 +0200 Message-ID: References: <87oe5v7q19.fsf@stupidchicken.com> <87k6giiqh3.fsf@pacem.orebokech.com> <87hdbht7v9.fsf@stupidchicken.com> <87d5m3zu20.fsf@stupidchicken.com> <85ek6hitq3.fsf@lola.goethe.zz> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1129737468 10816 80.91.229.2 (19 Oct 2005 15:57:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 19 Oct 2005 15:57:48 +0000 (UTC) Cc: Chong Yidong , emacs-devel@gnu.org, Stefan Monnier , rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 19 17:57:43 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1ESGGm-0005Ir-Nx for ged-emacs-devel@m.gmane.org; Wed, 19 Oct 2005 17:54:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ESGGm-0003aP-68 for ged-emacs-devel@m.gmane.org; Wed, 19 Oct 2005 11:54:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ESDRK-0003Z0-RL for emacs-devel@gnu.org; Wed, 19 Oct 2005 08:53:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ESDR7-0003Xe-SI for emacs-devel@gnu.org; Wed, 19 Oct 2005 08:53:00 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ESDQr-0003Wj-SO for emacs-devel@gnu.org; Wed, 19 Oct 2005 08:52:39 -0400 Original-Received: from [195.41.46.236] (helo=pfepb.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ESDQY-00061n-IU; Wed, 19 Oct 2005 08:52:18 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (unknown [80.165.4.124]) by pfepb.post.tele.dk (Postfix) with SMTP id 282525EE083; Wed, 19 Oct 2005 14:52:10 +0200 (CEST) Original-To: David Kastrup In-Reply-To: <85ek6hitq3.fsf@lola.goethe.zz> (David Kastrup's message of "Wed, 19 Oct 2005 14:20:20 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:44324 Archived-At: David Kastrup 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 http://www.cua.dk