public Matrix(Rectangle rect, Point[] plgpts) { if (plgpts == null) { throw new ArgumentNullException("plgpts"); } if (plgpts.Length != 3) { throw SafeNativeMethods.Gdip.StatusException(2); } IntPtr handle = SafeNativeMethods.Gdip.ConvertPointToMemory(plgpts); try { IntPtr zero = IntPtr.Zero; GPRECT gprect = new GPRECT(rect); int status = SafeNativeMethods.Gdip.GdipCreateMatrix3I(ref gprect, new HandleRef(null, handle), out zero); if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } this.nativeMatrix = zero; } finally { Marshal.FreeHGlobal(handle); } }
public Region(Rectangle rect) { IntPtr zero = IntPtr.Zero; GPRECT gprect = new GPRECT(rect); int status = SafeNativeMethods.Gdip.GdipCreateRegionRectI(ref gprect, out zero); if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } this.SetNativeRegion(zero); }
public GraphicsContainer BeginContainer(Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit) { GraphicsContext context = new GraphicsContext(this); int state = 0; GPRECT dstRect = new GPRECT(dstrect); GPRECT srcRect = new GPRECT(srcrect); int status = SafeNativeMethods.Gdip.GdipBeginContainerI(new HandleRef(this, this.NativeGraphics), ref dstRect, ref srcRect, (int) unit, out state); if (status != 0) { context.Dispose(); throw SafeNativeMethods.Gdip.StatusException(status); } context.State = state; this.PushContext(context); return new GraphicsContainer(state); }
internal static extern int GdipCombineRegionRectI(HandleRef region, ref GPRECT gprect, CombineMode mode);
public void EnumerateMetafile(Metafile metafile, Point[] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr) { if (destPoints == null) { throw new ArgumentNullException("destPoints"); } if (destPoints.Length != 3) { throw new ArgumentException(System.Drawing.SR.GetString("GdiplusDestPointsInvalidParallelogram")); } IntPtr handle = (metafile == null) ? IntPtr.Zero : metafile.nativeImage; IntPtr ptr2 = (imageAttr == null) ? IntPtr.Zero : imageAttr.nativeImageAttributes; IntPtr ptr3 = SafeNativeMethods.Gdip.ConvertPointToMemory(destPoints); GPRECT gprect = new GPRECT(srcRect); int status = SafeNativeMethods.Gdip.GdipEnumerateMetafileSrcRectDestPointsI(new HandleRef(this, this.NativeGraphics), new HandleRef(metafile, handle), ptr3, destPoints.Length, ref gprect, (int) unit, callback, new HandleRef(null, callbackData), new HandleRef(imageAttr, ptr2)); Marshal.FreeHGlobal(ptr3); if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } }
public void EnumerateMetafile(Metafile metafile, Point[] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr) { if (destPoints == null) throw new ArgumentNullException("destPoints"); if (destPoints.Length != 3) { throw new ArgumentException(SR.GetString(SR.GdiplusDestPointsInvalidParallelogram)); } IntPtr mf = (metafile == null ? IntPtr.Zero : metafile.nativeImage); IntPtr ia = (imageAttr == null ? IntPtr.Zero : imageAttr.nativeImageAttributes); IntPtr buffer = SafeNativeMethods.Gdip.ConvertPointToMemory(destPoints); GPRECT gpSrc = new GPRECT(srcRect); int status = SafeNativeMethods.Gdip.GdipEnumerateMetafileSrcRectDestPointsI(new HandleRef(this, this.NativeGraphics), new HandleRef(metafile, mf), buffer, destPoints.Length, ref gpSrc, unchecked((int) unit), callback, new HandleRef(null, callbackData), new HandleRef(imageAttr, ia)); Marshal.FreeHGlobal(buffer); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } }
// int version /// <include file='doc\Region.uex' path='docs/doc[@for="Region.Complement1"]/*' /> /// <devdoc> /// Updates this <see cref='System.Drawing.Region'/> to the portion of the /// specified <see cref='System.Drawing.Rectangle'/> that does not intersect with this <see cref='System.Drawing.Region'/>. /// </devdoc> public void Complement(Rectangle rect) { GPRECT gprect = new GPRECT(rect); int status = SafeNativeMethods.Gdip.GdipCombineRegionRectI(new HandleRef(this, nativeRegion), ref gprect, CombineMode.Complement); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); }
public LinearGradientBrush(Rectangle rect, Color color1, Color color2, float angle, bool isAngleScaleable) { IntPtr brush = IntPtr.Zero; //validate the rect if (rect.Width == 0 || rect.Height == 0) { throw new ArgumentException(SR.GetString(SR.GdiplusInvalidRectangle, rect.ToString())); } GPRECT gprect = new GPRECT(rect); int status = SafeNativeMethods.Gdip.GdipCreateLineBrushFromRectWithAngleI(ref gprect, color1.ToArgb(), color2.ToArgb(), angle, isAngleScaleable, (int)WrapMode.Tile, out brush); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); SetNativeBrushInternal(brush); }
public void Xor(Rectangle rect) { GPRECT gprect = new GPRECT(rect); int status = SafeNativeMethods.Gdip.GdipCombineRegionRectI(new HandleRef(this, this.nativeRegion), ref gprect, CombineMode.Xor); if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } }
public Region(Rectangle rect) { IntPtr region = IntPtr.Zero; GPRECT gprect = new GPRECT(rect); int status = SafeNativeMethods.Gdip.GdipCreateRegionRectI(ref gprect, out region); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); SetNativeRegion(region); }
public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string description) { int num; System.Drawing.IntSecurity.DemandReadFileIO(fileName); System.Drawing.IntSecurity.ObjectFromWin32Handle.Demand(); IntPtr zero = IntPtr.Zero; if (frameRect.IsEmpty) { num = SafeNativeMethods.Gdip.GdipRecordMetafileFileName(fileName, new HandleRef(null, referenceHdc), (int) type, System.Drawing.NativeMethods.NullHandleRef, (int) frameUnit, description, out zero); } else { GPRECT gprect = new GPRECT(frameRect); num = SafeNativeMethods.Gdip.GdipRecordMetafileFileNameI(fileName, new HandleRef(null, referenceHdc), (int) type, ref gprect, (int) frameUnit, description, out zero); } if (num != 0) { throw SafeNativeMethods.Gdip.StatusException(num); } base.SetNativeImage(zero); }
internal static extern int GdipEnumerateMetafileDestRectI(HandleRef graphics, HandleRef metafile, ref GPRECT destRect, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
internal static extern int GdipEnumerateMetafileSrcRectDestPointsI(HandleRef graphics, HandleRef metafile, IntPtr destPoints, int count, ref GPRECT srcRect, int pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
internal static extern int GdipBitmapLockBits(HandleRef bitmap, ref GPRECT rect, ImageLockMode flags, // ImageLockMode PixelFormat format, // PixelFormat [In, Out] BitmapData lockedBitmapData);
internal static extern int GdipCreateLineBrushFromRectWithAngleI(ref GPRECT rect, int color1, int color2, float angle, bool isAngleScaleable, int wrapMode, out IntPtr lineGradient);
internal static extern int GdipCreateLineBrushFromRectI(ref GPRECT rect, int color1, int color2, int lineGradientMode, int wrapMode, out IntPtr lineGradient);
public void EnumerateMetafile(Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr) { IntPtr handle = (metafile == null) ? IntPtr.Zero : metafile.nativeImage; IntPtr ptr2 = (imageAttr == null) ? IntPtr.Zero : imageAttr.nativeImageAttributes; GPRECT gprect = new GPRECT(destRect); GPRECT gprect2 = new GPRECT(srcRect); int status = SafeNativeMethods.Gdip.GdipEnumerateMetafileSrcRectDestRectI(new HandleRef(this, this.NativeGraphics), new HandleRef(metafile, handle), ref gprect, ref gprect2, (int) unit, callback, new HandleRef(null, callbackData), new HandleRef(imageAttr, ptr2)); if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } }
public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string description) { IntSecurity.ObjectFromWin32Handle.Demand(); IntPtr metafile = IntPtr.Zero; int status; if (frameRect.IsEmpty) { status = SafeNativeMethods.Gdip.GdipRecordMetafileStream(new GPStream(stream), new HandleRef(null, referenceHdc), unchecked((int)type), NativeMethods.NullHandleRef, unchecked((int)frameUnit), description, out metafile); } else { GPRECT gprect = new GPRECT(frameRect); status = SafeNativeMethods.Gdip.GdipRecordMetafileStreamI(new GPStream(stream), new HandleRef(null, referenceHdc), unchecked((int)type), ref gprect, unchecked((int)frameUnit), description, out metafile); } if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); SetNativeImage(metafile); }
internal static extern int GdipBeginContainerI(HandleRef graphics, ref GPRECT dstRect, ref GPRECT srcRect, int unit, out int state);
/// <include file='doc\GraphicsPath.uex' path='docs/doc[@for="GraphicsPath.AddString3"]/*' /> /// <devdoc> /// <para> /// Adds a text string to the current figure. /// </para> /// </devdoc> public void AddString(String s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format) { GPRECT rect = new GPRECT(layoutRect); int status = SafeNativeMethods.Gdip.GdipAddPathStringI(new HandleRef(this, nativePath), s, s.Length, new HandleRef(family, (family != null) ? family.NativeFamily : IntPtr.Zero), style, emSize, ref rect, new HandleRef(format, (format != null) ? format.nativeFormat : IntPtr.Zero)); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); }
// int version /// <include file='doc\Matrix.uex' path='docs/doc[@for="Matrix.Matrix3"]/*' /> /// <devdoc> /// <para> /// Initializes a new instance of the <see cref='System.Drawing.Drawing2D.Matrix'/> class to the geometrical transform /// defined by the specified rectangle and array of points. /// </para> /// </devdoc> public Matrix(Rectangle rect, Point[] plgpts) { if (plgpts == null) { throw new ArgumentNullException("plgpts"); } if (plgpts.Length != 3) { throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter); } IntPtr buf = SafeNativeMethods.Gdip.ConvertPointToMemory(plgpts); try { IntPtr matrix = IntPtr.Zero; GPRECT gprect = new GPRECT(rect); int status = SafeNativeMethods.Gdip.GdipCreateMatrix3I(ref gprect, new HandleRef(null, buf), out matrix); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } this.nativeMatrix = matrix; } finally { Marshal.FreeHGlobal(buf); } }
internal static extern int GdipRecordMetafileFileNameI(string fileName, HandleRef referenceHdc, int emfType, ref GPRECT frameRect, int frameUnit, string description, out IntPtr metafile);
public LinearGradientBrush(Rectangle rect, Color color1, Color color2, LinearGradientMode linearGradientMode) { //validate the LinearGradientMode enum //valid values are 0x0 to 0x3 if (!ClientUtils.IsEnumValid(linearGradientMode, unchecked((int)linearGradientMode), (int)LinearGradientMode.Horizontal, (int)LinearGradientMode.BackwardDiagonal)) { throw new InvalidEnumArgumentException("linearGradientMode", unchecked((int)linearGradientMode), typeof(LinearGradientMode)); } //validate the rect if (rect.Width == 0 || rect.Height == 0) { throw new ArgumentException(SR.GetString(SR.GdiplusInvalidRectangle, rect.ToString())); } IntPtr brush = IntPtr.Zero; GPRECT gpRect = new GPRECT(rect); int status = SafeNativeMethods.Gdip.GdipCreateLineBrushFromRectI(ref gpRect, color1.ToArgb(), color2.ToArgb(), unchecked((int) linearGradientMode), (int)WrapMode.Tile, out brush); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); SetNativeBrushInternal(brush); }
internal static extern int GdipRecordMetafileStreamI(UnsafeNativeMethods.IStream stream, HandleRef referenceHdc, int emfType, ref GPRECT frameRect, int frameUnit, string description, out IntPtr metafile);
internal static extern int GdipAddPathStringI(HandleRef path, string s, int length, HandleRef fontFamily, int style, float emSize, ref GPRECT layoutRect, HandleRef format);
internal static extern int GdipCreateMatrix3I(ref GPRECT rect, HandleRef dstplg, out IntPtr matrix);
public void EnumerateMetafile(Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr) { IntPtr mf = (metafile == null ? IntPtr.Zero : metafile.nativeImage); IntPtr ia = (imageAttr == null ? IntPtr.Zero : imageAttr.nativeImageAttributes); GPRECT gpDest = new GPRECT(destRect); GPRECT gpSrc = new GPRECT(srcRect); int status = SafeNativeMethods.Gdip.GdipEnumerateMetafileSrcRectDestRectI(new HandleRef(this, this.NativeGraphics), new HandleRef(metafile, mf), ref gpDest, ref gpSrc, unchecked((int) unit), callback, new HandleRef(null, callbackData), new HandleRef(imageAttr, ia)); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } }
internal static extern int GdipCreateRegionRectI(ref GPRECT gprect, out IntPtr region);
public BitmapData LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format, BitmapData bitmapData) { Contract.Ensures(Contract.Result<BitmapData>() != null); GPRECT gprect = new GPRECT(rect); int status = SafeNativeMethods.Gdip.GdipBitmapLockBits(new HandleRef(this, nativeImage), ref gprect, flags, format, bitmapData); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); return bitmapData; }
public BitmapData LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format, BitmapData bitmapData) { GPRECT gprect = new GPRECT(rect); int status = SafeNativeMethods.Gdip.GdipBitmapLockBits(new HandleRef(this, base.nativeImage), ref gprect, flags, format, bitmapData); if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } return bitmapData; }