-
Notifications
You must be signed in to change notification settings - Fork 451
CopyRectangle
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 );
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.
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) )
...
Behavior of this function is not defined if the source and destination image are the same and the source and destination rectangles overlap.
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Xbox One
- Xbox Series X|S
- Windows Subsystem for Linux
- x86
- x64
- ARM64
- Visual Studio 2022
- Visual Studio 2019 (16.11)
- clang/LLVM v12 - v18
- GCC 10.5, 11.4, 12.3
- MinGW 12.2, 13.2
- CMake 3.20
DirectX Tool Kit for DirectX 11