comparison src/image.c @ 83494:b901f4f12f33

Merged from emacs@sv.gnu.org Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-160 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-161 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-162 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-163 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-164 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-165 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-166 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-167 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-168 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-169 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-170 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-171 Update from CVS: man/mh-e.texi (Folders): Various edits. * emacs@sv.gnu.org/emacs--devo--0--patch-172 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-58 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-59 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-60 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-61 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-62 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-63 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-64 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-534
author Karoly Lorentey <lorentey@elte.hu>
date Wed, 22 Mar 2006 15:16:06 +0000
parents 414faf8dce4e 65b669e90ff5
children 81f2d90dee68
comparison
equal deleted inserted replaced
83493:1bf2ca323037 83494:b901f4f12f33
187 unsigned long pixel; 187 unsigned long pixel;
188 { 188 {
189 PixMapHandle pixmap = GetGWorldPixMap (ximage); 189 PixMapHandle pixmap = GetGWorldPixMap (ximage);
190 short depth = GetPixDepth (pixmap); 190 short depth = GetPixDepth (pixmap);
191 191
192 #if defined (WORDS_BIG_ENDIAN) || !USE_CG_DRAWING
192 if (depth == 32) 193 if (depth == 32)
193 { 194 {
194 char *base_addr = GetPixBaseAddr (pixmap); 195 char *base_addr = GetPixBaseAddr (pixmap);
195 short row_bytes = GetPixRowBytes (pixmap); 196 short row_bytes = GetPixRowBytes (pixmap);
196 197
197 ((unsigned long *) (base_addr + y * row_bytes))[x] = 0xff000000 | pixel; 198 ((unsigned long *) (base_addr + y * row_bytes))[x] = 0xff000000 | pixel;
198 } 199 }
199 else if (depth == 1) 200 else
201 #endif
202 if (depth == 1)
200 { 203 {
201 char *base_addr = GetPixBaseAddr (pixmap); 204 char *base_addr = GetPixBaseAddr (pixmap);
202 short row_bytes = GetPixRowBytes (pixmap); 205 short row_bytes = GetPixRowBytes (pixmap);
203 206
204 if (pixel == PIX_MASK_DRAW) 207 if (pixel == PIX_MASK_DRAW)
231 int x, y; 234 int x, y;
232 { 235 {
233 PixMapHandle pixmap = GetGWorldPixMap (ximage); 236 PixMapHandle pixmap = GetGWorldPixMap (ximage);
234 short depth = GetPixDepth (pixmap); 237 short depth = GetPixDepth (pixmap);
235 238
239 #if defined (WORDS_BIG_ENDIAN) || !USE_CG_DRAWING
236 if (depth == 32) 240 if (depth == 32)
237 { 241 {
238 char *base_addr = GetPixBaseAddr (pixmap); 242 char *base_addr = GetPixBaseAddr (pixmap);
239 short row_bytes = GetPixRowBytes (pixmap); 243 short row_bytes = GetPixRowBytes (pixmap);
240 244
241 return ((unsigned long *) (base_addr + y * row_bytes))[x] & 0x00ffffff; 245 return ((unsigned long *) (base_addr + y * row_bytes))[x] & 0x00ffffff;
242 } 246 }
243 else if (depth == 1) 247 else
248 #endif
249 if (depth == 1)
244 { 250 {
245 char *base_addr = GetPixBaseAddr (pixmap); 251 char *base_addr = GetPixBaseAddr (pixmap);
246 short row_bytes = GetPixRowBytes (pixmap); 252 short row_bytes = GetPixRowBytes (pixmap);
247 253
248 if (base_addr[y * row_bytes + x / 8] & (1 << (~x & 7))) 254 if (base_addr[y * row_bytes + x / 8] & (1 << (~x & 7)))
270 XDestroyImage (ximg) 276 XDestroyImage (ximg)
271 XImagePtr ximg; 277 XImagePtr ximg;
272 { 278 {
273 UnlockPixels (GetGWorldPixMap (ximg)); 279 UnlockPixels (GetGWorldPixMap (ximg));
274 } 280 }
281
282 #if USE_CG_DRAWING
283 static CGImageRef
284 mac_create_cg_image_from_image (f, img)
285 struct frame *f;
286 struct image *img;
287 {
288 Pixmap mask;
289 CGImageRef result = NULL;
290
291 BLOCK_INPUT;
292 if (img->mask)
293 mask = img->mask;
294 else
295 {
296 mask = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
297 img->width, img->height, 1);
298 if (mask)
299 {
300 CGrafPtr old_port;
301 GDHandle old_gdh;
302 Rect r;
303
304 GetGWorld (&old_port, &old_gdh);
305 SetGWorld (mask, NULL);
306 BackColor (blackColor); /* Don't mask. */
307 SetRect (&r, 0, 0, img->width, img->height);
308 EraseRect (&r);
309 SetGWorld (old_port, old_gdh);
310 }
311 }
312 if (mask)
313 {
314 CreateCGImageFromPixMaps (GetGWorldPixMap (img->pixmap),
315 GetGWorldPixMap (mask), &result);
316 if (mask != img->mask)
317 XFreePixmap (FRAME_X_DISPLAY (f), mask);
318 }
319 UNBLOCK_INPUT;
320
321 return result;
322 }
323 #endif /* USE_CG_DRAWING */
275 #endif /* MAC_OS */ 324 #endif /* MAC_OS */
276 325
277 326
278 /* Functions to access the contents of a bitmap, given an id. */ 327 /* Functions to access the contents of a bitmap, given an id. */
279 328
1204 1253
1205 /* If IMG doesn't have a pixmap yet, load it now, using the image 1254 /* If IMG doesn't have a pixmap yet, load it now, using the image
1206 type dependent loader function. */ 1255 type dependent loader function. */
1207 if (img->pixmap == NO_PIXMAP && !img->load_failed_p) 1256 if (img->pixmap == NO_PIXMAP && !img->load_failed_p)
1208 img->load_failed_p = img->type->load (f, img) == 0; 1257 img->load_failed_p = img->type->load (f, img) == 0;
1258
1259 #if defined (MAC_OS) && USE_CG_DRAWING
1260 if (!img->load_failed_p && img->data.ptr_val == NULL)
1261 {
1262 img->data.ptr_val = mac_create_cg_image_from_image (f, img);
1263 if (img->data.ptr_val == NULL)
1264 {
1265 img->load_failed_p = 1;
1266 img->type->free (f, img);
1267 }
1268 }
1269 #endif
1209 } 1270 }
1210 1271
1211 1272
1212 /* Value is the number of pixels for the ascent of image IMG when 1273 /* Value is the number of pixels for the ascent of image IMG when
1213 drawn in face FACE. */ 1274 drawn in face FACE. */
1450 #endif /* HAVE_X_WINDOWS */ 1511 #endif /* HAVE_X_WINDOWS */
1451 xfree (img->colors); 1512 xfree (img->colors);
1452 img->colors = NULL; 1513 img->colors = NULL;
1453 img->ncolors = 0; 1514 img->ncolors = 0;
1454 } 1515 }
1516
1517 #if defined (MAC_OS) && USE_CG_DRAWING
1518 if (img->data.ptr_val)
1519 {
1520 CGImageRelease (img->data.ptr_val);
1521 img->data.ptr_val = NULL;
1522 }
1523 #endif
1455 } 1524 }
1456 1525
1457 /* Free X resources of image IMG which is used on frame F. */ 1526 /* Free X resources of image IMG which is used on frame F. */
1458 1527
1459 static void 1528 static void