.TH "img.h" 3 "Bark" \" -*- nroff -*- .ad l .nh .SH NAME img.h \- Bark image decoding, cropping, and JPEG data-URI encoding\&. .SH SYNOPSIS .br .PP .SS "Functions" .in +1c .ti -1c .RI "uint8_t * \fBbark_img_decode_rgba\fP (const uint8_t *bytes, size_t len, uint32_t *w_out, uint32_t *h_out)" .br .RI "Decode PNG, JPEG, GIF, BMP, or WebP bytes in memory into tightly-packed RGBA8 pixels\&. " .ti -1c .RI "uint8_t * \fBbark_img_decode_data_uri\fP (const char *uri, size_t *len_out)" .br .RI "Decode an RFC 2397 data URI into raw bytes\&. " .ti -1c .RI "char * \fBbark_img_encode_jpeg_uri\fP (const uint8_t *rgba, int w, int h, int quality)" .br .RI "Encode an RGBA8 pixel buffer into a \fRdata:image/jpeg\fP;base64,\&.\&.\&. data URI\&. " .ti -1c .RI "char * \fBbark_img_crop_uri\fP (const uint8_t *img_bytes, size_t img_len, int out_size, float zoom, float pan_x, float pan_y, int quality)" .br .RI "Crop and resize an encoded image into a square JPEG data URI\&. " .ti -1c .RI "char * \fBbark_img_shrink_jpeg_uri\fP (const uint8_t *img_bytes, size_t img_len, int max_w, int max_h, int square_cover, size_t max_uri_len)" .br .RI "Downscale and re-encode an image to fit within dimensions and a byte budget\&. " .in -1c .SH "Detailed Description" .PP Bark image decoding, cropping, and JPEG data-URI encoding\&. Headless pure-C image decoding, data-URI decoding, and JPEG transform primitives\&. .PP Zero OpenGL or windowing dependencies\&. All returned heap buffers must be released with \fRfree()\fP\&. .SH "Function Documentation" .PP .SS "char * bark_img_crop_uri (const uint8_t * img_bytes, size_t img_len, int out_size, float zoom, float pan_x, float pan_y, int quality)" .PP Crop and resize an encoded image into a square JPEG data URI\&. .PP \fBParameters\fP .RS 4 \fIimg_bytes\fP Encoded input image bytes\&. .br \fIimg_len\fP Length of \fRimg_bytes\fP\&. .br \fIout_size\fP Output square edge length in pixels\&. .br \fIzoom\fP Zoom factor (>= 1\&.0)\&. .br \fIpan_x\fP Normalized horizontal pan offset\&. .br \fIpan_y\fP Normalized vertical pan offset\&. .br \fIquality\fP JPEG quality (1\&.\&.100)\&. .RE .PP \fBReturns\fP .RS 4 Newly allocated JPEG data URI string, or NULL on failure\&. .RE .PP .SS "uint8_t * bark_img_decode_data_uri (const char * uri, size_t * len_out)" .PP Decode an RFC 2397 data URI into raw bytes\&. Parses \fR"data:[mime][;base64],"\fP into a malloc()'d, NUL-terminated buffer\&. .PP \fBParameters\fP .RS 4 \fIuri\fP NUL-terminated data URI string\&. .br \fIlen_out\fP Exact decoded byte length\&. .RE .PP \fBReturns\fP .RS 4 Newly allocated byte buffer, or NULL on malformed input\&. .RE .PP .SS "uint8_t * bark_img_decode_rgba (const uint8_t * bytes, size_t len, uint32_t * w_out, uint32_t * h_out)" .PP Decode PNG, JPEG, GIF, BMP, or WebP bytes in memory into tightly-packed RGBA8 pixels\&. .PP \fBParameters\fP .RS 4 \fIbytes\fP Encoded image bytes\&. .br \fIlen\fP Length of \fRbytes\fP in bytes\&. .br \fIw_out\fP Decoded image width in pixels\&. .br \fIh_out\fP Decoded image height in pixels\&. .RE .PP \fBReturns\fP .RS 4 Newly allocated \fRw*h*4\fP byte RGBA8 buffer, or NULL on failure\&. .RE .PP .SS "char * bark_img_encode_jpeg_uri (const uint8_t * rgba, int w, int h, int quality)" .PP Encode an RGBA8 pixel buffer into a \fRdata:image/jpeg\fP;base64,\&.\&.\&. data URI\&. .PP \fBParameters\fP .RS 4 \fIrgba\fP Tightly-packed RGBA8 pixels (\fRw*h*4\fP bytes)\&. .br \fIw\fP Image width in pixels\&. .br \fIh\fP Image height in pixels\&. .br \fIquality\fP JPEG quality (1\&.\&.100)\&. .RE .PP \fBReturns\fP .RS 4 Newly allocated data URI string (free with \fRfree()\fP), or NULL on failure\&. .RE .PP .SS "char * bark_img_shrink_jpeg_uri (const uint8_t * img_bytes, size_t img_len, int max_w, int max_h, int square_cover, size_t max_uri_len)" .PP Downscale and re-encode an image to fit within dimensions and a byte budget\&. .PP \fBParameters\fP .RS 4 \fIimg_bytes\fP Encoded input image bytes\&. .br \fIimg_len\fP Length of \fRimg_bytes\fP\&. .br \fImax_w\fP Maximum output width in pixels\&. .br \fImax_h\fP Maximum output height in pixels\&. .br \fIsquare_cover\fP Non-zero to center-crop to a square before scaling\&. .br \fImax_uri_len\fP Maximum output data-URI length in bytes (0 for default)\&. .RE .PP \fBReturns\fP .RS 4 Newly allocated JPEG data URI string, or NULL on failure\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for Bark from the source code\&.