| 1302 | } |
| 1303 | |
| 1304 | void Image::copyImage( Graphics::Image* image, const Uint32& x, const Uint32& y ) { |
| 1305 | if ( NULL != mPixels && NULL != image->getPixelsPtr() && mWidth >= x + image->getWidth() && |
| 1306 | mHeight >= y + image->getHeight() ) { |
| 1307 | unsigned int dWidth = image->getWidth(); |
| 1308 | unsigned int dHeight = image->getHeight(); |
| 1309 | |
| 1310 | if ( mChannels != image->getChannels() ) { |
| 1311 | for ( unsigned int ty = 0; ty < dHeight; ty++ ) { |
| 1312 | for ( unsigned int tx = 0; tx < dWidth; tx++ ) { |
| 1313 | setPixel( x + tx, y + ty, image->getPixel( tx, ty ) ); |
| 1314 | } |
| 1315 | } |
| 1316 | } else { |
| 1317 | // Copy per row |
| 1318 | for ( unsigned int ty = 0; ty < dHeight; ty++ ) { |
| 1319 | Uint8* pDst = &mPixels[( x + ( ( ty + y ) * mWidth ) ) * mChannels]; |
| 1320 | const Uint8* pSrc = &( ( image->getPixelsPtr() )[( ty * dWidth ) * mChannels] ); |
| 1321 | |
| 1322 | memcpy( pDst, pSrc, mChannels * dWidth ); |
| 1323 | } |
| 1324 | } |
| 1325 | } |
| 1326 | } |
| 1327 | |
| 1328 | void Image::resize( const Uint32& newWidth, const Uint32& newHeight, ResamplerFilter filter ) { |
| 1329 | if ( NULL != mPixels && ( mWidth != newWidth || mHeight != newHeight ) ) { |
no test coverage detected