private RectangleF _GetRectangle() { GPRECTF gprectf = new GPRECTF(); int status = SafeNativeMethods.Gdip.GdipGetPathGradientRect(new HandleRef(this, base.NativeBrush), ref gprectf); if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } return gprectf.ToRectangleF(); }
public RectangleF GetBounds(ref GraphicsUnit pageUnit) { GPRECTF gprectf = new GPRECTF(); int status = SafeNativeMethods.Gdip.GdipGetImageBounds(new HandleRef(this, nativeImage), ref gprectf, out pageUnit); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); return gprectf.ToRectangleF(); }
public RectangleF GetBounds(Graphics g) { if (g == null) { throw new ArgumentNullException("g"); } GPRECTF gprectf = new GPRECTF(); int status = SafeNativeMethods.Gdip.GdipGetRegionBounds(new HandleRef(this, this.nativeRegion), new HandleRef(g, g.NativeGraphics), ref gprectf); if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } return gprectf.ToRectangleF(); }
/** * Get source rectangle */ private RectangleF _GetRectangle() { GPRECTF rect = new GPRECTF(); int status = SafeNativeMethods.Gdip.GdipGetLineRect(new HandleRef(this, this.NativeBrush), ref rect); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); return rect.ToRectangleF(); }
/// <include file='doc\GraphicsPath.uex' path='docs/doc[@for="GraphicsPath.GetBounds2"]/*' /> /// <devdoc> /// <para> /// Returns a rectangle that bounds this <see cref='System.Drawing.Drawing2D.GraphicsPath'/> when it is /// transformed by the specified <see cref='System.Drawing.Drawing2D.Matrix'/>. and drawn with the specified <see cref='System.Drawing.Pen'/>. /// </para> /// </devdoc> public RectangleF GetBounds(Matrix matrix, Pen pen) { GPRECTF gprectf = new GPRECTF(); IntPtr nativeMatrix = IntPtr.Zero, nativePen = IntPtr.Zero; if (matrix != null) nativeMatrix = matrix.nativeMatrix; if (pen != null) nativePen = pen.NativePen; int status = SafeNativeMethods.Gdip.GdipGetPathWorldBounds(new HandleRef(this, nativePath), ref gprectf, new HandleRef(matrix, nativeMatrix), new HandleRef(pen, nativePen)); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); return gprectf.ToRectangleF(); }
public RectangleF[] GetRegionScans(Matrix matrix) { if (matrix == null) throw new ArgumentNullException("matrix"); int count = 0; // call first time to get actual count of rectangles int status = SafeNativeMethods.Gdip.GdipGetRegionScansCount(new HandleRef(this, nativeRegion), out count, new HandleRef(matrix, matrix.nativeMatrix)); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); RectangleF[] rectangles; int rectsize = (int)Marshal.SizeOf(typeof(GPRECTF)); IntPtr memoryRects = Marshal.AllocHGlobal(checked(rectsize*count)); try { status = SafeNativeMethods.Gdip.GdipGetRegionScans(new HandleRef(this, nativeRegion), memoryRects, out count, new HandleRef(matrix, matrix.nativeMatrix)); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } int index; GPRECTF gprectf = new GPRECTF(); rectangles = new RectangleF[count]; for (index=0; index<count; index++) { gprectf = (GPRECTF) UnsafeNativeMethods.PtrToStructure((IntPtr)(checked((long)memoryRects + rectsize*index)), typeof(GPRECTF)); rectangles[index] = gprectf.ToRectangleF(); } }finally { Marshal.FreeHGlobal(memoryRects); } return rectangles; }