Esempio n. 1
0
        public RectangleF[] GetRegionScans(Matrix matrix)
        {
            if (matrix == null)
            {
                throw new ArgumentNullException("matrix");
            }

            int cnt;

            Status status = GDIPlus.GdipGetRegionScansCount(nativeRegion, out cnt, matrix.NativeObject);

            GDIPlus.CheckStatus(status);

            if (cnt == 0)
            {
                return(new RectangleF[0]);
            }

            RectangleF[] rects = new RectangleF [cnt];
            int          size  = Marshal.SizeOf(rects[0]);

            IntPtr dest = Marshal.AllocHGlobal(size * cnt);

            try {
                status = GDIPlus.GdipGetRegionScans(nativeRegion, dest, out cnt, matrix.NativeObject);
                GDIPlus.CheckStatus(status);
            }
            finally {
                // note: Marshal.FreeHGlobal is called from GDIPlus.FromUnManagedMemoryToRectangles
                GDIPlus.FromUnManagedMemoryToRectangles(dest, rects);
            }
            return(rects);
        }