-
Notifications
You must be signed in to change notification settings - Fork 437
CopyRectangle
DirectXTex |
---|
Copies a rectangle of pixels from one image to another.
HRESULT CopyRectangle(
const Image& srcImage, const Rect& srcRect,
const Image& dstImage,
TEX_FILTER_FLAGS 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).
struct Rect
{
size_t x;
size_t y;
size_t w;
size_t h;
}
filter: One or more Filter Flags. The default value is TEX_FILTER_DEFAULT
. 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.Initialize2D( ... );
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.
Block compressed images are not supported as either the source or destination. Use Decompress to uncompress BC images before using this function.
This function cannot operate directly on a planar format image. See ConvertToSinglePlane for a method for converting planar data to a format that is supported by this routine.
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 [email protected] with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Windows 7 Service Pack 1
- Xbox One
- Xbox Series X|S
- Windows Subsystem for Linux
- 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