diff src/image.c @ 55412:53a1a79a33f9

macterm.c (mac_check_for_quit_char): Adding BLOCK_INPUT around call to ReceiveEvent to avoid certain crashes. (mac_draw_line_to_pixmap, XCreatePixmapFromBitmapData) (mac_fill_rectangle_to_pixmap, mac_draw_rectangle_to_pixmap) (mac_copy_area_to_pixmap, mac_copy_area_with_mask_to_pixmap): Save/restore the current graphics port and device handle when drawing into an offscreen graphics world. image.c [MAC_OS] (XPutPixel, XGetPixel, image_load_qt_1) (gif_load): Likewise.
author Steven Tamm <steventamm@mac.com>
date Fri, 07 May 2004 17:46:50 +0000
parents b9215c2d57ad
children 30c03f9042b8
line wrap: on
line diff
--- a/src/image.c	Fri May 07 16:10:25 2004 +0000
+++ b/src/image.c	Fri May 07 17:46:50 2004 +0000
@@ -174,14 +174,19 @@
      int x, y;
      unsigned long pixel;
 {
+  CGrafPtr old_port;
+  GDHandle old_gdh;
   RGBColor color;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (ximage, NULL);
 
   color.red = RED16_FROM_ULONG (pixel);
   color.green = GREEN16_FROM_ULONG (pixel);
   color.blue = BLUE16_FROM_ULONG (pixel);
   SetCPixel (x, y, &color);
+
+  SetGWorld (old_port, old_gdh);
 }
 
 static unsigned long
@@ -189,11 +194,16 @@
      XImagePtr ximage;
      int x, y;
 {
+  CGrafPtr old_port;
+  GDHandle old_gdh;
   RGBColor color;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (ximage, NULL);
 
   GetCPixel (x, y, &color);
+
+  SetGWorld (old_port, old_gdh);
   return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8);
 }
 
@@ -2196,6 +2206,10 @@
     goto error;
   if (draw_all_pixels != graphicsImporterDrawsAllPixels)
     {
+      CGrafPtr old_port;
+      GDHandle old_gdh;
+
+      GetGWorld (&old_port, &old_gdh);
       SetGWorld (ximg, NULL);
       bg_color.red = color.red;
       bg_color.green = color.green;
@@ -2207,6 +2221,7 @@
 #else
       EraseRect (&(ximg->portRect));
 #endif
+      SetGWorld (old_port, old_gdh);
     }
   GraphicsImportSetGWorld (gi, ximg, NULL);
   GraphicsImportDraw (gi);
@@ -6883,6 +6898,8 @@
   TimeValue time;
   struct gcpro gcpro1;
   int ino;
+  CGrafPtr old_port;
+  GDHandle old_gdh;
 
   specified_file = image_spec_value (img->spec, QCfile, NULL);
   specified_data = image_spec_value (img->spec, QCdata, NULL);
@@ -7000,11 +7017,13 @@
   if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
     goto error;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (ximg, NULL);
   bg_color.red = color.red;
   bg_color.green = color.green;
   bg_color.blue = color.blue;
   RGBBackColor (&bg_color);
+  SetGWorld (old_port, old_gdh);
   SetMovieActive (movie, TRUE);
   SetMovieGWorld (movie, ximg, NULL);
   SampleNumToMediaTime (media, ino + 1, &time, NULL);