projects
/
fishladder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add two more achievment triggers
[fishladder.git]
/
qoiconv.c
diff --git
a/qoiconv.c
b/qoiconv.c
index 610f2b18d5dc376c844bac841e313969a5368931..366e92c0e5fc797b9a36e264e34dd673ab359eb4 100644
(file)
--- a/
qoiconv.c
+++ b/
qoiconv.c
@@
-38,7
+38,7
@@
SOFTWARE.
#include "stb/stb_image.h"
//#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb/stb_image.h"
//#define STB_IMAGE_WRITE_IMPLEMENTATION
-//#include "stb
/stb
_image_write.h"
+//#include "stb_image_write.h"
#define QOI_IMPLEMENTATION
#include "phoboslab/qoi.h"
#define QOI_IMPLEMENTATION
#include "phoboslab/qoi.h"
@@
-48,23
+48,26
@@
SOFTWARE.
int main(int argc, char **argv) {
if (argc < 3) {
int main(int argc, char **argv) {
if (argc < 3) {
- printf("Usage: qoiconv
infile outfile
\n");
+ printf("Usage: qoiconv
<infile> <outfile>
\n");
printf("Examples:\n");
printf("Examples:\n");
- printf(" qoiconv i
mage.png image
.qoi\n");
- printf(" qoiconv i
mage.qoi image
.png\n");
+ printf(" qoiconv i
nput.png output
.qoi\n");
+ printf(" qoiconv i
nput.qoi output
.png\n");
exit(1);
}
stbi_set_flip_vertically_on_load(1);
exit(1);
}
stbi_set_flip_vertically_on_load(1);
-
+
void *pixels = NULL;
void *pixels = NULL;
- int w, h;
+ int w, h
, channels
;
if (STR_ENDS_WITH(argv[1], ".png")) {
if (STR_ENDS_WITH(argv[1], ".png")) {
-
- pixels = (void *)stbi_load(argv[1], &w, &h, NULL, 4);
+ pixels = (void *)stbi_load(argv[1], &w, &h, &channels, 4);
}
else if (STR_ENDS_WITH(argv[1], ".qoi")) {
}
else if (STR_ENDS_WITH(argv[1], ".qoi")) {
- pixels = qoi_read(argv[1], &w, &h, 4);
+ qoi_desc desc;
+ pixels = qoi_read(argv[1], &desc, 0);
+ channels = desc.channels;
+ w = desc.width;
+ h = desc.height;
}
if (pixels == NULL) {
}
if (pixels == NULL) {
@@
-74,10
+77,15
@@
int main(int argc, char **argv) {
int encoded = 0;
if (STR_ENDS_WITH(argv[2], ".png")) {
int encoded = 0;
if (STR_ENDS_WITH(argv[2], ".png")) {
- //encoded = stbi_write_png(argv[2], w, h,
4
, pixels, 0);
+ //encoded = stbi_write_png(argv[2], w, h,
channels
, pixels, 0);
}
else if (STR_ENDS_WITH(argv[2], ".qoi")) {
}
else if (STR_ENDS_WITH(argv[2], ".qoi")) {
- encoded = qoi_write(argv[2], pixels, w, h, 4);
+ encoded = qoi_write(argv[2], pixels, &(qoi_desc){
+ .width = w,
+ .height = h,
+ .channels = 4,
+ .colorspace = QOI_SRGB
+ });
}
if (!encoded) {
}
if (!encoded) {
@@
-85,5
+93,6
@@
int main(int argc, char **argv) {
exit(1);
}
exit(1);
}
+ free(pixels);
return 0;
}
return 0;
}