while we try to load an iPad-Photo with an resolution of 2592x1936 as an background Texture, we are always getting an white rectangle as background...
So we implemented code, that transforms the texture to POT. As a result we get a Texture with 2048x1024, but the rectangle es even white.
What are we doing wrong?
Code: Select all
video::ITexture *E3DCLoadImage::getPOTTextureForTexture( video::ITexture *backgroundTexture, stringc path )
{
video::ITexture *POTText;
int width = backgroundTexture->getSize().Width;
int height = backgroundTexture->getSize().Height;
printf("original - w:%i h:%i", width, height);
int kMaxWidth = 2048;
int kMaxHeight = 1024;
int i;
bool sizeToFit = false;
// Scale image width to next pot size
if( (width != 1) && (width & (width - 1)) )
{
i = 1;
while( (sizeToFit ? 2 * i : i) < width )
i *= 2;
width = i;
}
// Scale image height to next pot size
if( (height != 1) && (height & (height - 1)) )
{
i = 1;
while( (sizeToFit ? 2 * i : i) < height )
i *= 2;
height = i;
}
// Scale image down if now larger than the maximum texture size
while( width > kMaxWidth )
{
width /= 2;
//imageWidth *= 0.5;
//imageHeight *= 0.5;
}
while( height > kMaxHeight )
{
height /= 2;
}
printf("calculated - w:%i h:%i", width, height);
core::vector2d<s32> pos = core::vector2d<s32>(0,0);
core::dimension2d<u32> size = core::dimension2d<u32>(backgroundTexture->getSize().Width, backgroundTexture->getSize().Height);
IImage *backimage = driver->createImage(backgroundTexture, pos, size);
//IImage *backimage = driver->createImageFromFile( "fassade.jpg" );
IImage *imagesmall = driver->createImage(ECF_A16B16G16R16F,core::dimension2d<u32>(512, 512));
// backimage->copyToScaling(imagesmall, 2048, 2048);
backimage->copyTo(imagesmall);
//imagesmall->fill(video::SColor(255,181,154,109));
//driver->writeImageToFile(imagesmall, "newimage.jpg");
driver->addTexture(L"imagesmall.jpg", imagesmall);
//imagesmall->drop();
//IWriteFile *imagefile;
//driver->writeImageToFile(imagesmall, imagefile);
//writefile readfile
//IReadFile *readfile = imagefile->
POTText = driver->getTexture("imagesmall.jpg");
return POTText;
}