Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
image_processor.c File Reference

Data Structures

struct  pixel_t
 

Macros

#define STB_IMAGE_IMPLEMENTATION
 
#define STB_IMAGE_WRITE_IMPLEMENTATION
 
#define CLAMP(x, l, u)
 

Functions

void shuffleArray (uint32_t *ar, uint32_t len)
 Randomizes the order of the given array of ints.
 
int isNeighborNotDrawn (pixel_t **img, int x, int y, int w, int h)
 
void spreadError (pixel_t **img, int x, int y, int w, int h, int teR, int teG, int teB, float diagScalar)
 
bool process_image (processorInput_t *arg)
 

Variables

const assetProcessor_t imageProcessor = {.name = "wsg", .type = FUNCTION, .function = process_image, .inFmt = FMT_FILE_BIN, .outFmt = FMT_FILE_BIN}
 The image processor converts PNG images to 8-bit images using the 216-color web-safe palette plus one bit of transparency. Colors outside the palette will be replaced with their closest value within the palette.
 

Data Structure Documentation

◆ pixel_t

struct pixel_t
Data Fields
uint8_t r
uint8_t g
uint8_t b
uint8_t a
int eR
int eG
int eB
bool isDrawn

Macro Definition Documentation

◆ STB_IMAGE_IMPLEMENTATION

#define STB_IMAGE_IMPLEMENTATION

◆ STB_IMAGE_WRITE_IMPLEMENTATION

#define STB_IMAGE_WRITE_IMPLEMENTATION

◆ CLAMP

#define CLAMP ( x,
l,
u )
Value:
((x) < l ? l : ((x) > u ? u : (x)))

Function Documentation

◆ shuffleArray()

void shuffleArray ( uint32_t * ar,
uint32_t len )

Randomizes the order of the given array of ints.

Parameters
arThe array to randomize
lenThe number of items in the array

◆ isNeighborNotDrawn()

int isNeighborNotDrawn ( pixel_t ** img,
int x,
int y,
int w,
int h )

◆ spreadError()

void spreadError ( pixel_t ** img,
int x,
int y,
int w,
int h,
int teR,
int teG,
int teB,
float diagScalar )

◆ process_image()

bool process_image ( processorInput_t * arg)

Variable Documentation

◆ imageProcessor

const assetProcessor_t imageProcessor = {.name = "wsg", .type = FUNCTION, .function = process_image, .inFmt = FMT_FILE_BIN, .outFmt = FMT_FILE_BIN}

The image processor converts PNG images to 8-bit images using the 216-color web-safe palette plus one bit of transparency. Colors outside the palette will be replaced with their closest value within the palette.