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
|
/**
* Base test for gdImageCreateFromGd2PartPtr()
*/
#include "gd.h"
#include "gdtest.h"
#include <stdio.h>
int main()
{
FILE *p;
gdImagePtr im, partim;
void *pg;
int size = 0;
int status = 0;
int actual_color = 0;
int expected_color = 0xffffff;
p = gdTestFileOpen2("gd2", "conv_test.gd2");
if (!p) {
gdTestErrorMsg("failed, cannot open gd2 file:conv_test.gd2");
return 1;
}
im = gdImageCreateFromGd2(p);
fclose(p);
if (!im) {
gdTestErrorMsg("failed, cannot create gd2 file.");
return 1;
}
pg = gdImageGd2Ptr(im, (GD2_CHUNKSIZE_MIN + GD2_CHUNKSIZE_MAX) / 2, GD2_FMT_COMPRESSED, &size);
if (!pg) {
status = 1;
goto done1;
}
if (size <= 0) {
status = 1;
goto done0;
}
partim = gdImageCreateFromGd2PartPtr(size, pg, 3, 3, 3, 3);
if (!partim) {
status = 1;
goto done0;
}
actual_color = gdImageGetPixel(partim, 2, 2);
status = (expected_color == actual_color) ? 0 : 1;
gdImageDestroy(partim);
done0:
gdFree(pg);
done1:
gdImageDestroy(im);
return status;
}
|