add ILImage::Copy/Refresh functions.
This commit is contained in:
parent
dae3e49980
commit
3b3a03814b
@ -12,6 +12,8 @@ class ILImage
|
|||||||
|
|
||||||
uint channel_count;
|
uint channel_count;
|
||||||
|
|
||||||
|
void Refresh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool Convert(ILuint,ILuint);
|
bool Convert(ILuint,ILuint);
|
||||||
@ -36,11 +38,13 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ILImage();
|
ILImage();
|
||||||
|
ILImage(ILImage *);
|
||||||
~ILImage();
|
~ILImage();
|
||||||
|
|
||||||
bool LoadFile(const OSString &);
|
bool LoadFile(const OSString &);
|
||||||
|
|
||||||
void Bind();
|
void Bind();
|
||||||
|
void Copy(ILImage *);
|
||||||
|
|
||||||
bool Resize(uint,uint);
|
bool Resize(uint,uint);
|
||||||
|
|
||||||
|
@ -52,11 +52,72 @@ ILImage::ILImage()
|
|||||||
ilGenImages(1,&il_index);
|
ilGenImages(1,&il_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ILImage::ILImage(ILImage *img):ILImage()
|
||||||
|
{
|
||||||
|
ilGenImages(1,&il_index);
|
||||||
|
Bind();
|
||||||
|
ilCopyImage(img->il_index);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
ILImage::~ILImage()
|
ILImage::~ILImage()
|
||||||
{
|
{
|
||||||
ilDeleteImages(1,&il_index);
|
ilDeleteImages(1,&il_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ILImage::Copy(ILImage *img)
|
||||||
|
{
|
||||||
|
ilCopyImage(img->il_index);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ILImage::Refresh()
|
||||||
|
{
|
||||||
|
il_width =ilGetInteger(IL_IMAGE_WIDTH);
|
||||||
|
il_height =ilGetInteger(IL_IMAGE_HEIGHT);
|
||||||
|
il_depth =ilGetInteger(IL_IMAGE_DEPTH);
|
||||||
|
il_bit =ilGetInteger(IL_IMAGE_BITS_PER_PIXEL);
|
||||||
|
il_format =ilGetInteger(IL_IMAGE_FORMAT);
|
||||||
|
il_type =ilGetInteger(IL_IMAGE_TYPE);
|
||||||
|
|
||||||
|
if(ilGetInteger(IL_IMAGE_ORIGIN)==IL_ORIGIN_LOWER_LEFT)
|
||||||
|
iluFlipImage();
|
||||||
|
|
||||||
|
if(il_format==IL_COLOR_INDEX)
|
||||||
|
{
|
||||||
|
uint il_pattle=ilGetInteger(IL_PALETTE_TYPE);
|
||||||
|
|
||||||
|
if(il_pattle==IL_PAL_RGB24||il_pattle==IL_PAL_BGR24
|
||||||
|
||il_pattle==IL_PAL_RGB32||il_pattle==IL_PAL_BGR32)
|
||||||
|
{
|
||||||
|
channel_count=3;
|
||||||
|
il_format=IL_RGB;
|
||||||
|
il_type=IL_UNSIGNED_BYTE;
|
||||||
|
ilConvertImage(il_format,il_type);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(il_pattle==IL_PAL_RGBA32||il_pattle==IL_PAL_BGRA32)
|
||||||
|
{
|
||||||
|
channel_count=4;
|
||||||
|
il_format=IL_RGBA;
|
||||||
|
il_type=IL_UNSIGNED_BYTE;
|
||||||
|
ilConvertImage(il_format,il_type);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_ERROR("Don't support the pattle format.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
il_bit =ilGetInteger(IL_IMAGE_BITS_PER_PIXEL);
|
||||||
|
|
||||||
|
if(il_format==IL_LUMINANCE||il_format==IL_ALPHA)channel_count=1;else
|
||||||
|
if(il_format==IL_LUMINANCE_ALPHA) channel_count=2;else
|
||||||
|
if(il_format==IL_RGB||il_format==IL_BGR) channel_count=3;else
|
||||||
|
if(il_format==IL_RGBA||il_format==IL_BGRA) channel_count=4;else
|
||||||
|
channel_count=0;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr ILenum format_by_channel[]=
|
constexpr ILenum format_by_channel[]=
|
||||||
{
|
{
|
||||||
IL_LUMINANCE,
|
IL_LUMINANCE,
|
||||||
@ -154,15 +215,7 @@ bool ILImage::LoadFile(const OSString &filename)
|
|||||||
|
|
||||||
LOG_INFO(OS_TEXT("\nFile: ")+filename);
|
LOG_INFO(OS_TEXT("\nFile: ")+filename);
|
||||||
|
|
||||||
il_width =ilGetInteger(IL_IMAGE_WIDTH);
|
Refresh();
|
||||||
il_height =ilGetInteger(IL_IMAGE_HEIGHT);
|
|
||||||
il_depth =ilGetInteger(IL_IMAGE_DEPTH);
|
|
||||||
il_bit =ilGetInteger(IL_IMAGE_BITS_PER_PIXEL);
|
|
||||||
il_format =ilGetInteger(IL_IMAGE_FORMAT);
|
|
||||||
il_type =ilGetInteger(IL_IMAGE_TYPE);
|
|
||||||
|
|
||||||
if(ilGetInteger(IL_IMAGE_ORIGIN)==IL_ORIGIN_LOWER_LEFT)
|
|
||||||
iluFlipImage();
|
|
||||||
|
|
||||||
LOG_INFO(OS_TEXT("\t width: ")+OSString::valueOf(il_width));
|
LOG_INFO(OS_TEXT("\t width: ")+OSString::valueOf(il_width));
|
||||||
LOG_INFO(OS_TEXT("\theight: ")+OSString::valueOf(il_height));
|
LOG_INFO(OS_TEXT("\theight: ")+OSString::valueOf(il_height));
|
||||||
@ -171,41 +224,6 @@ bool ILImage::LoadFile(const OSString &filename)
|
|||||||
LOG_INFO(OS_TEXT("\tformat: ")+GetILFormatName(il_format));
|
LOG_INFO(OS_TEXT("\tformat: ")+GetILFormatName(il_format));
|
||||||
LOG_INFO(OS_TEXT("\t type: ")+GetILTypeName(il_type));
|
LOG_INFO(OS_TEXT("\t type: ")+GetILTypeName(il_type));
|
||||||
|
|
||||||
if(il_format==IL_COLOR_INDEX)
|
|
||||||
{
|
|
||||||
uint il_pattle=ilGetInteger(IL_PALETTE_TYPE);
|
|
||||||
|
|
||||||
if(il_pattle==IL_PAL_RGB24||il_pattle==IL_PAL_BGR24
|
|
||||||
||il_pattle==IL_PAL_RGB32||il_pattle==IL_PAL_BGR32)
|
|
||||||
{
|
|
||||||
channel_count=3;
|
|
||||||
il_format=IL_RGB;
|
|
||||||
il_type=IL_UNSIGNED_BYTE;
|
|
||||||
ilConvertImage(il_format,il_type);
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(il_pattle==IL_PAL_RGBA32||il_pattle==IL_PAL_BGRA32)
|
|
||||||
{
|
|
||||||
channel_count=4;
|
|
||||||
il_format=IL_RGBA;
|
|
||||||
il_type=IL_UNSIGNED_BYTE;
|
|
||||||
ilConvertImage(il_format,il_type);
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_ERROR("Don't support the pattle format.");
|
|
||||||
return(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(il_format==IL_LUMINANCE||il_format==IL_ALPHA)channel_count=1;else
|
|
||||||
if(il_format==IL_LUMINANCE_ALPHA) channel_count=2;else
|
|
||||||
if(il_format==IL_RGB||il_format==IL_BGR) channel_count=3;else
|
|
||||||
if(il_format==IL_RGBA||il_format==IL_BGRA) channel_count=4;else
|
|
||||||
channel_count=0;
|
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user