1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include <stdio.h>
#include "gd.h"
#include "gdtest.h"
int main()
{
gdImagePtr im;
int error = 0;
int c, c1, c2, c3, c4, color;
im = gdImageCreateTrueColor(5, 5);
c = gdImageColorExact(im, 255, 0, 255);
c2 = gdImageColorExactAlpha(im, 255, 0, 255, 100);
gdImageDestroy(im);
if (gdTestAssert(c == 0xFF00FF) != 1) {
error = -1;
}
if (gdTestAssert(c2 == 0x64FF00FF) != 1) {
error = -1;
}
im = gdImageCreate(5, 5);
c1 = gdImageColorAllocate(im, 255, 0, 255);
c2 = gdImageColorAllocate(im, 255, 200, 0);
c3 = gdImageColorAllocateAlpha(im, 255, 0, 255, 100);
c1 = gdImageColorExact(im, 255, 0, 255);
c2 = gdImageColorExact(im, 255, 200, 0);
c3 = gdImageColorExactAlpha(im, 255, 0, 255, 100);
c4 = gdImageColorExactAlpha(im, 255, 34, 255, 100);
if (gdTestAssert(c1 == 0) != 1) {
error = -1;
}
if (gdTestAssert(c2 == 1) != 1) {
error = -1;
}
if (gdTestAssert(c3 == 2) != 1) {
error = -1;
}
if (gdTestAssert(c4 == -1) != 1) {
error = -1;
}
color = gdTrueColorAlpha(gdImageRed(im, c1), gdImageGreen(im, c1),
gdImageBlue(im, c1), 0);
if (gdTestAssert(color == 0xFF00FF) != 1) {
error = -1;
}
color = gdTrueColorAlpha(gdImageRed(im, c2), gdImageGreen(im, c2),
gdImageBlue(im, c2), 0);
if (gdTestAssert(color == 0xFFC800) != 1) {
error = -1;
}
color = gdTrueColorAlpha(gdImageRed(im, c3), gdImageGreen(im, c3),
gdImageBlue(im, c3), 0);
if (gdTestAssert(color == 0xFF00FF) != 1) {
error = -1;
}
gdImageDestroy(im);
return error;
}
|