summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Joye <pierre.php@gmail.com>2022-01-22 17:29:04 +0700
committerGitHub <noreply@github.com>2022-01-22 17:29:04 +0700
commitf1a53c082173567b8ad07eaba8fc7ba66457a730 (patch)
tree4b2752d19dd8d7f847dc4dd10936bf2ec0e20427 /tests
parent0f9dd9627aa9f5095164a73e84905bb4af4bfc8f (diff)
downloadlibgd-f1a53c082173567b8ad07eaba8fc7ba66457a730.tar.gz
#788 fix bug in HEIF usage, stride is require (#801)
fix bug #788 in HEIF usage, stride is require
Diffstat (limited to 'tests')
-rw-r--r--tests/heif/CMakeLists.txt1
-rw-r--r--tests/heif/bug788.c43
-rw-r--r--tests/heif/bug788.pngbin0 -> 124720 bytes
3 files changed, 44 insertions, 0 deletions
diff --git a/tests/heif/CMakeLists.txt b/tests/heif/CMakeLists.txt
index 4a41528..a45b957 100644
--- a/tests/heif/CMakeLists.txt
+++ b/tests/heif/CMakeLists.txt
@@ -5,6 +5,7 @@ LIST(APPEND TESTS_FILES
heif_null
heif_ptr_double_free
heif_read
+ bug788
)
ENDIF(HEIF_FOUND)
diff --git a/tests/heif/bug788.c b/tests/heif/bug788.c
new file mode 100644
index 0000000..5475251
--- /dev/null
+++ b/tests/heif/bug788.c
@@ -0,0 +1,43 @@
+/**
+ * Bug 788 stride not implemented.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+#include <libheif/heif.h>
+
+int main () {
+ FILE *fp;
+ gdImagePtr in;
+ gdImagePtr dst;
+ gdImagePtr diff;
+ int size;
+ void *data;
+ CuTestImageResult result = {0, 0};
+ fp = gdTestFileOpen2("heif", "bug788.png");
+ in = gdImageCreateFromPng(fp);
+ fclose(fp);
+ fp = fopen("1.png", "wb");
+ gdImagePng(in, fp);
+ fclose(fp);
+ data = gdImageHeifPtrEx(in, &size, 200, GD_HEIF_CODEC_HEVC, GD_HEIF_CHROMA_444);
+
+ dst = gdImageCreateFromHeifPtr(size, data);
+ diff = gdImageCreateTrueColor(gdImageSX(dst), gdImageSY(dst));
+ if (gdTestAssertMsg(dst != NULL, "cannot compare with NULL buffer")) {
+ gdTestImageDiff(in, dst, diff, &result);
+ }
+ fp = fopen("2.png", "wb");
+ gdImageHeif(dst, fp);
+ fclose(fp);
+ fp = fopen("3.png", "wb");
+ gdImagePng(diff, fp);
+ fclose(fp);
+ /* colorspace conversion cannot avoid colors differences, even if we use the same format/colorspace for in and out */
+ gdTestAssertMsg(result.pixels_changed > 30, "pixels changed: %d\n", result.pixels_changed);
+ gdImageDestroy(dst);
+ gdImageDestroy(in);
+ gdImageDestroy(diff);
+ return 0;
+} \ No newline at end of file
diff --git a/tests/heif/bug788.png b/tests/heif/bug788.png
new file mode 100644
index 0000000..953ef6e
--- /dev/null
+++ b/tests/heif/bug788.png
Binary files differ