~reviczky/luatex/texlive-bin-git

« back to all changes in this revision

Viewing changes to libs/gd/libgd-2.1.0/src/gdcmpgif.c

  • Committer: Adam Reviczky
  • Date: 2015-04-26 22:40:47 UTC
  • Revision ID: adam.reviczky@kclalumni.net-20150426224047-i2p26n3wqphupq6z
TeX Live 2015 import (rev. 37052)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifdef HAVE_CONFIG_H
2
 
#include "config.h"
3
 
#endif
4
 
 
5
 
#include <stdio.h>
6
 
#include <stdlib.h>
7
 
#ifndef _WIN32
8
 
#include <unistd.h> /* For unlink function */
9
 
#endif
10
 
 
11
 
#include "gd.h"
12
 
 
13
 
/* A short program which converts a .png file into a .gd file, for
14
 
        your convenience in creating images on the fly from a
15
 
        basis image that must be loaded quickly. The .gd format
16
 
        is not intended to be a general-purpose format. */
17
 
 
18
 
void CompareImages(char *msg, gdImagePtr im1, gdImagePtr im2);
19
 
 
20
 
 
21
 
int main(int argc, char **argv)
22
 
{
23
 
        gdImagePtr im1, im2;
24
 
        FILE *in;
25
 
 
26
 
        if (argc != 3) {
27
 
                fprintf(stderr, "Usage: gdcmpgif filename.gif filename.gif\n");
28
 
                exit(1);
29
 
        }
30
 
        in = fopen(argv[1], "rb");
31
 
        if (!in) {
32
 
                fprintf(stderr, "Input file does not exist!\n");
33
 
                exit(1);
34
 
        }
35
 
        im1 = gdImageCreateFromGif(in);
36
 
        fclose(in);
37
 
 
38
 
        if (!im1) {
39
 
                fprintf(stderr, "Input is not in GIF format!\n");
40
 
                exit(1);
41
 
        }
42
 
 
43
 
        in = fopen(argv[2], "rb");
44
 
        if (!in) {
45
 
                fprintf(stderr, "Input file 2 does not exist!\n");
46
 
                exit(1);
47
 
        }
48
 
        im2 = gdImageCreateFromGif(in);
49
 
        fclose(in);
50
 
 
51
 
        if (!im2) {
52
 
                fprintf(stderr, "Input 2 is not in GIF format!\n");
53
 
                exit(1);
54
 
        }
55
 
 
56
 
        CompareImages("gdcmpgif", im1, im2);
57
 
 
58
 
        gdImageDestroy(im1);
59
 
        gdImageDestroy(im2);
60
 
 
61
 
        return 0;
62
 
}
63
 
 
64
 
void CompareImages(char *msg, gdImagePtr im1, gdImagePtr im2)
65
 
{
66
 
        int cmpRes;
67
 
 
68
 
        cmpRes = gdImageCompare(im1, im2);
69
 
 
70
 
        if (cmpRes & GD_CMP_IMAGE) {
71
 
                printf("%%%s: ERROR images differ: BAD\n",msg);
72
 
        } else if (cmpRes != 0) {
73
 
                printf("%%%s: WARNING images differ: WARNING - Probably OK\n",msg);
74
 
        } else {
75
 
                printf("%%%s: OK\n",msg);
76
 
                return;
77
 
        }
78
 
 
79
 
        if (cmpRes & (GD_CMP_SIZE_X + GD_CMP_SIZE_Y)) {
80
 
                printf("-%s: INFO image sizes differ\n",msg);
81
 
        }
82
 
 
83
 
        if (cmpRes & GD_CMP_NUM_COLORS) {
84
 
                printf("-%s: INFO number of palette entries differ %d Vs. %d\n",msg,
85
 
                       im1->colorsTotal, im2->colorsTotal);
86
 
        }
87
 
 
88
 
        if (cmpRes & GD_CMP_COLOR) {
89
 
                printf("-%s: INFO actual colours of pixels differ\n",msg);
90
 
        }
91
 
}
92
 
 
93