Duplicating an Image
// First, get our resource manager and access its interface.
RED::Object* resmgr = RED::Factory::CreateInstance( CID_REDResourceManager );
RED::IResourceManager* iresmgr = resmgr->As< RED::IResourceManager >();
// Let's create a sample 2D image:
RED::Object* image2D;
RC_TEST( iresmgr->CreateImage2D( image2D, iresmgr->GetState() ) );
// And add some contents to it for the purpose of this example:
RED::IImage2D* iimage2D = image2D->As< RED::IImage2D >();
float pixel[4] = { 2.0f, 1.0f, 0.5f, 1.0f };
RC_TEST( iimage2D->SetPixels( (unsigned char*)pixel, RED::FMT_FLOAT_RGBA, RED::TGT_TEX_RECT, 1, 1, iresmgr->GetState() ) );
// And duplicate that image:
RED::Object* image2D_copy;
RC_TEST( iresmgr->CloneImage( image2D_copy, image2D, iresmgr->GetState() ) );
Please note that, as detailed by the RED::IResourceManager::CloneImage
method, the local storage of the source image is overridden and lost during the operation due to the fact that the engine reads back the source image contents to its local storage before re-assigning it to the copy.