我有一个如下所示的类:
class myTexture
{
public:
myTexture();
~myTexture();
unsigned char * data;
void loadFile(string file)
{
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
FIBITMAP *dib(0);
BYTE* bits;
fif = FreeImage_GetFileType(filename.c_str(), 0);
if(fif == FIF_UNKNOWN)
fif = FreeImage_GetFIFFromFilename(filename.c_str());
if(FreeImage_FIFSupportsReading(fif))
dib = FreeImage_Load(fif, filename.c_str(), 0);
bits = FreeImage_GetBits(dib);
data = bits;
FreeImage_Unload(dib);
}
};
当我执行 FreeImage_Unload(dib) 时,我会丢失数据信息,如何将“bits”上的信息复制到“data”,以便在卸载“dib”时不会丢失信息?
有什么建议么?