2014-05-28 08:56:42 +04:00
|
|
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
|
|
|
#include "stb_image_write.h"
|
|
|
|
|
2014-05-31 15:49:43 +04:00
|
|
|
#define STB_IMAGE_IMPLEMENTATION
|
|
|
|
#include "stb_image.h"
|
2014-05-28 08:56:42 +04:00
|
|
|
|
2014-06-03 19:45:34 +04:00
|
|
|
#define STB_DEFINE
|
|
|
|
#include "stb.h"
|
2014-05-28 08:56:42 +04:00
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int w,h;
|
2014-06-03 19:45:34 +04:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
2014-05-28 08:56:42 +04:00
|
|
|
return 0;
|
2014-05-28 22:05:17 +04:00
|
|
|
}
|