This commit is contained in:
Andrew Haynes
2026-03-22 18:51:47 -04:00
parent b986e7394e
commit c0bfdb484d
+21 -17
View File
@@ -1,4 +1,5 @@
#include "image/imgio.h"
#include <stdio.h>
#include <stdlib.h>
#include <turbojpeg.h>
@@ -93,6 +94,7 @@ ppm_save(const unsigned int* buf, const PPM img)
return 10;
}
printf("test 1");
fprintf(fptr, "P%c\n%d %d\n255\n", img.fmt, img.width, img.height);
if (img.fmt == '3')
{
@@ -108,6 +110,7 @@ ppm_save(const unsigned int* buf, const PPM img)
}
}
}
printf("test 2");
if (img.fmt == '6')
{
for (int i = 0; i < img.len; i++)
@@ -118,6 +121,7 @@ ppm_save(const unsigned int* buf, const PPM img)
}
fwrite(dst_buf, 1, img.len * 3, fptr);
}
printf("test 3");
fclose(fptr);
free(dst_buf);
printf("Encode Done!\n");
@@ -195,7 +199,7 @@ transcode_to_jpeg(PPM* in, JPEG* out)
out->width = in->width;
out->height = in->height;
jpeg_save(dst, out, out->name);
free(dst);
free(dst);
}
void
@@ -206,26 +210,26 @@ transcode_to_ppm(JPEG* input, PPM* out)
out->height = input->height;
out->len = out->width * out->height;
ppm_save(dst, *out);
free(dst);
free(dst);
}
PPM
inherit_from_jpeg(const JPEG* in, const char fmt) {
PPM image = {
.width = in->width,
.height = in->height,
.len = in->width * in->height,
.fmt = fmt
};
return image;
inherit_from_jpeg(const JPEG* in, const char fmt)
{
PPM image = { .width = in->width,
.height = in->height,
.len = in->width * in->height,
.fmt = fmt };
return image;
}
JPEG
inherit_from_ppm(const PPM* in) {
JPEG image = {
.width = in->width,
.height = in->height,
.len = in->width * in->height,
};
return image;
inherit_from_ppm(const PPM* in)
{
JPEG image = {
.width = in->width,
.height = in->height,
.len = in->width * in->height,
};
return image;
}