00001
00002
00003
00004
00005 #ifndef LIBWIISPRITE_IMAGE
00006 #define LIBWIISPRITE_IMAGE
00007
00008 #include <stdlib.h>
00009 #include <gccore.h>
00010 #include <png.h>
00011
00013 namespace wsp{
00014
00016 enum IMG_LOAD_ERROR{
00017 IMG_LOAD_ERROR_NONE = 0,
00018 IMG_LOAD_ERROR_NOT_FOUND,
00019 IMG_LOAD_ERROR_INV_PNG,
00020 IMG_LOAD_ERROR_PNG_FAIL,
00021 IMG_LOAD_ERROR_WRONG_SIZE,
00022 IMG_LOAD_ERROR_ALREADY_INIT
00023 };
00024
00026 enum IMG_LOAD_TYPE{
00027 IMG_LOAD_TYPE_PATH = 0,
00028 IMG_LOAD_TYPE_BUFFER
00029 };
00030
00032 class Image{
00033 public:
00035 Image();
00037 virtual ~Image();
00038
00046 IMG_LOAD_ERROR LoadImage(const char* path, IMG_LOAD_TYPE loadtype = IMG_LOAD_TYPE_PATH);
00051 IMG_LOAD_ERROR LoadImage(const unsigned char* path, IMG_LOAD_TYPE loadtype = IMG_LOAD_TYPE_BUFFER);
00052
00054 void DestroyImage();
00057 u32 GetWidth() const;
00060 u32 GetHeight() const;
00061
00064 bool IsInitialized() const;
00065
00069 void BindTexture(bool bilinear = true);
00070 protected:
00076 bool _InitializeImage(u32 width, u32 height);
00078 void _Flush();
00079
00080 u8* _pixels;
00081 private:
00082 void _ConvertTexture(png_byte color_type, png_bytep* row_pointers);
00083
00084 u32 _width, _height;
00085 bool _initialized;
00086 GXTexObj _texObj;
00087 };
00088 };
00089
00135 #endif