public static RGNDATAHEADER Create(Rectangle region, int rectangleCount) { RGNDATAHEADER header = new RGNDATAHEADER(); header.dwSize = Marshal.SizeOf(typeof(RGNDATAHEADER)); header.iType = RegionDataHeaderTypes.Rectangles; header.rcBound = region; header.nCount = rectangleCount; return(header); }
public unsafe RECT[] GetRegionRects() { uint regionDataSize = GetRegionData(Handle, 0, IntPtr.Zero); if (regionDataSize == 0) { return(Array.Empty <RECT>()); } byte[] buffer = ArrayPool <byte> .Shared.Rent((int)regionDataSize); fixed(byte *b = buffer) { if (GetRegionData(Handle, regionDataSize, (IntPtr)b) != regionDataSize) { return(Array.Empty <RECT>()); } RECT[] result = RGNDATAHEADER.GetRegionRects((RGNDATAHEADER *)b); ArrayPool <byte> .Shared.Return(buffer); return(result); } }