/// <summary> /// Draws the specified portion of the specified <see cref="T:System.Drawing.Image"/> at the specified location and with the specified size. /// </summary> /// <param name="image"><see cref="T:System.Drawing.Image"/> to draw. </param> /// <param name="destRect"><see cref="T:System.Drawing.RectangleF"/> structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle. </param> /// <param name="srcRect"><see cref="T:System.Drawing.RectangleF"/> structure that specifies the portion of the <paramref name="image"/> object to draw. </param> /// <exception cref="T:System.ArgumentNullException"><paramref name="image"/> is null.</exception> public override void DrawImage(Image image, RectangleF destRect, RectangleF srcRect) { DrawingGL.GLBitmap glbmp = ResolveForGLBitmap(image); if (glbmp != null) { painter1.Canvas.DrawSubImage(glbmp, destRect.Left, srcRect.Top, srcRect.Width, srcRect.Height, destRect.Left, this.Height - destRect.Top); } }
/// <summary> /// Draws the specified <see cref="T:System.Drawing.Image"/> at the specified location and with the specified size. /// </summary> /// <param name="image"><see cref="T:System.Drawing.Image"/> to draw. </param><param name="destRect"><see cref="T:System.Drawing.Rectangle"/> structure that specifies the location and size of the drawn image. </param><exception cref="T:System.ArgumentNullException"><paramref name="image"/> is null.</exception><PermissionSet><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence"/></PermissionSet> public override void DrawImage(Image image, RectangleF destRect) { //1. image from outside //resolve to internal presentation DrawingGL.GLBitmap glbmp = ResolveForGLBitmap(image); if (glbmp != null) { painter1.Canvas.DrawImage(glbmp, destRect.X, this.Height - destRect.Y, destRect.Width, destRect.Height); } }
DrawingGL.GLBitmap ResolveForGLBitmap(Image image) { var cacheBmp = Image.GetCacheInnerImage(image) as DrawingGL.GLBitmap; if (cacheBmp != null) { return(cacheBmp); } else { //TODO: review here //we should create 'borrow' method ? => send direct exact ptr to img buffer //for now, create a new one -- after we copy we, don't use it var req = new Image.ImgBufferRequestArgs(32, Image.RequestType.Copy); image.RequestInternalBuffer(ref req); var glBmp = new DrawingGL.GLBitmap(image.Width, image.Height, req.OutputBuffer32, req.IsInvertedImage); Image.SetCacheInnerImage(image, glBmp); return(glBmp); } }