Fix handling of iphone-procesed image to not accidentally appear corrupt (instead they just load wrong).

Add a proper testing path to image test
This commit is contained in:
Sean Barrett
2014-06-03 08:45:34 -07:00
parent 687985dbf9
commit 334cec8d8c
3 changed files with 43 additions and 14 deletions

View File

@ -4,12 +4,42 @@
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#define STB_DEFINE
#include "stb.h"
int main(int argc, char **argv)
{
int w,h;
unsigned char *data = stbi_load(argv[1], &w, &h, 0, 4);
if (data)
stbi_write_png("c:/x/result.png", w, h, 4, data, w*4);
if (argc > 1) {
int i;
for (i=1; i < argc; ++i) {
unsigned char *data;
printf("%s\n", argv[i]);
data = stbi_load(argv[i], &w, &h, 0, 4);
assert(data);
if (data) {
char fname[512];
stb_splitpath(fname, argv[i], STB_FILE);
stbi_write_png(stb_sprintf("output/%s.png", fname), w, h, 4, data, w*4);
free(data);
}
}
} else {
int i;
char **files = stb_readdir_files("images");
for (i=0; i < stb_arr_len(files); ++i) {
unsigned char *data;
printf("%s\n", files[i]);
data = stbi_load(files[i], &w, &h, 0, 4);
//assert(data);
if (data) {
char fname[512];
stb_splitpath(fname, files[i], STB_FILE);
stbi_write_png(stb_sprintf("output/%s.png", fname), w, h, 4, data, w*4);
free(data);
} else
printf("FAILED\n");
}
}
return 0;
}

View File

@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@ -84,9 +84,5 @@ LINK32=link.exe
SOURCE=..\image_test.c
# End Source File
# Begin Source File
SOURCE=..\..\stb_image_write.h
# End Source File
# End Target
# End Project