diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-04-10 03:40:48 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-04-10 03:40:48 +0000 |
commit | 503c0227622254c0ae3209a1fa72bcb68bb450bc (patch) | |
tree | 48df20533f300f819504c15af33cdc03fc386a93 /Build/source/libs/gd/libgd-src/tests/gd2/createimagefromgd2partptr.c | |
parent | a9d86b73ecf95b83666e16c4d90e348c4958a63b (diff) |
libgd 2.3.0
git-svn-id: svn://tug.org/texlive/trunk@54636 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/gd/libgd-src/tests/gd2/createimagefromgd2partptr.c')
-rw-r--r-- | Build/source/libs/gd/libgd-src/tests/gd2/createimagefromgd2partptr.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/createimagefromgd2partptr.c b/Build/source/libs/gd/libgd-src/tests/gd2/createimagefromgd2partptr.c new file mode 100644 index 00000000000..e432874667f --- /dev/null +++ b/Build/source/libs/gd/libgd-src/tests/gd2/createimagefromgd2partptr.c @@ -0,0 +1,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; +} |