Update stb_image test code to test loading with all channel counts (including 0),
to avoid missing bugs like the recent TGA bug in the future. Doesn't check the *results*, but tests that it doesn't crash or fail.
This commit is contained in:
parent
23a775cc13
commit
f5dfba0b8b
@ -14,7 +14,12 @@ int main(int argc, char **argv)
|
|||||||
int i;
|
int i;
|
||||||
for (i=1; i < argc; ++i) {
|
for (i=1; i < argc; ++i) {
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
int n;
|
||||||
printf("%s\n", argv[i]);
|
printf("%s\n", argv[i]);
|
||||||
|
data = stbi_load(argv[i], &w, &h, &n, 4); if (data) free(data); else printf("Failed &n\n");
|
||||||
|
data = stbi_load(argv[i], &w, &h, 0, 1); if (data) free(data); else printf("Failed 1\n");
|
||||||
|
data = stbi_load(argv[i], &w, &h, 0, 2); if (data) free(data); else printf("Failed 2\n");
|
||||||
|
data = stbi_load(argv[i], &w, &h, 0, 3); if (data) free(data); else printf("Failed 3\n");
|
||||||
data = stbi_load(argv[i], &w, &h, 0, 4);
|
data = stbi_load(argv[i], &w, &h, 0, 4);
|
||||||
assert(data);
|
assert(data);
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -22,16 +27,21 @@ int main(int argc, char **argv)
|
|||||||
stb_splitpath(fname, argv[i], STB_FILE);
|
stb_splitpath(fname, argv[i], STB_FILE);
|
||||||
stbi_write_png(stb_sprintf("output/%s.png", fname), w, h, 4, data, w*4);
|
stbi_write_png(stb_sprintf("output/%s.png", fname), w, h, 4, data, w*4);
|
||||||
free(data);
|
free(data);
|
||||||
}
|
} else
|
||||||
|
printf("FAILED 4\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i;
|
||||||
char **files = stb_readdir_files("images");
|
char **files = stb_readdir_files("images");
|
||||||
for (i=0; i < stb_arr_len(files); ++i) {
|
for (i=0; i < stb_arr_len(files); ++i) {
|
||||||
|
int n;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
printf("%s\n", files[i]);
|
printf("%s\n", files[i]);
|
||||||
|
data = stbi_load(files[i], &w, &h, &n, 4); if (data) free(data); else printf("Failed &n\n");
|
||||||
|
data = stbi_load(files[i], &w, &h, 0, 1); if (data) free(data); else printf("Failed 1\n");
|
||||||
|
data = stbi_load(files[i], &w, &h, 0, 2); if (data) free(data); else printf("Failed 2\n");
|
||||||
|
data = stbi_load(files[i], &w, &h, 0, 3); if (data) free(data); else printf("Failed 3\n");
|
||||||
data = stbi_load(files[i], &w, &h, 0, 4);
|
data = stbi_load(files[i], &w, &h, 0, 4);
|
||||||
//assert(data);
|
|
||||||
if (data) {
|
if (data) {
|
||||||
char fname[512];
|
char fname[512];
|
||||||
stb_splitpath(fname, files[i], STB_FILE);
|
stb_splitpath(fname, files[i], STB_FILE);
|
||||||
|
Loading…
Reference in New Issue
Block a user