Commit 75f7074e authored by hybrid's avatar hybrid

Deprecate some image creation methods.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2908 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 4b57a03b
......@@ -1137,7 +1137,7 @@ namespace video
virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) =0;
//! Creates a software image by converting it to given format from another image.
/**
/** \deprecated Create an empty image and use copyTo()
\param format Desired color format of the image.
\param imageToCopy Image to copy to the new image.
\return The created image.
......@@ -1146,7 +1146,7 @@ namespace video
virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy) =0;
//! Creates a software image from a part of another image.
/**
/** \deprecated Create an empty image and use copyTo()
\param imageToCopy Image to copy to the new image in part.
\param pos Position of rectangle to copy.
\param size Extents of rectangle to copy.
......
......@@ -241,14 +241,16 @@ bool CGUIFont::loadTexture(video::IImage* image, const io::path& name)
switch(image->getColorFormat())
{
case video::ECF_R5G6B5:
tmpImage = new video::CImage(video::ECF_A1R5G5B5,image);
tmpImage = new video::CImage(video::ECF_A1R5G5B5,image->getDimension());
image->copyTo(tmpImage);
deleteTmpImage=true;
break;
case video::ECF_A1R5G5B5:
case video::ECF_A8R8G8B8:
break;
case video::ECF_R8G8B8:
tmpImage = new video::CImage(video::ECF_A8R8G8B8,image);
tmpImage = new video::CImage(video::ECF_A8R8G8B8,image->getDimension());
image->copyTo(tmpImage);
deleteTmpImage=true;
break;
}
......
......@@ -264,9 +264,10 @@ IMesh* CGeometryCreator::createTerrainMesh(video::IImage* texture,
{
c8 textureName[64];
// create texture for this block
video::IImage* img = new video::CImage(texture,
video::IImage* img = new video::CImage(texture->getColorFormat(), texture->getDimension());
texture->copyTo(img, core::position2di(0,0), core::recti(
core::position2d<s32>(core::floor32(processed.X*thRel.X), core::floor32(processed.Y*thRel.Y)),
core::dimension2d<u32>(core::floor32(blockSize.Width*thRel.X), core::floor32(blockSize.Height*thRel.Y)));
core::dimension2d<u32>(core::floor32(blockSize.Width*thRel.X), core::floor32(blockSize.Height*thRel.Y))), 0);
sprintf(textureName, "terrain%u_%u", tm, mesh->getMeshBufferCount());
......
......@@ -40,39 +40,6 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size, void* d
}
//! Constructor from other image, with color conversion
CImage::CImage(ECOLOR_FORMAT format, IImage* imageToCopy)
: Data(0), Format(format), DeleteMemory(true)
{
if (!imageToCopy)
return;
Size = imageToCopy->getDimension();
initData();
// now copy data from other image
Blit ( BLITTER_TEXTURE, this, 0, 0, imageToCopy, 0,0 );
}
//! Constructor from other image, partially
CImage::CImage(IImage* imageToCopy, const core::position2d<s32>& pos,
const core::dimension2d<u32>& size)
: Data(0), Size(0,0), DeleteMemory(true)
{
if (!imageToCopy)
return;
Format = imageToCopy->getColorFormat();
Size = size;
initData();
core::rect<s32> sClip( pos.X, pos.Y, pos.X + size.Width,pos.Y + size.Height );
Blit (BLITTER_TEXTURE, this, 0, 0, imageToCopy, &sClip, 0);
}
//! assumes format and size has been set and creates the rest
void CImage::initData()
{
......
......@@ -19,23 +19,16 @@ class CImage : public IImage
{
public:
//! constructor from another image with format change
CImage(ECOLOR_FORMAT format, IImage* imageToCopy);
//! constructor from raw image data
//! \param useForeignMemory: If true, the image will use the data pointer
//! directly and own it from now on, which means it will also try to delete [] the
//! data when the image will be destructed. If false, the memory will by copied.
/** \param useForeignMemory: If true, the image will use the data pointer
directly and own it from now on, which means it will also try to delete [] the
data when the image will be destructed. If false, the memory will by copied. */
CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size,
void* data, bool ownForeignMemory=true, bool deleteMemory = true);
//! constructor for empty image
CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size);
//! constructor using a part from another image
CImage(IImage* imageToCopy,
const core::position2d<s32>& pos, const core::dimension2d<u32>& size);
//! destructor
virtual ~CImage();
......
......@@ -1347,20 +1347,26 @@ IImage* CNullDriver::createImage(ECOLOR_FORMAT format, const core::dimension2d<u
//! Creates a software image from another image.
IImage* CNullDriver::createImage(ECOLOR_FORMAT format, IImage *imageToCopy)
{
os::Printer::log("Deprecated method, please create an empty image instead and use copyTo().", ELL_WARNING);
if(IImage::isRenderTargetOnlyFormat(format))
{
os::Printer::log("Could not create IImage, format only supported for render target textures.", ELL_WARNING);
return 0;
}
return new CImage(format, imageToCopy);
CImage* tmp = new CImage(format, imageToCopy->getDimension());
imageToCopy->copyTo(tmp);
return tmp;
}
//! Creates a software image from part of another image.
IImage* CNullDriver::createImage(IImage* imageToCopy, const core::position2d<s32>& pos, const core::dimension2d<u32>& size)
{
return new CImage(imageToCopy, pos, size);
os::Printer::log("Deprecated method, please create an empty image instead and use copyTo().", ELL_WARNING);
CImage* tmp = new CImage(imageToCopy->getColorFormat(), imageToCopy->getDimension());
imageToCopy->copyTo(tmp, core::position2di(0,0), core::recti(pos,size));
return tmp;
}
......
......@@ -919,7 +919,11 @@ void CSoftwareDriver::clearZBuffer()
IImage* CSoftwareDriver::createScreenShot()
{
if (BackBuffer)
return new CImage(BackBuffer->getColorFormat(), BackBuffer);
{
CImage* tmp = new CImage(BackBuffer->getColorFormat(), BackBuffer->getDimension());
BackBuffer->copyTo(tmp);
return tmp;
}
else
return 0;
}
......
......@@ -26,7 +26,8 @@ CSoftwareTexture::CSoftwareTexture(IImage* image, const io::path& name, bool ren
OrigSize = image->getDimension();
core::dimension2d<u32> optSize=OrigSize.getOptimalSize();
Image = new CImage(ECF_A1R5G5B5, image);
Image = new CImage(ECF_A1R5G5B5, OrigSize);
image->copyTo(Image);
if (optSize == OrigSize)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment