public BitmapGdi ToBitmapGdi() { var result = new BitmapGdi(Width, Height); result.CopyPixelsFrom(this); return(result); }
public static BitmapGdi ToBitmapGdi(this BitmapSource src) { var result = new BitmapGdi(src.PixelWidth, src.PixelHeight); result.CopyPixelsFrom(src); return(result); }
/// <summary>Returns a new blank (transparent) GDI bitmap of the specified size.</summary> /// <param name="draw">Optionally a method to draw into the returned image.</param> public static BitmapGdi NewBitmapGdi(int width, int height, Action <D.Graphics> draw) { var result = new BitmapGdi(width, height); if (draw != null) { using (var g = D.Graphics.FromImage(result.Bitmap)) draw(g); } return(result); }
/// <summary> /// Returns a bitmap containing the specified text drawn using the specified font and brush onto a transparent /// image. The image is sized to be as small as possible without running the risk of clipping the text. /// </summary> public static BitmapGdi TextToBitmap(this D.Graphics graphics, string text, D.Font font, D.Brush brush) { var size = graphics.MeasureString(text, font); // the default is to include any overhangs into the calculation var bmp = new BitmapGdi((int)size.Width + 1, (int)size.Height + 1); using (var g = D.Graphics.FromImage(bmp.Bitmap)) { g.CompositingQuality = graphics.CompositingQuality; g.InterpolationMode = graphics.InterpolationMode; g.PixelOffsetMode = graphics.PixelOffsetMode; g.SmoothingMode = graphics.SmoothingMode; g.TextRenderingHint = graphics.TextRenderingHint; g.DrawString(text, font, brush, 0, 0); } return(bmp); }
public BitmapGdi ToBitmapGdi() { var result = new BitmapGdi(Width, Height); result.CopyPixelsFrom(this); return result; }
/// <summary>A shorthand for drawing an image into a GDI image at coordinate 0,0.</summary> public static BitmapGdi DrawImage(this BitmapGdi target, BitmapGdi source) { using (var g = D.Graphics.FromImage(target.Bitmap)) g.DrawImageUnscaled(source.Bitmap, 0, 0); return(target); }
/// <summary>A shorthand for drawing an image at coordinate 0,0.</summary> public static void DrawImage(this DrawingContext context, BitmapGdi bmp) { context.DrawImage(bmp.ToWpf(), new Rect(0, 0, bmp.Width, bmp.Height)); }
public static BitmapGdi ToBitmapGdi(this BitmapSource src) { var result = new BitmapGdi(src.PixelWidth, src.PixelHeight); result.CopyPixelsFrom(src); return result; }
/// <summary> /// Returns a bitmap containing the specified text drawn using the specified font and brush onto a transparent /// image. The image is sized to be as small as possible without running the risk of clipping the text. /// </summary> public static BitmapGdi TextToBitmap(this D.Graphics graphics, string text, D.Font font, D.Brush brush) { var size = graphics.MeasureString(text, font); // the default is to include any overhangs into the calculation var bmp = new BitmapGdi((int) size.Width + 1, (int) size.Height + 1); using (var g = D.Graphics.FromImage(bmp.Bitmap)) { g.CompositingQuality = graphics.CompositingQuality; g.InterpolationMode = graphics.InterpolationMode; g.PixelOffsetMode = graphics.PixelOffsetMode; g.SmoothingMode = graphics.SmoothingMode; g.TextRenderingHint = graphics.TextRenderingHint; g.DrawString(text, font, brush, 0, 0); } return bmp; }
/// <summary>Returns a new blank (transparent) GDI bitmap of the specified size.</summary> /// <param name="draw">Optionally a method to draw into the returned image.</param> public static BitmapGdi NewBitmapGdi(int width, int height, Action<D.Graphics> draw) { var result = new BitmapGdi(width, height); if (draw != null) using (var g = D.Graphics.FromImage(result.Bitmap)) draw(g); return result; }
/// <summary>A shorthand for drawing an image into a GDI image at coordinate 0,0.</summary> public static BitmapGdi DrawImage(this BitmapGdi target, BitmapGdi source) { using (var g = D.Graphics.FromImage(target.Bitmap)) g.DrawImageUnscaled(source.Bitmap, 0, 0); return target; }