// 32 bit RGBA bitmap functions.
// Written by Nils Liaaen Corneliusen and Sjur Julin.
// License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication license
// https://www.ignorantus.com
// https://www.in-a-vision.com

#ifndef BMPH
#define BMPH

#include <stdint.h>
#include <stdbool.h>

typedef struct {
	uint32_t *data;
	int w, h;
} bmp32;

bmp32 *bmp32_Create( int w, int h, void *data );
bmp32 *bmp32_Alloc( int w, int h );
bmp32 *bmp32_Duplicate( bmp32 *src );
void   bmp32_Clear( bmp32 *dst );
void   bmp32_ClearAlpha( bmp32 *dst );

void bmp32_DrawRect( bmp32 *dst, int ulx, int uly, int brx, int bry, uint32_t col );

bmp32 *bmp32_ReadPng( const char *fname, bool flip );
bmp32 *bmp32_ReadPngMem( uint8_t *ppng, size_t size, bool flip );
bool   bmp32_WritePng( bmp32 *bp, const char *fname, bool flip );

void bmp32_DrawText(         bmp32 *dst, int fontid, bool alpha, int x, int y, const char *text, uint32_t col );
void bmp32_DrawTextRight(    bmp32 *dst, int fontid, bool alpha,        int y, const char *text, uint32_t col );
void bmp32_DrawTextCenter(   bmp32 *dst, int fontid, bool alpha,        int y, const char *text, uint32_t col );

#endif
