Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ CopyData< T >() [2/3]

static unsafe void Microsoft.Xna.Framework.Graphics.Texture.CopyData< T > ( void * pData,
int pitch,
T[] data,
int dataIndex,
int elementCount,
_D3DSURFACE_DESC * pSurface,
uint dwLockWidth,
uint dwLockHeight,
[MarshalAs(UnmanagedType.U1)] bool isSetting )
inlinestaticpackageinherited
Type Constraints
T :struct 

Definition at line 278 of file Texture.cs.

278 : struct
279 {
280 if (pSurface == null)
281 {
282 return;
283 }
284 fixed (T* ptr2 = &data[dataIndex])
285 {
286 byte* ptr = (byte*)pData;
287 byte* ptr3 = (byte*)ptr2;
288 uint num = (uint)System.Runtime.CompilerServices.Unsafe.SizeOf<T>();
289 uint num2 = GetExpectedByteSizeFromFormat(*(_D3DFORMAT*)pSurface) / num;
290 int num3 = *(int*)pSurface;
291 _D3DFORMAT d3DFORMAT = (_D3DFORMAT)num3;
292 int num4 = ((d3DFORMAT == (_D3DFORMAT)827611204 || d3DFORMAT == (_D3DFORMAT)844388420 || d3DFORMAT == (_D3DFORMAT)861165636 || d3DFORMAT == (_D3DFORMAT)877942852 || d3DFORMAT == (_D3DFORMAT)894720068) ? 1 : 0);
293 if ((byte)num4 != 0)
294 {
295 dwLockWidth = dwLockWidth + 3 >> 2;
296 dwLockHeight = dwLockHeight + 3 >> 2;
297 num2 = ((num3 == 827611204) ? 8u : 16u);
298 }
299 uint num5 = num2 * num * dwLockWidth;
300 if (0 >= dwLockHeight)
301 {
302 return;
303 }
304 uint num6 = dwLockHeight;
305 do
306 {
307 if (*(int*)pSurface == 21)
308 {
309 if (isSetting)
310 {
311 SwapBgr(ptr, ptr3, num5);
312 }
313 else
314 {
315 SwapBgr(ptr3, ptr, num5);
316 }
317 }
318 else if (isSetting)
319 {
320 _003CModule_003E.memcpy_s(ptr, num5, ptr3, num5);
321 }
322 else
323 {
324 _003CModule_003E.memcpy_s(ptr3, num5, ptr, num5);
325 }
326 ptr = pitch + ptr;
327 ptr3 = (int)num5 + ptr3;
328 num6--;
329 }
330 while (num6 != 0);
331 }
332 }
static unsafe void SwapBgr(void *pDest, void *pSrc, uint dwSize)
Definition Texture.cs:334
static byte GetExpectedByteSizeFromFormat(_D3DFORMAT format)
Definition Texture.cs:72

References Microsoft.Xna.Framework.Graphics.Texture.GetExpectedByteSizeFromFormat(), and Microsoft.Xna.Framework.Graphics.Texture.SwapBgr().