I have a class that looks like the following:
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);
        }
};
When I do FreeImage_Unload(dib), I lose the data information, how can I copy the info on 'bits' to 'data' so whenever I unload the 'dib' I do not lose the information?
Any suggestions?
                        
You have to copy image data from FreeImage's DIB to a separate location:
Now you can free the
dibas you do.