Doxygen Source Code Documentation
gifx.h File Reference
#include "gif.h"
#include <X11/Xlib.h>
Go to the source code of this file.
Define Documentation
|
|
Typedef Documentation
|
|
|
|
Function Documentation
|
Definition at line 729 of file gifx.c. References Gif_XContext::closest, delete_colormap_hook(), delete_xcolormap(), Gif_XContext::display, Gif_Delete, Gif_DeleteArray, Gif_RemoveDeletionHook(), GIF_T_COLORMAP, Gif_XContext::image_gc, Gif_XContext::mask_gc, Gif_XContext::refcount, and Gif_XContext::xcolormap. Referenced by delete_viewer().
00730 { 00731 if (!gfx) return; 00732 if (--gfx->refcount > 0) return; 00733 while (gfx->xcolormap) 00734 delete_xcolormap(gfx->xcolormap); 00735 if (gfx->image_gc) 00736 XFreeGC(gfx->display, gfx->image_gc); 00737 if (gfx->mask_gc) 00738 XFreeGC(gfx->display, gfx->mask_gc); 00739 Gif_DeleteArray(gfx->closest); 00740 Gif_Delete(gfx); 00741 Gif_RemoveDeletionHook(GIF_T_COLORMAP, delete_colormap_hook, gfx); 00742 } |
|
Definition at line 719 of file gifx.c. References display, and Gif_NewXContextFromVisual().
00720 { 00721 XWindowAttributes attr; 00722 XGetWindowAttributes(display, window, &attr); 00723 return Gif_NewXContextFromVisual(display, XScreenNumberOfScreen(attr.screen), 00724 attr.visual, attr.depth, attr.colormap); 00725 } |
|
|
Definition at line 199 of file gifx.c. References allocate_colors(), and find_x_colormap_extension().
00200 { 00201 Gif_XColormap *gfxc = find_x_colormap_extension(gfx, gfcm, 1); 00202 if (gfxc) { 00203 allocate_colors(gfxc); 00204 return 1; 00205 } else 00206 return 0; 00207 } |
|
Definition at line 219 of file gifx.c. References Gif_XColormap::allocated, Gif_XColormap::claimed, find_x_colormap_extension(), Gif_NewArray, Gif_Stream::global, global, i, Gif_Stream::images, Gif_Image::local, Gif_Stream::nimages, Gif_XColormap::npixels, Gif_XColormap::pixels, and pixels.
00220 { 00221 int i; 00222 int npixels = 0; 00223 unsigned long *pixels; 00224 Gif_Colormap *global = gfs->global; 00225 *np_store = 0; 00226 00227 for (i = 0; i < gfs->nimages; i++) { 00228 Gif_Image *gfi = gfs->images[i]; 00229 Gif_Colormap *gfcm = (gfi->local ? gfi->local : global); 00230 Gif_XColormap *gfxc = find_x_colormap_extension(gfx, gfcm, 0); 00231 if (gfxc && gfxc->allocated && gfxc->claimed == 0) { 00232 gfxc->claimed = 2; 00233 npixels += gfxc->npixels; 00234 if (gfcm == global) global = 0; 00235 } 00236 } 00237 00238 if (!npixels) return 0; 00239 00240 pixels = Gif_NewArray(unsigned long, npixels); 00241 if (!pixels) return 0; 00242 *np_store = npixels; 00243 00244 npixels = 0; 00245 global = gfs->global; 00246 for (i = 0; i < gfs->nimages; i++) { 00247 Gif_Image *gfi = gfs->images[i]; 00248 Gif_Colormap *gfcm = (gfi->local ? gfi->local : global); 00249 Gif_XColormap *gfxc = find_x_colormap_extension(gfx, gfcm, 0); 00250 if (gfxc && gfxc->allocated && gfxc->claimed == 2) { 00251 memcpy(pixels + npixels, gfxc->pixels, gfxc->npixels); 00252 npixels += gfxc->npixels; 00253 gfxc->claimed = 1; 00254 if (gfcm == global) global = 0; 00255 } 00256 } 00257 00258 return pixels; 00259 } |
|
Definition at line 210 of file gifx.c. References deallocate_colors(), and find_x_colormap_extension().
00211 { 00212 Gif_XColormap *gfxc = find_x_colormap_extension(gfx, gfcm, 0); 00213 if (gfxc) 00214 deallocate_colors(gfxc); 00215 } |
|
Definition at line 422 of file gifx.c. References Gif_XSubImageColormap(), Gif_Stream::global, Gif_Image::height, Gif_Stream::images, Gif_Image::local, Gif_Stream::nimages, and Gif_Image::width. Referenced by Gif_XNextImage(), and view_frame().
00423 { 00424 Gif_Colormap *gfcm; 00425 if (!gfi && gfs->nimages) gfi = gfs->images[0]; 00426 if (!gfi) return None; 00427 gfcm = gfi->local; 00428 if (!gfcm) gfcm = gfs->global; 00429 return Gif_XSubImageColormap(gfx, gfi, gfcm, 00430 0, 0, gfi->width, gfi->height); 00431 } |
|
Definition at line 434 of file gifx.c. References Gif_XSubImageColormap(), Gif_Image::height, Gif_Stream::images, Gif_Stream::nimages, and Gif_Image::width.
00436 { 00437 if (!gfi && gfs->nimages) gfi = gfs->images[0]; 00438 if (!gfi) return None; 00439 return Gif_XSubImageColormap(gfx, gfi, gfcm, 00440 0, 0, gfi->width, gfi->height); 00441 } |
|
Definition at line 543 of file gifx.c. References Gif_XSubMask(), Gif_Image::height, Gif_Stream::images, Gif_Stream::nimages, and Gif_Image::width. Referenced by Gif_XNextImage().
00544 { 00545 if (!gfi && gfs->nimages) gfi = gfs->images[0]; 00546 if (!gfi) return None; 00547 return Gif_XSubMask(gfx, gfi, 0, 0, gfi->width, gfi->height); 00548 } |
|
Definition at line 552 of file gifx.c. References allocate_colors(), Gif_Stream::background, Gif_XContext::depth, Gif_XContext::display, Gif_Image::disposal, Gif_XContext::drawable, error_exit(), find_x_colormap_extension(), GIF_DISPOSAL_BACKGROUND, GIF_DISPOSAL_PREVIOUS, Gif_XImage(), Gif_XMask(), Gif_Stream::global, Gif_Image::height, Gif_XContext::image_gc, Gif_Stream::images, Gif_Image::left, Gif_Image::local, Gif_Colormap::ncol, Gif_XColormap::pixels, put_sub_image_colormap(), Gif_Stream::screen_height, Gif_Stream::screen_width, Gif_Image::top, Gif_Image::transparent, Gif_XContext::transparent_pixel, and Gif_Image::width. Referenced by unoptimized_frame().
00554 { 00555 Pixmap pixmap = None, image = None, mask = None; 00556 Gif_Image *gfi = gfs->images[n]; 00557 Gif_Image *last_gfi = (n > 0 ? gfs->images[n-1] : 0); 00558 Gif_Colormap *gfcm = (gfi->local ? gfi->local : gfs->global); 00559 unsigned long bg_pixel; 00560 unsigned long old_transparent = gfx->transparent_pixel; 00561 00562 if (gfs->screen_width == 0 || gfs->screen_height == 0) 00563 return None; 00564 00565 if (gfi->width == gfs->screen_width && gfi->height == gfs->screen_height 00566 && gfi->left == 0 && gfi->top == 0 && gfi->transparent < 0) 00567 return Gif_XImage(gfx, gfs, gfi); 00568 00569 /* create the pixmap */ 00570 pixmap = XCreatePixmap(gfx->display, gfx->drawable, 00571 gfs->screen_width, gfs->screen_height, gfx->depth); 00572 if (!pixmap) goto error_exit; 00573 00574 /* find background color if necessary */ 00575 if (last == None 00576 || (last_gfi && last_gfi->disposal == GIF_DISPOSAL_BACKGROUND)) { 00577 /* find bg_pixel */ 00578 if (gfs->global && gfs->background < gfs->global->ncol 00579 && gfs->images[0]->transparent < 0) { 00580 Gif_XColormap *gfxc = find_x_colormap_extension(gfx, gfcm, 1); 00581 if (!gfxc) 00582 return None; 00583 allocate_colors(gfxc); 00584 bg_pixel = gfxc->pixels[gfs->background]; 00585 } else 00586 bg_pixel = old_transparent; 00587 /* install it as the foreground color on gfx->image_gc */ 00588 if (!gfx->image_gc) 00589 gfx->image_gc = XCreateGC(gfx->display, pixmap, 0, 0); 00590 if (!gfx->image_gc) goto error_exit; 00591 XSetForeground(gfx->display, gfx->image_gc, bg_pixel); 00592 gfx->transparent_pixel = bg_pixel; 00593 } 00594 00595 /* if there is no `last' then we need special handling */ 00596 if (last == None 00597 || (last_gfi && last_gfi->width == gfs->screen_width 00598 && last_gfi->height == gfs->screen_height 00599 && last_gfi->left == 0 && last_gfi->top == 0 00600 && last_gfi->disposal == GIF_DISPOSAL_BACKGROUND)) { 00601 XFillRectangle(gfx->display, pixmap, gfx->image_gc, 0, 0, 00602 gfs->screen_width, gfs->screen_height); 00603 if (!put_sub_image_colormap(gfx, gfi, gfcm, 0, 0, gfi->width, gfi->height, 00604 pixmap, gfi->left, gfi->top)) 00605 goto error_exit; 00606 return pixmap; 00607 } 00608 00609 /* use the disposal to create the intermediate image */ 00610 XCopyArea(gfx->display, last, pixmap, gfx->image_gc, 00611 0, 0, gfs->screen_width, gfs->screen_height, 0, 0); 00612 if (last_last != None && last_gfi->disposal == GIF_DISPOSAL_PREVIOUS) 00613 XCopyArea(gfx->display, last_last, pixmap, gfx->image_gc, 00614 last_gfi->left, last_gfi->top, last_gfi->width, last_gfi->height, 00615 last_gfi->left, last_gfi->top); 00616 else if (last_gfi->disposal == GIF_DISPOSAL_BACKGROUND) 00617 XFillRectangle(gfx->display, pixmap, gfx->image_gc, 00618 last_gfi->left, last_gfi->top, 00619 last_gfi->width, last_gfi->height); 00620 00621 /* apply image */ 00622 if (gfi->transparent < 0) { 00623 if (!put_sub_image_colormap(gfx, gfi, gfcm, 0, 0, gfi->width, gfi->height, 00624 pixmap, gfi->left, gfi->top)) 00625 goto error_exit; 00626 } else { 00627 image = Gif_XImage(gfx, gfs, gfi); 00628 mask = Gif_XMask(gfx, gfs, gfi); 00629 if (image == None || mask == None) goto error_exit; 00630 XSetClipMask(gfx->display, gfx->image_gc, mask); 00631 XSetClipOrigin(gfx->display, gfx->image_gc, gfi->left, gfi->top); 00632 XCopyArea(gfx->display, image, pixmap, gfx->image_gc, 00633 0, 0, gfi->width, gfi->height, gfi->left, gfi->top); 00634 XSetClipMask(gfx->display, gfx->image_gc, None); 00635 XFreePixmap(gfx->display, image); 00636 XFreePixmap(gfx->display, mask); 00637 } 00638 00639 gfx->transparent_pixel = old_transparent; 00640 return pixmap; 00641 00642 error_exit: 00643 if (pixmap) XFreePixmap(gfx->display, pixmap); 00644 if (image) XFreePixmap(gfx->display, image); 00645 if (mask) XFreePixmap(gfx->display, mask); 00646 gfx->transparent_pixel = old_transparent; 00647 return None; 00648 } |
|
Definition at line 444 of file gifx.c. References Gif_XSubImageColormap(), Gif_Stream::global, Gif_Stream::images, left, Gif_Image::local, Gif_Stream::nimages, and top.
00446 { 00447 Gif_Colormap *gfcm; 00448 if (!gfi && gfs->nimages) gfi = gfs->images[0]; 00449 if (!gfi) return None; 00450 gfcm = gfi->local; 00451 if (!gfcm) gfcm = gfs->global; 00452 return Gif_XSubImageColormap(gfx, gfi, gfcm, 00453 left, top, width, height); 00454 } |
|
Definition at line 406 of file gifx.c. References Gif_XContext::depth, Gif_XContext::display, Gif_XContext::drawable, left, put_sub_image_colormap(), and top. Referenced by Gif_XImage(), Gif_XImageColormap(), and Gif_XSubImage().
00408 { 00409 Pixmap pixmap = 00410 XCreatePixmap(gfx->display, gfx->drawable, width, height, gfx->depth); 00411 if (pixmap) { 00412 if (put_sub_image_colormap(gfx, gfi, gfcm, left, top, width, height, 00413 pixmap, 0, 0)) 00414 return pixmap; 00415 else 00416 XFreePixmap(gfx->display, pixmap); 00417 } 00418 return None; 00419 } |
|
Definition at line 458 of file gifx.c. References BYTESIZE, Gif_Image::compressed, Gif_XContext::display, Gif_XContext::drawable, Gif_DeleteArray, Gif_NewArray, Gif_ReleaseUncompressedImage(), Gif_UncompressImage, Gif_Image::height, i, Gif_Image::image_data, Gif_Image::img, left, Gif_XContext::mask_gc, top, Gif_Image::transparent, u_int32_t, Gif_XContext::visual, and Gif_Image::width. Referenced by Gif_XMask().
00460 { 00461 Pixmap pixmap = None; 00462 XImage *ximage; 00463 byte *xdata; 00464 00465 int i, j; 00466 int transparent; 00467 int bytes_per_line; 00468 int release_uncompressed = 0; 00469 00470 /* Find the correct image */ 00471 if (!gfi) return None; 00472 00473 /* Check subimage dimensions */ 00474 if (width <= 0 || height <= 0 || left < 0 || top < 0 00475 || left+width <= 0 || top+height <= 0 00476 || left+width > gfi->width || top+height > gfi->height) 00477 return None; 00478 00479 /* Make sure the image is uncompressed */ 00480 if (!gfi->img && !gfi->image_data && gfi->compressed) { 00481 Gif_UncompressImage(gfi); 00482 release_uncompressed = 1; 00483 } 00484 00485 /* Create the X image */ 00486 ximage = 00487 XCreateImage(gfx->display, gfx->visual, 1, 00488 XYBitmap, 0, NULL, 00489 width, height, 00490 8, 0); 00491 00492 ximage->bitmap_bit_order = ximage->byte_order = LSBFirst; 00493 bytes_per_line = ximage->bytes_per_line; 00494 xdata = Gif_NewArray(byte, bytes_per_line * height); 00495 ximage->data = (char *)xdata; 00496 00497 transparent = gfi->transparent; 00498 00499 /* The main loop */ 00500 for (j = 0; j < height; j++) { 00501 int imshift = 0; 00502 u_int32_t impixel = 0; 00503 byte *line = gfi->img[top + j] + left; 00504 byte *writer = xdata + bytes_per_line * j; 00505 00506 for (i = 0; i < width; i++) { 00507 if (line[i] == transparent) 00508 impixel |= 1 << imshift; 00509 00510 if (++imshift >= BYTESIZE) { 00511 *writer++ = impixel; 00512 imshift = 0; 00513 impixel = 0; 00514 } 00515 } 00516 00517 if (imshift) 00518 *writer++ = impixel; 00519 } 00520 00521 /* Create the pixmap */ 00522 pixmap = 00523 XCreatePixmap(gfx->display, gfx->drawable, width, height, 1); 00524 if (!gfx->mask_gc) 00525 gfx->mask_gc = XCreateGC(gfx->display, pixmap, 0, 0); 00526 00527 if (pixmap && gfx->mask_gc) 00528 XPutImage(gfx->display, pixmap, gfx->mask_gc, ximage, 0, 0, 0, 0, 00529 width, height); 00530 00531 Gif_DeleteArray(xdata); 00532 ximage->data = 0; /* avoid freeing it again in XDestroyImage */ 00533 XDestroyImage(ximage); 00534 00535 if (release_uncompressed) 00536 Gif_ReleaseUncompressedImage(gfi); 00537 00538 return pixmap; 00539 } |