vbagx/source/utils/pngu.h

76 lines
2.6 KiB
C
Raw Permalink Normal View History

2009-08-25 19:20:54 +02:00
/********************************************************************************************
*
* PNGU
*
* Original author: frontier (http://frontier-dev.net)
* Modified by Tantric, 2009-2010
*
2009-08-25 19:20:54 +02:00
********************************************************************************************/
2009-08-25 19:20:54 +02:00
#ifndef __PNGU__
#define __PNGU__
2010-06-29 09:50:37 +02:00
#include <gccore.h>
2009-08-25 19:20:54 +02:00
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
2010-06-29 09:50:37 +02:00
u8 r;
u8 g;
u8 b;
2009-08-25 19:20:54 +02:00
} PNGUCOLOR;
typedef struct
{
2010-06-29 09:50:37 +02:00
u32 imgWidth; // In pixels
u32 imgHeight; // In pixels
u32 imgBitDepth; // In bitx
u32 imgColorType; // PNGU_COLOR_TYPE_*
u32 validBckgrnd; // Non zero if there is a background color
PNGUCOLOR bckgrnd; // Background color
u32 numTrans; // Number of transparent colors
2009-08-25 19:20:54 +02:00
PNGUCOLOR *trans; // Transparent colors
} PNGUPROP;
// Image context, always initialize with SelectImageFrom* and free with ReleaseImageContext
struct _IMGCTX;
typedef struct _IMGCTX *IMGCTX;
/****************************************************************************
* Image context handling *
2009-08-25 19:20:54 +02:00
****************************************************************************/
2010-06-29 09:50:37 +02:00
// Selects a PNG file, previously loaded into a buffer, and creates an image context for subsequent processing.
2009-08-25 19:20:54 +02:00
IMGCTX PNGU_SelectImageFromBuffer (const void *buffer);
2010-06-29 09:50:37 +02:00
// Selects a PNG file, from any devoptab device, and creates an image context for subsequent processing.
2009-08-25 19:20:54 +02:00
IMGCTX PNGU_SelectImageFromDevice (const char *filename);
// Frees resources associated with an image context. Always call this function when you no longer need the IMGCTX.
void PNGU_ReleaseImageContext (IMGCTX ctx);
/****************************************************************************
* Miscellaneous *
2009-08-25 19:20:54 +02:00
****************************************************************************/
// Retrieves info from selected PNG file, including image dimensions, color format, background and transparency colors.
int PNGU_GetImageProperties (IMGCTX ctx, PNGUPROP *fileproperties);
/****************************************************************************
* Image conversion *
2009-08-25 19:20:54 +02:00
****************************************************************************/
2010-06-29 09:50:37 +02:00
u8 * DecodePNG(const u8 *src, int *width, int *height, u8 *dst, int maxwidth, int maxheight);
int PNGU_EncodeFromRGB (IMGCTX ctx, u32 width, u32 height, void *buffer, u32 stride);
int PNGU_EncodeFromGXTexture (IMGCTX ctx, u32 width, u32 height, void *buffer, u32 stride);
int PNGU_EncodeFromEFB (IMGCTX ctx, u32 width, u32 height);
2009-08-25 19:20:54 +02:00
#ifdef __cplusplus
}
#endif
#endif