diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IImage.h Irrlicht_starsonata/include/IImage.h --- irrlicht-svn-ss/trunk/include/IImage.h 2007-07-26 02:11:22.000000000 +0200 +++ Irrlicht_starsonata/include/IImage.h 2008-05-08 00:58:34.000000000 +0200 @@ -104,6 +104,12 @@ public: //! copies the image into the target, scaling the image to fit virtual void copyToScaling(IImage* target) = 0; + //! copies this surface into another + virtual void copyTo(IImage* target, const core::position2d& pos=core::position2d(0,0)) = 0; + + // starsonata, micha, needed this for padding d3d textures + //! copies this surface into another + virtual void copyTo(void* target, s32 width, s32 height, ECOLOR_FORMAT format, u32 pitch=0, const core::position2d& pos=core::position2d(0,0)) = 0; }; } // end namespace video diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CImage.cpp Irrlicht_starsonata/source/Irrlicht/CImage.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CImage.cpp 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CImage.cpp 2008-05-08 01:57:18.000000000 +0200 @@ -1267,6 +1267,49 @@ void CImage::drawLine(const core::positi } } +// starsonata, micha, needed this for padding d3d textures +// Not yet much tested. +//! copies this surface into another +// note: slow +void CImage::copyTo(void* target, s32 width, s32 height, ECOLOR_FORMAT format, u32 pitch, const core::position2d& pos) +{ + if (!target || !width || !height) + return; + + const u32 bpp=getBitsPerPixelFromFormat(format)/8; + if (0==pitch) + pitch = width*bpp; + + core::rect sourceRect(0,0, Size.Width, Size.Height); + if ( pos.X < 0 ) + sourceRect.UpperLeftCorner.X -= pos.X; + if ( pos.Y < 0 ) + sourceRect.UpperLeftCorner.Y -= pos.Y; + if ( sourceRect.LowerRightCorner.X + pos.X > width ) + sourceRect.LowerRightCorner.X = width - pos.X; + if ( sourceRect.LowerRightCorner.Y + pos.Y > height ) + sourceRect.LowerRightCorner.Y = height - pos.Y; + + s32 syval=sourceRect.UpperLeftCorner.Y*Pitch; + s32 tyval=pos.Y*pitch; + for (s32 y=sourceRect.UpperLeftCorner.Y; ylock(), targetSize.Width, targetSize.Height, target->getColorFormat()); + target->unlock(); } diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CImage.h Irrlicht_starsonata/source/Irrlicht/CImage.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CImage.h 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CImage.h 2008-05-08 00:58:42.000000000 +0200 @@ -99,6 +99,10 @@ public: //! copies this surface into another, scaling it to fit. void copyToScaling(void* target, s32 width, s32 height, ECOLOR_FORMAT format, u32 pitch=0); + // starsonata, micha, needed this for padding d3d textures + //! copies this surface into another + virtual void copyTo(void* target, s32 width, s32 height, ECOLOR_FORMAT format, u32 pitch=0, const core::position2d& pos=core::position2d(0,0)); + //! copies this surface into another, scaling it to fit. void copyToScaling(IImage* target);