From 19492f71a364f72e5af6962e7bd4260de8813961 Mon Sep 17 00:00:00 2001 From: Andrew Haynes Date: Mon, 13 Jul 2026 02:05:09 -0400 Subject: [PATCH] Print attributes for ppm --- .DS_Store | Bin 6148 -> 8196 bytes include/image/utils.h | 2 ++ src/imgio.c | 8 ++++++++ src/main.c | 27 +++++++++++++++++---------- src/utils.c | 10 ++++++++++ 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/.DS_Store b/.DS_Store index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..7192c57822e5a5cd178f6eb2d8d730a032b5b52f 100644 GIT binary patch literal 8196 zcmeHM%}>-o6n_IKT@fi?ii)wi7ZZsrA{yhtvO)|8vq%X-0GDoCmTI@Nwp~yO$sRoE zAK)LLCof)2yy(e;(WCL^!GFMuXMOXr?Ba?yKN4q>dB4~9(KqvJrqkI40Fte^BLD*c zpkZgIccA!5V}90~T8p%FArj1opg3YVv{Y`2R0hR>Vn8vV7*Gr-2L2TWaL;B<+hyMu zUL_R+ih=)<0rq|{uro9zRt54`2MT@!Kx{)ZZ>Z}`K{OP(clvoug(t*gs2a%PDJfRR?9q(`Oa3H2YB^3jTfo2BS*}VEZm<#gGK5ZX zy)7T1CTHV2>vA^aU2Qg>biFp8)V_}Wod>$~?w;Q6zV811{+>evhkK3==Jno!?c6R# zY@AnUK%;C>@$!0CjI*6`XgD2t>p08##JihV{(W@y{E#r?xi{;k*?VP->8l&~O|M3t z7cLef-_5PA#$Gbtpf9j$PDF!Xn#O+O({N#lS5LgsRJcm9A{#-j%v|xD7sZH8Ir9s4 z6xm_X%idcK?1C5M!YoY^TAKH97Hs6aq*b;ZKP;v%e-R|6(&j0l>5#7Rn(C`*5=r`% zE7aN0E_s+VEiTjMWL0PyoQ83*Uxq+{3v>7Y~(Ue#fh!$*W|K~I)p&0mU477^M1MK`ix%=<`e{FoK zuwpw5aE@Piqz_pm2gF}!R pBnTAa1`@77thzDrJM(0I8AV3M$)+;eJWLRCKt?lcj^~-f3;-dB4=?}# diff --git a/include/image/utils.h b/include/image/utils.h index ef26136..2038416 100644 --- a/include/image/utils.h +++ b/include/image/utils.h @@ -57,4 +57,6 @@ u32to_u64(const unsigned int clr); unsigned int u64to_u32(const unsigned long clr, const unsigned long u64_div); +void __attribute__((overloadable)) print_attr(const PPM *src); + #endif diff --git a/src/imgio.c b/src/imgio.c index 9608ae1..2b9899e 100644 --- a/src/imgio.c +++ b/src/imgio.c @@ -233,3 +233,11 @@ inherit_from_ppm(const PPM* in) }; return image; } + +/** The Second image gets merged into the first. + * The First image obtains attributes from the second image that were not found. +*/ +PPM +merge_ppm(const PPM* in_1, const PPM* in_2) { + if(in) +} diff --git a/src/main.c b/src/main.c index 56f8b58..96beafb 100644 --- a/src/main.c +++ b/src/main.c @@ -1,20 +1,27 @@ #include #include "image/utils.h" -#include "image/filters.h" -// #include "transformations.h" +// #include "image/filters.h" +// #include "image/transformations.h" #include "image/imgio.h" int main() { - PPM out = { - .name = "../test.ppm", - }; + JPEG out_1 = { + .name = "../MF8jno.jpg", - unsigned int* src_buf = ppm_load("../assets/8ktest.ppm", &out); - unsigned int* blurred = box_blur(src_buf, &out, 10); - ppm_save(blurred, out); - free(src_buf); - free(blurred); + }; + + // PPM out_2 = inherit_from_jpeg(&out_1, '6'); + // + // + 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, ); + // ppm_save(blurred, out_2); + // free(src_buf); + // free(blurred); return 0; } diff --git a/src/utils.c b/src/utils.c index b1ef2db..a04e804 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,4 +1,5 @@ #include "image/utils.h" +#include unsigned long u32to_u64(const unsigned int clr) @@ -21,3 +22,12 @@ u64to_u32(const unsigned long clr, const unsigned long u64_div) return ENCODE_ARGB((a / u64_div), (r / u64_div), (g / u64_div), (b / u64_div)); } + +// Utilizing new knowledge below + +void +__attribute__((overloadable)) +print_attr(const PPM *src) { + printf("Name: %s\nFMT: %c\nWidth: %i, Height: %i\nLength: %i", + src->name, src->fmt, src->width, src->height, src->len); +}