2019-12-02 22:10:49 +08:00
|
|
|
#pragma once
|
|
|
|
#include<IL/il.h>
|
|
|
|
#include<hgl/type/BaseString.h>
|
|
|
|
|
|
|
|
using namespace hgl;
|
|
|
|
|
|
|
|
class ILImage
|
|
|
|
{
|
|
|
|
ILuint il_index;
|
2019-12-30 16:48:15 +08:00
|
|
|
ILuint il_width,il_height,il_depth;
|
2019-12-02 22:10:49 +08:00
|
|
|
ILuint il_bit,il_format,il_type;
|
|
|
|
|
|
|
|
uint channel_count;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
bool Convert(ILuint,ILuint);
|
|
|
|
|
|
|
|
void *GetData(ILuint,ILuint);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2019-12-30 16:48:15 +08:00
|
|
|
const ILuint width ()const{return il_width;}
|
|
|
|
const ILuint height ()const{return il_height;}
|
|
|
|
const ILuint depth ()const{return il_depth;}
|
|
|
|
const ILuint bit ()const{return il_bit;}
|
|
|
|
const ILuint format ()const{return il_format;}
|
|
|
|
const ILuint type ()const{return il_type;}
|
2019-12-02 22:10:49 +08:00
|
|
|
|
2019-12-30 16:48:15 +08:00
|
|
|
const ILuint pixel_total()const{return il_width*il_height*il_depth;}
|
2019-12-02 22:10:49 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
const uint channels()const{return channel_count;} //通道数量
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ILImage();
|
|
|
|
~ILImage();
|
|
|
|
|
|
|
|
bool LoadFile(const OSString &);
|
|
|
|
|
|
|
|
void Bind();
|
2019-12-30 16:48:15 +08:00
|
|
|
|
|
|
|
bool Resize(uint,uint);
|
2019-12-31 13:44:09 +08:00
|
|
|
|
2020-01-08 15:54:58 +08:00
|
|
|
void *ToRGB(ILuint type=IL_UNSIGNED_BYTE);
|
|
|
|
void *ToGray(ILuint type=IL_UNSIGNED_BYTE);
|
2019-12-02 22:10:49 +08:00
|
|
|
|
|
|
|
void *GetR(ILuint type);
|
|
|
|
|
|
|
|
void *GetRG(ILuint type){return GetData(IL_LUMINANCE_ALPHA,type);}
|
|
|
|
void *GetRGB(ILuint type){return GetData(IL_RGB,type);}
|
2019-12-04 11:06:57 +08:00
|
|
|
// void *GetBGR(ILuint type){return GetData(IL_BGR,type);}
|
2019-12-02 22:10:49 +08:00
|
|
|
void *GetRGBA(ILuint type){return GetData(IL_RGBA,type);}
|
2019-12-04 11:06:57 +08:00
|
|
|
// void *GetBGRA(ILuint type){return GetData(IL_BGRA,type);}
|
2019-12-31 13:44:09 +08:00
|
|
|
|
|
|
|
void *GetLum(ILuint type){return GetData(IL_LUMINANCE,type);}
|
2019-12-02 22:10:49 +08:00
|
|
|
};//class ILImage
|
2020-01-02 21:40:06 +08:00
|
|
|
|
2020-01-08 15:54:58 +08:00
|
|
|
bool SaveImageToFile(const OSString &filename,ILuint w,ILuint h,const float scale,ILuint c,ILuint t,void *data);
|