From c55429b4c2e96eaed85e60794bad209b6abdd035 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Sun, 21 Jun 2015 09:56:41 -0700 Subject: [PATCH] Created CopyRectangle (markdown) --- CopyRectangle.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 CopyRectangle.md diff --git a/CopyRectangle.md b/CopyRectangle.md new file mode 100644 index 0000000..3ae9853 --- /dev/null +++ b/CopyRectangle.md @@ -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. \ No newline at end of file