chmichael 12 Posted October 14, 2023 (edited) Hello, Anyone knows how to copy the Bits from a ID3D11Texture2D which it has different RowPitch than Bitmap.Width * 4 ? if FTexture.RowPitch = FBitmap.Width * 4 then for I := 0 to FBitmap.Height - 1 do Move(FTexture.pData[4 * FBitmap.Width * I], FBitmap.Scanline^, 4 * FBitmap.Width); else ????? Thank you Edited October 14, 2023 by chmichael Share this post Link to post
Rollo62 538 Posted October 16, 2023 https://github.com/tothpaul/Delphi/blob/master/DesktopDuplicationAPI/lib/Execute.DesktopDuplicationAPI.pas Share this post Link to post
chmichael 12 Posted October 17, 2023 19 hours ago, Rollo62 said: https://github.com/tothpaul/Delphi/blob/master/DesktopDuplicationAPI/lib/Execute.DesktopDuplicationAPI.pas I have checked that but it doesn't check the RowPitch. Share this post Link to post
Renate Schaaf 64 Posted October 17, 2023 On 10/14/2023 at 3:42 PM, chmichael said: Anyone knows how to copy the Bits from a ID3D11Texture2D which it has different RowPitch than Bitmap.Width * 4 ? It doesn't only depend to the pitch, but also on the pixel-format of the source. If that is BGR or BGRA, the following pseudo-code based on what you post should be usable. If the color-order is different, like RGB or RGBA, you need to copy the single color-bytes. Best done by defining a record for the pixel. // Pointers to Pixels in Source/Target to be copied var pPixS, pPixT: pByte; // Bytes per Pixel for the Source-Texture // would be 3 for BGR, 4 for BGRA // if the channels have a different order, like RGB, // then the single color bytes need to be copied. var BytesPerPixel: integer; // Common Width and Height of Source and Target var Width, Height: integer; for I := 0 to Height - 1 do begin pPixS := @FTexture.pData[FTexture.RowPitch * I]; pPixT := FBitmap.Scanline[I]; for j := 0 to Width - 1 do begin Move(pPixS^, pPixT^, BytesPerPixel); inc(pPixS, BytesPerPixel); inc(pPixT, 4); end; end; 1 Share this post Link to post