diff --git a/DirectXTex/DirectXTexD3D11.cpp b/DirectXTex/DirectXTexD3D11.cpp index 254e7b3..735fc57 100644 --- a/DirectXTex/DirectXTexD3D11.cpp +++ b/DirectXTex/DirectXTexD3D11.cpp @@ -171,11 +171,13 @@ namespace return E_UNEXPECTED; } + const size_t msize = (metadata.dimension == TEX_DIMENSION_TEXTURE2D) + ? std::min(img->rowPitch, mapped.RowPitch) : img->rowPitch; + auto sptr = static_cast(mapped.pData); uint8_t* dptr = img->pixels; for (size_t h = 0; h < lines; ++h) { - const size_t msize = std::min(img->rowPitch, mapped.RowPitch); memcpy(dptr, sptr, msize); sptr += mapped.RowPitch; dptr += img->rowPitch;