comparison src/image.c @ 63323:ccf928f0383c

(x_create_x_image_and_pixmap) [HAVE_NTGUI]: Cast 4th arg to CreateDIBSection to avoid a compiler warning. (pbm_load): Cast 3rd arg to IMAGE_BACKGROUND to avoid a compiler warning. (png_load): Cast return values of fn_png_create_read_struct and fn_png_create_info_struct, to avoid compiler warnings on W32. Cast 3rd arg to IMAGE_BACKGROUND and image_background_transparent to avoid compiler warnings. (jpeg_load): Cast return value of fn_jpeg_std_error to avoid a compiler warning on W32. Cast 3rd arg to IMAGE_BACKGROUND to avoid a compiler warning. (tiff_load): Cast return values of fn_TIFFOpen and fn_TIFFClientOpen to avoid compiler warning on W32. Cast 3rd arg to IMAGE_BACKGROUND to avoid a compiler warning. (gif_load): Cast return values of fn_DGifOpenFileName and fn_DGifOpen to avoid compiler warnings on W32. Cast 3rd arg to IMAGE_BACKGROUND to avoid a compiler warning. (DrawText) [HAVE_NTGUI || MAC_OS]: If already defined, undef before redefining.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 11 Jun 2005 16:24:36 +0000
parents e369bf902cfc
children c95dbbf82d19 a1b34dec1104
comparison
equal deleted inserted replaced
63322:ca9285a9e7ee 63323:ccf928f0383c
1970 1970
1971 /* Create a DIBSection and raster array for the bitmap, 1971 /* Create a DIBSection and raster array for the bitmap,
1972 and store its handle in *pixmap. */ 1972 and store its handle in *pixmap. */
1973 *pixmap = CreateDIBSection (hdc, &((*ximg)->info), 1973 *pixmap = CreateDIBSection (hdc, &((*ximg)->info),
1974 (depth < 16) ? DIB_PAL_COLORS : DIB_RGB_COLORS, 1974 (depth < 16) ? DIB_PAL_COLORS : DIB_RGB_COLORS,
1975 &((*ximg)->data), NULL, 0); 1975 /* casting avoids a GCC warning */
1976 (void **)&((*ximg)->data), NULL, 0);
1976 1977
1977 /* Realize display palette and garbage all frames. */ 1978 /* Realize display palette and garbage all frames. */
1978 release_frame_dc (f, hdc); 1979 release_frame_dc (f, hdc);
1979 1980
1980 if (*pixmap == NULL) 1981 if (*pixmap == NULL)
5515 img->height = height; 5516 img->height = height;
5516 5517
5517 /* Maybe fill in the background field while we have ximg handy. */ 5518 /* Maybe fill in the background field while we have ximg handy. */
5518 5519
5519 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 5520 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
5520 IMAGE_BACKGROUND (img, f, ximg); 5521 /* Casting avoids a GCC warning. */
5522 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
5521 5523
5522 /* Put the image into a pixmap. */ 5524 /* Put the image into a pixmap. */
5523 x_put_x_image (f, ximg, img->pixmap, width, height); 5525 x_put_x_image (f, ximg, img->pixmap, width, height);
5524 x_destroy_x_image (ximg); 5526 x_destroy_x_image (ximg);
5525 5527
5841 5843
5842 /* Need to skip past the signature. */ 5844 /* Need to skip past the signature. */
5843 tbr.bytes += sizeof (sig); 5845 tbr.bytes += sizeof (sig);
5844 } 5846 }
5845 5847
5846 /* Initialize read and info structs for PNG lib. */ 5848 /* Initialize read and info structs for PNG lib. Casting return
5847 png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, 5849 value avoids a GCC warning on W32. */
5848 my_png_error, my_png_warning); 5850 png_ptr = (png_structp)fn_png_create_read_struct (PNG_LIBPNG_VER_STRING,
5851 NULL, my_png_error,
5852 my_png_warning);
5849 if (!png_ptr) 5853 if (!png_ptr)
5850 { 5854 {
5851 if (fp) fclose (fp); 5855 if (fp) fclose (fp);
5852 UNGCPRO; 5856 UNGCPRO;
5853 return 0; 5857 return 0;
5854 } 5858 }
5855 5859
5856 info_ptr = fn_png_create_info_struct (png_ptr); 5860 /* Casting return value avoids a GCC warning on W32. */
5861 info_ptr = (png_infop)fn_png_create_info_struct (png_ptr);
5857 if (!info_ptr) 5862 if (!info_ptr)
5858 { 5863 {
5859 fn_png_destroy_read_struct (&png_ptr, NULL, NULL); 5864 fn_png_destroy_read_struct (&png_ptr, NULL, NULL);
5860 if (fp) fclose (fp); 5865 if (fp) fclose (fp);
5861 UNGCPRO; 5866 UNGCPRO;
5862 return 0; 5867 return 0;
5863 } 5868 }
5864 5869
5865 end_info = fn_png_create_info_struct (png_ptr); 5870 /* Casting return value avoids a GCC warning on W32. */
5871 end_info = (png_infop)fn_png_create_info_struct (png_ptr);
5866 if (!end_info) 5872 if (!end_info)
5867 { 5873 {
5868 fn_png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 5874 fn_png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
5869 if (fp) fclose (fp); 5875 if (fp) fclose (fp);
5870 UNGCPRO; 5876 UNGCPRO;
6133 xfree (pixels); 6139 xfree (pixels);
6134 6140
6135 img->width = width; 6141 img->width = width;
6136 img->height = height; 6142 img->height = height;
6137 6143
6138 /* Maybe fill in the background field while we have ximg handy. */ 6144 /* Maybe fill in the background field while we have ximg handy.
6139 IMAGE_BACKGROUND (img, f, ximg); 6145 Casting avoids a GCC warning. */
6146 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
6140 6147
6141 /* Put the image into the pixmap, then free the X image and its buffer. */ 6148 /* Put the image into the pixmap, then free the X image and its buffer. */
6142 x_put_x_image (f, ximg, img->pixmap, width, height); 6149 x_put_x_image (f, ximg, img->pixmap, width, height);
6143 x_destroy_x_image (ximg); 6150 x_destroy_x_image (ximg);
6144 6151
6145 /* Same for the mask. */ 6152 /* Same for the mask. */
6146 if (mask_img) 6153 if (mask_img)
6147 { 6154 {
6148 /* Fill in the background_transparent field while we have the mask 6155 /* Fill in the background_transparent field while we have the
6149 handy. */ 6156 mask handy. Casting avoids a GCC warning. */
6150 image_background_transparent (img, f, mask_img); 6157 image_background_transparent (img, f, (XImagePtr_or_DC)mask_img);
6151 6158
6152 x_put_x_image (f, mask_img, img->mask, img->width, img->height); 6159 x_put_x_image (f, mask_img, img->mask, img->width, img->height);
6153 x_destroy_x_image (mask_img); 6160 x_destroy_x_image (mask_img);
6154 } 6161 }
6155 6162
6492 return 0; 6499 return 0;
6493 } 6500 }
6494 } 6501 }
6495 6502
6496 /* Customize libjpeg's error handling to call my_error_exit when an 6503 /* Customize libjpeg's error handling to call my_error_exit when an
6497 error is detected. This function will perform a longjmp. */ 6504 error is detected. This function will perform a longjmp.
6498 cinfo.err = fn_jpeg_std_error (&mgr.pub); 6505 Casting return value avoids a GCC warning on W32. */
6506 cinfo.err = (struct jpeg_error_mgr *)fn_jpeg_std_error (&mgr.pub);
6499 mgr.pub.error_exit = my_error_exit; 6507 mgr.pub.error_exit = my_error_exit;
6500 6508
6501 if ((rc = setjmp (mgr.setjmp_buffer)) != 0) 6509 if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
6502 { 6510 {
6503 if (rc == 1) 6511 if (rc == 1)
6604 if (fp) 6612 if (fp)
6605 fclose ((FILE *) fp); 6613 fclose ((FILE *) fp);
6606 6614
6607 /* Maybe fill in the background field while we have ximg handy. */ 6615 /* Maybe fill in the background field while we have ximg handy. */
6608 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 6616 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
6609 IMAGE_BACKGROUND (img, f, ximg); 6617 /* Casting avoids a GCC warning. */
6618 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
6610 6619
6611 /* Put the image into the pixmap. */ 6620 /* Put the image into the pixmap. */
6612 x_put_x_image (f, ximg, img->pixmap, width, height); 6621 x_put_x_image (f, ximg, img->pixmap, width, height);
6613 x_destroy_x_image (ximg); 6622 x_destroy_x_image (ximg);
6614 UNGCPRO; 6623 UNGCPRO;
6930 image_error ("Cannot find image file `%s'", specified_file, Qnil); 6939 image_error ("Cannot find image file `%s'", specified_file, Qnil);
6931 UNGCPRO; 6940 UNGCPRO;
6932 return 0; 6941 return 0;
6933 } 6942 }
6934 6943
6935 /* Try to open the image file. */ 6944 /* Try to open the image file. Casting return value avoids a
6936 tiff = fn_TIFFOpen (SDATA (file), "r"); 6945 GCC warning on W32. */
6946 tiff = (TIFF *)fn_TIFFOpen (SDATA (file), "r");
6937 if (tiff == NULL) 6947 if (tiff == NULL)
6938 { 6948 {
6939 image_error ("Cannot open `%s'", file, Qnil); 6949 image_error ("Cannot open `%s'", file, Qnil);
6940 UNGCPRO; 6950 UNGCPRO;
6941 return 0; 6951 return 0;
6946 /* Memory source! */ 6956 /* Memory source! */
6947 memsrc.bytes = SDATA (specified_data); 6957 memsrc.bytes = SDATA (specified_data);
6948 memsrc.len = SBYTES (specified_data); 6958 memsrc.len = SBYTES (specified_data);
6949 memsrc.index = 0; 6959 memsrc.index = 0;
6950 6960
6951 tiff = fn_TIFFClientOpen ("memory_source", "r", &memsrc, 6961 /* Casting return value avoids a GCC warning on W32. */
6952 (TIFFReadWriteProc) tiff_read_from_memory, 6962 tiff = (TIFF *)fn_TIFFClientOpen ("memory_source", "r", &memsrc,
6953 (TIFFReadWriteProc) tiff_write_from_memory, 6963 (TIFFReadWriteProc) tiff_read_from_memory,
6954 tiff_seek_in_memory, 6964 (TIFFReadWriteProc) tiff_write_from_memory,
6955 tiff_close_memory, 6965 tiff_seek_in_memory,
6956 tiff_size_of_memory, 6966 tiff_close_memory,
6957 tiff_mmap_memory, 6967 tiff_size_of_memory,
6958 tiff_unmap_memory); 6968 tiff_mmap_memory,
6969 tiff_unmap_memory);
6959 6970
6960 if (!tiff) 6971 if (!tiff)
6961 { 6972 {
6962 image_error ("Cannot open memory source for `%s'", img->spec, Qnil); 6973 image_error ("Cannot open memory source for `%s'", img->spec, Qnil);
6963 UNGCPRO; 6974 UNGCPRO;
7016 img->width = width; 7027 img->width = width;
7017 img->height = height; 7028 img->height = height;
7018 7029
7019 /* Maybe fill in the background field while we have ximg handy. */ 7030 /* Maybe fill in the background field while we have ximg handy. */
7020 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 7031 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
7021 IMAGE_BACKGROUND (img, f, ximg); 7032 /* Casting avoids a GCC warning on W32. */
7033 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
7022 7034
7023 /* Put the image into the pixmap, then free the X image and its buffer. */ 7035 /* Put the image into the pixmap, then free the X image and its buffer. */
7024 x_put_x_image (f, ximg, img->pixmap, width, height); 7036 x_put_x_image (f, ximg, img->pixmap, width, height);
7025 x_destroy_x_image (ximg); 7037 x_destroy_x_image (ximg);
7026 xfree (buf); 7038 xfree (buf);
7124 #endif /* HAVE_GIF || MAC_OS */ 7136 #endif /* HAVE_GIF || MAC_OS */
7125 7137
7126 #ifdef HAVE_GIF 7138 #ifdef HAVE_GIF
7127 7139
7128 #if defined (HAVE_NTGUI) || defined (MAC_OS) 7140 #if defined (HAVE_NTGUI) || defined (MAC_OS)
7141 /* winuser.h might define DrawText to DrawTextA or DrawTextW.
7142 Undefine before redefining to avoid a preprocessor warning. */
7143 #ifdef DrawText
7144 #undef DrawText
7145 #endif
7129 /* avoid conflict with QuickdrawText.h */ 7146 /* avoid conflict with QuickdrawText.h */
7130 #define DrawText gif_DrawText 7147 #define DrawText gif_DrawText
7131 #include <gif_lib.h> 7148 #include <gif_lib.h>
7132 #undef DrawText 7149 #undef DrawText
7133 7150
7237 image_error ("Cannot find image file `%s'", specified_file, Qnil); 7254 image_error ("Cannot find image file `%s'", specified_file, Qnil);
7238 UNGCPRO; 7255 UNGCPRO;
7239 return 0; 7256 return 0;
7240 } 7257 }
7241 7258
7242 /* Open the GIF file. */ 7259 /* Open the GIF file. Casting return value avoids a GCC warning
7243 gif = fn_DGifOpenFileName (SDATA (file)); 7260 on W32. */
7261 gif = (GifFileType *)fn_DGifOpenFileName (SDATA (file));
7244 if (gif == NULL) 7262 if (gif == NULL)
7245 { 7263 {
7246 image_error ("Cannot open `%s'", file, Qnil); 7264 image_error ("Cannot open `%s'", file, Qnil);
7247 UNGCPRO; 7265 UNGCPRO;
7248 return 0; 7266 return 0;
7254 current_gif_memory_src = &memsrc; 7272 current_gif_memory_src = &memsrc;
7255 memsrc.bytes = SDATA (specified_data); 7273 memsrc.bytes = SDATA (specified_data);
7256 memsrc.len = SBYTES (specified_data); 7274 memsrc.len = SBYTES (specified_data);
7257 memsrc.index = 0; 7275 memsrc.index = 0;
7258 7276
7259 gif = fn_DGifOpen(&memsrc, gif_read_from_memory); 7277 /* Casting return value avoids a GCC warning on W32. */
7278 gif = (GifFileType *)fn_DGifOpen(&memsrc, gif_read_from_memory);
7260 if (!gif) 7279 if (!gif)
7261 { 7280 {
7262 image_error ("Cannot open memory source `%s'", img->spec, Qnil); 7281 image_error ("Cannot open memory source `%s'", img->spec, Qnil);
7263 UNGCPRO; 7282 UNGCPRO;
7264 return 0; 7283 return 0;
7388 7407
7389 fn_DGifCloseFile (gif); 7408 fn_DGifCloseFile (gif);
7390 7409
7391 /* Maybe fill in the background field while we have ximg handy. */ 7410 /* Maybe fill in the background field while we have ximg handy. */
7392 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 7411 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
7393 IMAGE_BACKGROUND (img, f, ximg); 7412 /* Casting avoids a GCC warning. */
7413 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
7394 7414
7395 /* Put the image into the pixmap, then free the X image and its buffer. */ 7415 /* Put the image into the pixmap, then free the X image and its buffer. */
7396 x_put_x_image (f, ximg, img->pixmap, width, height); 7416 x_put_x_image (f, ximg, img->pixmap, width, height);
7397 x_destroy_x_image (ximg); 7417 x_destroy_x_image (ximg);
7398 7418
7399 UNGCPRO; 7419 UNGCPRO;
7400 return 1; 7420 return 1;
7401 } 7421 }
7402 7422
7403 #else 7423 #else /* !HAVE_GIF */
7404 7424
7405 #ifdef MAC_OS 7425 #ifdef MAC_OS
7406 static int 7426 static int
7407 gif_load (f, img) 7427 gif_load (f, img)
7408 struct frame *f; 7428 struct frame *f;