Mercurial > emacs
comparison src/image.c @ 93759:4e76a03232e5
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1107
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 05 Apr 2008 23:01:26 +0000 |
parents | 1c088baa9d2d 296f5c781a2b |
children | a0615a586d39 |
comparison
equal
deleted
inserted
replaced
93758:abcbb8375c30 | 93759:4e76a03232e5 |
---|---|
5799 height = pbm_scan_number (&p, end); | 5799 height = pbm_scan_number (&p, end); |
5800 | 5800 |
5801 if (type != PBM_MONO) | 5801 if (type != PBM_MONO) |
5802 { | 5802 { |
5803 max_color_idx = pbm_scan_number (&p, end); | 5803 max_color_idx = pbm_scan_number (&p, end); |
5804 if (raw_p && max_color_idx > 255) | 5804 if (max_color_idx > 65535 || max_color_idx < 0) |
5805 max_color_idx = 255; | 5805 { |
5806 } | 5806 image_error ("Unsupported maximum PBM color value", Qnil, Qnil); |
5807 | 5807 goto error; |
5808 if (!check_image_size (f, width, height) | 5808 } |
5809 || (type != PBM_MONO && max_color_idx < 0)) | 5809 } |
5810 goto error; | 5810 |
5811 if (!check_image_size (f, width, height)) | |
5812 { | |
5813 image_error ("Invalid image size", Qnil, Qnil); | |
5814 goto error; | |
5815 } | |
5811 | 5816 |
5812 if (!x_create_x_image_and_pixmap (f, width, height, 0, | 5817 if (!x_create_x_image_and_pixmap (f, width, height, 0, |
5813 &ximg, &img->pixmap)) | 5818 &ximg, &img->pixmap)) |
5814 goto error; | 5819 goto error; |
5815 | 5820 |
5865 XPutPixel (ximg, x, y, g ? fg : bg); | 5870 XPutPixel (ximg, x, y, g ? fg : bg); |
5866 } | 5871 } |
5867 } | 5872 } |
5868 else | 5873 else |
5869 { | 5874 { |
5870 if (raw_p | 5875 int expected_size = height * width; |
5871 && ((type == PBM_GRAY) | 5876 if (max_color_idx > 255) |
5872 ? (p + height * width > end) | 5877 expected_size *= 2; |
5873 : (p + 3 * height * width > end))) | 5878 if (type == PBM_COLOR) |
5879 expected_size *= 3; | |
5880 | |
5881 if (raw_p && p + expected_size > end) | |
5874 { | 5882 { |
5875 x_destroy_x_image (ximg); | 5883 x_destroy_x_image (ximg); |
5876 x_clear_image (f, img); | 5884 x_clear_image (f, img); |
5877 image_error ("Invalid image size in image `%s'", | 5885 image_error ("Invalid image size in image `%s'", |
5878 img->spec, Qnil); | 5886 img->spec, Qnil); |
5882 for (y = 0; y < height; ++y) | 5890 for (y = 0; y < height; ++y) |
5883 for (x = 0; x < width; ++x) | 5891 for (x = 0; x < width; ++x) |
5884 { | 5892 { |
5885 int r, g, b; | 5893 int r, g, b; |
5886 | 5894 |
5887 if (type == PBM_GRAY) | 5895 if (type == PBM_GRAY && raw_p) |
5888 r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end); | 5896 { |
5897 r = g = b = *p++; | |
5898 if (max_color_idx > 255) | |
5899 r = g = b = r * 256 + *p++; | |
5900 } | |
5901 else if (type == PBM_GRAY) | |
5902 r = g = b = pbm_scan_number (&p, end); | |
5889 else if (raw_p) | 5903 else if (raw_p) |
5890 { | 5904 { |
5891 r = *p++; | 5905 r = *p++; |
5906 if (max_color_idx > 255) | |
5907 r = r * 256 + *p++; | |
5892 g = *p++; | 5908 g = *p++; |
5909 if (max_color_idx > 255) | |
5910 g = g * 256 + *p++; | |
5893 b = *p++; | 5911 b = *p++; |
5912 if (max_color_idx > 255) | |
5913 b = b * 256 + *p++; | |
5894 } | 5914 } |
5895 else | 5915 else |
5896 { | 5916 { |
5897 r = pbm_scan_number (&p, end); | 5917 r = pbm_scan_number (&p, end); |
5898 g = pbm_scan_number (&p, end); | 5918 g = pbm_scan_number (&p, end); |