public unsafe static RECT[] GetRectsFromRegion(Gdi32.RGNDATAHEADER *regionData) { int count; if (regionData is null || (count = (int)regionData->nCount) == 0) { return(Array.Empty <RECT>()); } var regionRects = new RECT[count]; Span <RECT> sourceRects = new Span <RECT>((byte *)regionData + regionData->dwSize, count); sourceRects.CopyTo(regionRects.AsSpan()); return(regionRects); }