X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgifload.c;h=fc2fc28af8602ee4cb20a2efede6ba6223576cfb;hp=f26ba5a1702349551b61668052e84b0a4919bbef;hb=3367ba5eaec57086e3c1013708967e8a995ef2e3;hpb=e4566563844c4bcfc472159c9ae870941099708c diff --git a/src/gifload.c b/src/gifload.c index f26ba5a1..fc2fc28a 100644 --- a/src/gifload.c +++ b/src/gifload.c @@ -17,24 +17,30 @@ #include "xli.h" +#ifdef DEBUG +#define DEBUG_TIMING +#endif -extern Pixmap test_pix[]; -extern Pixmap test_clipmask[]; -extern int test_picture_count; +extern long Counter(void); -int Read_GIF_to_Pixmaps(Display *display, Window window, char *filename) +int Read_GIF_to_Pixmaps(Display *display, Window window, char *filename, + Pixmap *pixmap, Pixmap *pixmap_mask) { Image *image, *image_mask; XImageInfo *ximageinfo, *ximageinfo_mask; - Pixmap pixmap, pixmap_mask; int screen; Visual *visual; unsigned int depth; +#ifdef DEBUG_TIMING + long count1, count2; + count1 = Counter(); +#endif + /* load GIF file */ if (!(image = gifLoad(filename))) { @@ -42,6 +48,13 @@ int Read_GIF_to_Pixmaps(Display *display, Window window, char *filename) exit(1); } +#ifdef DEBUG_TIMING + count2 = Counter(); + printf(" LOADING '%s' IN %.2f SECONDS\n", + filename, (float)(count2-count1)/100.0); + count1 = Counter(); +#endif + if (image->depth > 8) { printf("Sorry, GIFs with more than 256 colors are not supported.\n"); @@ -51,6 +64,13 @@ int Read_GIF_to_Pixmaps(Display *display, Window window, char *filename) /* minimize colormap */ compress(image); +#ifdef DEBUG_TIMING + count2 = Counter(); + printf(" COMPRESSING IMAGE COLORMAP IN %.2f SECONDS\n", + (float)(count2-count1)/100.0); + count1 = Counter(); +#endif + screen = DefaultScreen(display); visual = DefaultVisual(display, screen); depth = DefaultDepth(display, screen); @@ -62,32 +82,40 @@ int Read_GIF_to_Pixmaps(Display *display, Window window, char *filename) exit(1); } - if (ximageinfo->cmap != DefaultColormap(display, screen)) - { - /* - printf("--> '%s' gets own colormap\n", filename); - */ +#ifdef DEBUG_TIMING + count2 = Counter(); + printf(" CONVERTING IMAGE TO XIMAGE IN %.2f SECONDS\n", + (float)(count2-count1)/100.0); + count1 = Counter(); +#endif + if (ximageinfo->cmap != DefaultColormap(display, screen)) XSetWindowColormap(display, window, ximageinfo->cmap); - } /* convert XImage to Pixmap */ - if ((pixmap = ximageToPixmap(display, window, ximageinfo)) == None) + if ((*pixmap = ximageToPixmap(display, window, ximageinfo)) == None) { fprintf(stderr, "Cannot convert XImage to Pixmap.\n"); exit(1); } - /* - printf("test_picture_count == %d\n", test_picture_count); - */ - - test_pix[test_picture_count] = pixmap; - +#ifdef DEBUG_TIMING + count2 = Counter(); + printf(" CONVERTING IMAGE TO PIXMAP IN %.2f SECONDS\n", + (float)(count2-count1)/100.0); + count1 = Counter(); +#endif /* create mono image for masking */ image_mask = monochrome(image); +#ifdef DEBUG_TIMING + count2 = Counter(); + printf(" CONVERTING IMAGE TO MASK IN %.2f SECONDS\n", + (float)(count2-count1)/100.0); + count1 = Counter(); +#endif + /* convert internal image structure to X11 XImage */ if (!(ximageinfo_mask = imageToXImage(display, screen, visual, depth, image_mask))) @@ -96,18 +124,26 @@ int Read_GIF_to_Pixmaps(Display *display, Window window, char *filename) exit(1); } +#ifdef DEBUG_TIMING + count2 = Counter(); + printf(" CONVERTING MASK TO XIMAGE IN %.2f SECONDS\n", + (float)(count2-count1)/100.0); + count1 = Counter(); +#endif + /* convert XImage to Pixmap */ - if ((pixmap_mask = ximageToPixmap(display, window, ximageinfo_mask)) == None) + if ((*pixmap_mask = ximageToPixmap(display, window, ximageinfo_mask)) == None) { fprintf(stderr, "Cannot convert XImage to Pixmap.\n"); exit(1); } - - test_clipmask[test_picture_count] = pixmap_mask; - - test_picture_count++; - +#ifdef DEBUG_TIMING + count2 = Counter(); + printf(" CONVERTING MASK TO PIXMAP IN %.2f SECONDS\n", + (float)(count2-count1)/100.0); + count1 = Counter(); +#endif return(GIF_Success); }