DOCS: Added docs to imgio and refactored some of the names and code of imgio

This commit is contained in:
2026-09-09 16:44:37 -04:00
parent 4a181348b5
commit 2a168f8947
5 changed files with 136 additions and 75 deletions
+47 -6
View File
@@ -3,27 +3,68 @@
#include "utils.h"
/**
* @brief Open and Fill buffer from .ppm file
* @param [in] file Char pointer use to locate the image to be modified lays.
* @param [in,out] m_attr PPM pointer to store image information
*/
unsigned int*
ppm_load(const char* file, PPM* m_attr);
read_ppm(const char* file, PPM* m_attr);
/**
* @brief Open and write buffer to file
* @param [in] buf Information of pixels
* @param [in] img PPM pointer to store image information
* @param [in] char Name/Location for file
*/
int
ppm_save(const unsigned int* buf, const PPM img, char* name);
write_ppm(const unsigned int* buf, const PPM img, const char* name);
/**
* @brief Open and Fill buffer from .jpg file
* @details Opens a .jpg file, creates a new buffer and extracts the pixels into
* said buffer as integers.
* @param [in] file Char pointer use to locate the image to be modified lays.
* @param [in,out] m_attr JPEG pointer to store image information
*/
unsigned int*
jpeg_load(JPEG* m_attr);
read_jpeg(JPEG* m_attr);
/**
* @brief Open and write buffer to file
* @param [in] buf Information of pixels
* @param [in] attr JPEG pointer to store image information
* @param [in] char Name/Location for file
*/
int
jpeg_save(const unsigned int* src_buf, const JPEG* attr, const char* name);
write_jpeg(const unsigned int* src_buf, const JPEG* attr, const char* name);
/**
* @brief Converts PPM to JPEG
* @param [in] in Pointer to PPM container
*/
void
transcode_to_jpeg(PPM* in, JPEG* out);
transcode_to_jpeg(PPM* in);
/**
* @brief Converts JPEG to PPM
* @param [in] in Pointer to JPEG container
*/
void
transcode_to_ppm(JPEG* in, PPM* out);
transcode_to_ppm(JPEG* in);
/**
* @brief Inherits the attributes from JPEG container
* @param [in] in Pointer to JPEG container
* @param [in] fmt Character for type of PPM image, binary or raw
*/
PPM
inherit_from_jpeg(const JPEG* in, const char fmt);
/**
* @brief Inherits the attributes from PPM container
* @param [in] in Pointer to PPM container
*/
JPEG
inherit_from_ppm(const PPM* in);
+10 -2
View File
@@ -9,6 +9,7 @@
// The u in the BYTE Macros are for unsigned calls so colors are not changed to
// signed and the values cut in half
#include <stddef.h>
#define BYTE_A 0xFF000000u /**< Isolates the First Byte for alpha */
#define BYTE_R 0x00FF0000u /**< Isolates the Second Byte for red */
#define BYTE_G 0x0000FF00u /**< Isolates the Third Byte for green */
@@ -21,6 +22,7 @@
#define SHIFT_16 16 /**< Constant shift of 16-Bits */
#define SHIFT_24 24 /**< Constant shift of 24-Bits */
// These are success and error codes
#define SUCCESS 0
#define FAILURE 1
@@ -31,11 +33,14 @@
#define ERR_IMG_NULL 24
#define ERR_IMG_NAME_INVALID 25
#define ERR_JHEADER 26
#define ERR_MALLOC_NULL 27
extern const char* error_messages[];
#define LOG(msg) printf("LOG: %s\n", msg)
#define LOGERROR(error_code) printf("ERROR: %s\n", error_messages[error_code])
#define LOG(msg) printf("LOG: %s\n", msg) /**< Print log message*/
#define LOGERROR(error_code) \
printf("ERROR: %s\n", \
error_messages[error_code]) /**< Print log error message*/
/**
*
@@ -167,4 +172,7 @@ print_attr(const PPM* src);
void __attribute__((overloadable))
print_attr(const JPEG* src);
size_t
find_extension(const char* n);
#endif