How to use DirectXTex's CopyRectangle ?

Coordinator
Jan 29, 2014 at 5:40 PM
I want to get Image2 from Image1.

Finally, The output of Image2 is empty.

I need your suggestion.

Below is my code and pictrue to define variable.

Image
DirectX::ScratchImage DxImage;
HRESULT hr_0 = DirectX::CaptureTexture(  m_d3dDevice.Get() , m_d3dContext.Get() , d3DTexture.Get() , DxImage );
const Image* mage_1 = DxImage.GetImages();
Image Image_2;
        
DirectX::Rect rect( x1, y1, x2, y2 );
DirectX::CopyRectangle( *Image_1.GetImages(), rect , Image_2 , DirectX::TEX_FILTER_DEFAULT, x1, y1);
Coordinator
Jan 29, 2014 at 5:40 PM
Edited Jan 29, 2014 at 6:05 PM
using namespace DirectX;

ScratchImage DxImage;
HRESULT hr = CaptureTexture(  m_d3dDevice.Get() , m_d3dContext.Get() , d3DTexture.Get() , DxImage );
DX:ThrowIfFailed( hr );

const Image* Image_1 = DxImage.GetImages();

TexMetadata mdata = DxImage.GetMetadata();
mdata.width = x2 - x1 + 1;
mdata.height = y2 - y2 + 1;

ScratchImage CropImage;
hr = CropImage.Initialize( mdata );
DX:ThrowIfFailed( hr );

const Image* Image_2 = CropImage.GetImages();

Rect rect( x1, y1, mdata.width, mdata.height );
hr = CopyRectangle( *Image_1, rect, *Image_2, DirectX::TEX_FILTER_DEFAULT, 0, 0);
DX:ThrowIfFailed( hr );
Also, see the Wiki doc page for CopyRectangle.
Marked as answer by walbourn on 1/29/2014 at 10:40 AM
Feb 5, 2014 at 11:33 PM
Thank you very much. I don't known how to use wiki doc.