2009-03-11 18:28:37 +01:00
|
|
|
/****************************************************************************
|
2009-04-10 10:12:37 +02:00
|
|
|
* libwiigui
|
2009-03-11 18:28:37 +01:00
|
|
|
*
|
2009-04-10 10:12:37 +02:00
|
|
|
* Tantric 2009
|
2009-03-11 18:28:37 +01:00
|
|
|
*
|
|
|
|
* gui_imagedata.cpp
|
|
|
|
*
|
|
|
|
* GUI class definitions
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "gui.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor for the GuiImageData class.
|
|
|
|
*/
|
2009-10-17 02:15:58 +02:00
|
|
|
GuiImageData::GuiImageData(const u8 * i)
|
2009-03-11 18:28:37 +01:00
|
|
|
{
|
2009-03-21 03:01:40 +01:00
|
|
|
data = NULL;
|
|
|
|
width = 0;
|
|
|
|
height = 0;
|
|
|
|
|
2009-10-17 02:15:58 +02:00
|
|
|
if(i)
|
2009-03-11 18:28:37 +01:00
|
|
|
{
|
|
|
|
PNGUPROP imgProp;
|
2009-10-17 02:15:58 +02:00
|
|
|
IMGCTX ctx = PNGU_SelectImageFromBuffer(i);
|
2009-03-11 18:28:37 +01:00
|
|
|
|
2009-03-17 07:06:01 +01:00
|
|
|
if(!ctx)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int res = PNGU_GetImageProperties(ctx, &imgProp);
|
|
|
|
|
|
|
|
if(res == PNGU_OK)
|
|
|
|
{
|
2010-01-25 08:34:45 +01:00
|
|
|
int len = (imgProp.imgWidth * imgProp.imgHeight) <<2;
|
2009-03-21 22:17:09 +01:00
|
|
|
if(len%32) len += (32-len%32);
|
|
|
|
data = (u8 *)memalign (32, len);
|
2009-03-17 07:06:01 +01:00
|
|
|
|
|
|
|
if(data)
|
|
|
|
{
|
|
|
|
res = PNGU_DecodeTo4x4RGBA8 (ctx, imgProp.imgWidth, imgProp.imgHeight, data, 255);
|
|
|
|
|
|
|
|
if(res == PNGU_OK)
|
|
|
|
{
|
|
|
|
width = imgProp.imgWidth;
|
|
|
|
height = imgProp.imgHeight;
|
2009-03-21 22:17:09 +01:00
|
|
|
DCFlushRange(data, len);
|
2009-03-17 07:06:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free(data);
|
|
|
|
data = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-11 18:28:37 +01:00
|
|
|
PNGU_ReleaseImageContext (ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor for the GuiImageData class.
|
|
|
|
*/
|
|
|
|
GuiImageData::~GuiImageData()
|
|
|
|
{
|
|
|
|
if(data)
|
|
|
|
{
|
|
|
|
free(data);
|
|
|
|
data = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 * GuiImageData::GetImage()
|
|
|
|
{
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GuiImageData::GetWidth()
|
|
|
|
{
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GuiImageData::GetHeight()
|
|
|
|
{
|
|
|
|
return height;
|
|
|
|
}
|