diff options
| author | Lars Ingebrigtsen | 2016-02-20 17:55:43 +1100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-02-20 18:03:37 +1100 |
| commit | ad1951dbfb7e289553c25474efdfa02f83c16e71 (patch) | |
| tree | 2b1a06150febcc319cefe0c0a4a87fa772beac06 /src/image.c | |
| parent | 0883e988ac950b2da2893e64822041ca0e6133a0 (diff) | |
| download | emacs-ad1951dbfb7e289553c25474efdfa02f83c16e71.tar.gz emacs-ad1951dbfb7e289553c25474efdfa02f83c16e71.zip | |
Get explicit width/height + scale computations right
* src/image.c (compute_image_size): :scale should also be
taken into account when :width and :height are explicitly names.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/image.c b/src/image.c index af65fdec7dc..9ba1a7972f0 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -8075,18 +8075,21 @@ compute_image_size (size_t width, size_t height, | |||
| 8075 | int desired_width, desired_height; | 8075 | int desired_width, desired_height; |
| 8076 | double scale = 1; | 8076 | double scale = 1; |
| 8077 | 8077 | ||
| 8078 | value = image_spec_value (spec, QCscale, NULL); | ||
| 8079 | if (NUMBERP (value)) | ||
| 8080 | scale = extract_float (value); | ||
| 8081 | |||
| 8078 | /* If width and/or height is set in the display spec assume we want | 8082 | /* If width and/or height is set in the display spec assume we want |
| 8079 | to scale to those values. If either h or w is unspecified, the | 8083 | to scale to those values. If either h or w is unspecified, the |
| 8080 | unspecified should be calculated from the specified to preserve | 8084 | unspecified should be calculated from the specified to preserve |
| 8081 | aspect ratio. */ | 8085 | aspect ratio. */ |
| 8082 | value = image_spec_value (spec, QCwidth, NULL); | 8086 | value = image_spec_value (spec, QCwidth, NULL); |
| 8083 | desired_width = NATNUMP (value) ? min (XFASTINT (value), INT_MAX) : -1; | 8087 | desired_width = NATNUMP (value) ? |
| 8088 | min (XFASTINT (value) * scale, INT_MAX) : -1; | ||
| 8084 | value = image_spec_value (spec, QCheight, NULL); | 8089 | value = image_spec_value (spec, QCheight, NULL); |
| 8085 | desired_height = NATNUMP (value) ? min (XFASTINT (value), INT_MAX) : -1; | 8090 | desired_height = NATNUMP (value) ? |
| 8091 | min (XFASTINT (value) * scale, INT_MAX) : -1; | ||
| 8086 | 8092 | ||
| 8087 | value = image_spec_value (spec, QCscale, NULL); | ||
| 8088 | if (NUMBERP (value)) | ||
| 8089 | scale = extract_float (value); | ||
| 8090 | width = width * scale; | 8093 | width = width * scale; |
| 8091 | height = height * scale; | 8094 | height = height * scale; |
| 8092 | 8095 | ||