summaryrefslogtreecommitdiff
path: root/tests/tga
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2016-08-16 14:27:23 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2016-08-16 14:27:23 +0200
commit4f8e26f2a40ffaa3a5b77be6a49989a1a42e2b83 (patch)
tree11f1a2bdcc71102ff42d1c3296d4e41ba9650038 /tests/tga
parentf756f3d9e48ebff358701cbfd0af9dfb1fb416f7 (diff)
downloadlibgd-4f8e26f2a40ffaa3a5b77be6a49989a1a42e2b83.tar.gz
Fix #290: TGA RLE decoding is broken
We make it work only, for now. Actually, it doesn't make sense that `oTga::bitmap` is an `int *` as we're storing only bytes there. If this will be changed, we can even get rid of the `conversion_buffer` in `read_image_tga` altogether, and read the image data into the `decompression_buffer` (if RLE'd) or the `tga->bitmap` (if uncompressed) directly.
Diffstat (limited to 'tests/tga')
-rw-r--r--tests/tga/CMakeLists.txt1
-rw-r--r--tests/tga/Makemodule.am8
-rw-r--r--tests/tga/tga_read.c40
-rw-r--r--tests/tga/tga_read_rgb.pngbin0 -> 2349 bytes
-rw-r--r--tests/tga/tga_read_rgb.tgabin0 -> 90444 bytes
-rw-r--r--tests/tga/tga_read_rgb_rle.tgabin0 -> 9987 bytes
6 files changed, 47 insertions, 2 deletions
diff --git a/tests/tga/CMakeLists.txt b/tests/tga/CMakeLists.txt
index c3a589c..789fb14 100644
--- a/tests/tga/CMakeLists.txt
+++ b/tests/tga/CMakeLists.txt
@@ -5,6 +5,7 @@ LIST(APPEND TESTS_FILES
bug00247a
bug00248
bug00248a
+ tga_read
)
ADD_GD_TESTS()
diff --git a/tests/tga/Makemodule.am b/tests/tga/Makemodule.am
index dff828f..a1e6af6 100644
--- a/tests/tga/Makemodule.am
+++ b/tests/tga/Makemodule.am
@@ -4,7 +4,8 @@ libgd_test_programs += \
tga/bug00247a \
tga/bug00248 \
tga/bug00248a \
- tga/tga_null
+ tga/tga_null \
+ tga/tga_read
EXTRA_DIST += \
tga/CMakeLists.txt \
@@ -12,4 +13,7 @@ EXTRA_DIST += \
tga/bug00247.tga \
tga/bug00247a.tga \
tga/bug00248.tga \
- tga/bug00248a.tga
+ tga/bug00248a.tga \
+ tga/tga_read_rgb.png \
+ tga/tga_read_rgb.tga \
+ tga/tga_read_rgb_rle.tga
diff --git a/tests/tga/tga_read.c b/tests/tga/tga_read.c
new file mode 100644
index 0000000..310b72f
--- /dev/null
+++ b/tests/tga/tga_read.c
@@ -0,0 +1,40 @@
+/**
+ * Basic test case for reading TGA files.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void assert_equals(char *exp, char *orig);
+
+
+int main()
+{
+ assert_equals("tga_read_rgb.png", "tga_read_rgb.tga");
+ assert_equals("tga_read_rgb.png", "tga_read_rgb_rle.tga");
+
+ return gdNumFailures();
+}
+
+
+static void assert_equals(char *exp, char *orig)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *filename;
+
+ fp = gdTestFileOpen2("tga", orig);
+ gdTestAssertMsg(fp != NULL, "can't open %s", orig);
+
+ im = gdImageCreateFromTga(fp);
+ gdTestAssertMsg(im != NULL, "can't read %s", orig);
+ fclose(fp);
+
+ filename = gdTestFilePath2("tga", exp);
+ gdAssertImageEqualsToFile(filename, im);
+ gdFree(filename);
+
+ gdImageDestroy(im);
+}
diff --git a/tests/tga/tga_read_rgb.png b/tests/tga/tga_read_rgb.png
new file mode 100644
index 0000000..bc468e3
--- /dev/null
+++ b/tests/tga/tga_read_rgb.png
Binary files differ
diff --git a/tests/tga/tga_read_rgb.tga b/tests/tga/tga_read_rgb.tga
new file mode 100644
index 0000000..5f11f5a
--- /dev/null
+++ b/tests/tga/tga_read_rgb.tga
Binary files differ
diff --git a/tests/tga/tga_read_rgb_rle.tga b/tests/tga/tga_read_rgb_rle.tga
new file mode 100644
index 0000000..ce845ad
--- /dev/null
+++ b/tests/tga/tga_read_rgb_rle.tga
Binary files differ