Many changes just look at the new documentation and such

This commit is contained in:
Andrew Haynes
2026-08-31 22:18:42 -04:00
parent 5367c71c34
commit 854f5c2ba6
7 changed files with 139 additions and 47 deletions
+5 -4
View File
@@ -65,7 +65,7 @@ ppm_load(const char* file, PPM* m_attr)
}
int
ppm_save(const unsigned int* buf, const PPM img)
ppm_save(const unsigned int* buf, const PPM img, char* name)
{
if (!buf)
{
@@ -82,12 +82,12 @@ ppm_save(const unsigned int* buf, const PPM img)
if (img.fmt == '3')
{
fptr = fopen(img.name, "w");
fptr = fopen(name, "w");
}
if (img.fmt == '6')
{
fptr = fopen(img.name, "wb");
fptr = fopen(name, "wb");
}
if (!fptr)
@@ -125,6 +125,7 @@ ppm_save(const unsigned int* buf, const PPM img)
fclose(fptr);
free(dst_buf);
printf("Encode Done!\n");
printf("Image: %s is saved.\n", name);
return 1;
}
@@ -209,7 +210,7 @@ transcode_to_ppm(JPEG* input, PPM* out)
out->width = input->width;
out->height = input->height;
out->len = out->width * out->height;
ppm_save(dst, *out);
ppm_save(dst, *out, out->name);
free(dst);
}
+19 -5
View File
@@ -1,4 +1,6 @@
#include <stdlib.h>
#include "image/filters.h"
#include "image/utils.h"
// #include "image/filters.h"
// #include "image/transformations.h"
@@ -7,16 +9,28 @@
int
main()
{
JPEG out_1 = {
.name = "../MF8jno.jpg",
// JPEG out_1 = {
// .name = "../MF8jno.jpg",
//
// };
PPM img = {
.name = "../IMG_1649.ppm",
};
};
unsigned int* buf = ppm_load(img.name, &img);
for (int i = 0; i < img.len; i++)
{
// you need to replace the old value with the new updated value
buf[i] = u32_grayscale(buf[i]);
}
ppm_save(buf, img, "../IMG_1649_new.ppm");
// PPM out_2 = inherit_from_jpeg(&out_1, '6');
//
//
PPM out = inherit_from_jpeg(&out_1, '6');
// print_attr(&out);
// PPM out = inherit_from_jpeg(&out_1, '6');
// print_attr(&out);
// unsigned int* src_buf = ppm_load("../assets/8ktest.ppm", &out_2);
// unsigned int* blurred = box_blur(src_buf, &out_2, 10);
// unsigned int* flip = u32_rotate(src_buf_jpeg, );