1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-09 22:40:06 +00:00

Created CopyRectangle (markdown)

Chuck Walbourn 2015-06-21 09:56:41 -07:00
parent ff00a41f7e
commit c55429b4c2

37
CopyRectangle.md Normal file

@ -0,0 +1,37 @@
Copies a rectangle of pixels from one image to another.
_Block compressed images are not supported as either the source or destination. Use [Decompress] to uncompress BC images before using this function._
HRESULT CopyRectangle( const Image& srcImage, const Rect& srcRect,
const Image& dstImage,
DWORD filter, size_t xOffset, size_t yOffset );
# Parameters
_srcRect_: A rectangle described with _x_, _y_ of the upper right corner, and _w_ and _h_ with the width and height, which indicates pixel location from _srcImage_ to copy. The _w_ and _h_ also define the size of the destination rectangle in _dstImage_. Both rectangles must be valid for the size of the images (i.e. the API does not support clipping).
_filter_: See [[Filter Flags]]. Source and destination images do not need to be the same format, in which case conversions will use these flags.
_xOffset_, _yOffset_: Pixel location of destination rectangle in _dstImage_. The width and height of the destination rectangle is the same as _srcRect.w_ and _srcRect.h_.
# Example
Here's an example that copies a source image to the location (100,50) location in a new, larger image.
ScratchImage srcImage;
...
ScratchImage destImage;
destImage.Iniitalize2D( ... );
auto mdata = srcImage.GetMetadata();
Rect r( 0, 0, mdata.width, mdata.height );
hr = CopyRectangle( *srcImage.GetImage(0,0,0), r, *dstImage.GetImage(0,0,0),
TEX_FILTER_DEFAULT, 100, 50 );
if ( FAILED(hr) )
...
# Remarks
Behavior of this function is not defined if the source and destination image are the same and the source and destination rectangles overlap.