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
00055 u32 GetWidth() const;
00058 u32 GetHeight() const;
00059
00062 bool IsInitialized() const;
00063
00067 void BindTexture(bool bilinear = true);
00068 protected:
00074 bool _InitializeImage(u32 width, u32 height);
00076 void _Flush();
00077
00078 u8* _pixels;
00079 private:
00080 void _ConvertTexture(png_byte color_type, png_bytep* row_pointers);
00081
00082 u32 _width, _height;
00083 bool _initialized;
00084 GXTexObj _texObj;
00085 };
00086 };
00087
00133 #endif