Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing a new System.Drawing.Bitmap

Tags:

.net

linqpad

This code generates an exception with the latest LINQPad 4.28 beta

new System.Drawing.Bitmap(200, 200).Dump();

Is this a problem in my code or a problem with LINQPad's .Dump() extension method?

like image 235
Bent Rasmussen Avatar asked Nov 22 '10 00:11

Bent Rasmussen


People also ask

What is System drawing bitmap?

Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes. A Bitmap is an object used to work with images defined by pixel data.


1 Answers

Being able to dump bitmaps is a new feature of the LINQPad 4.28 beta - but it seems there's a bug. I'll upload a fix later today.

Edit: The new build has now been uploaded. You can test it by running this:

using (var b = new System.Drawing.Bitmap (400, 200))
using (var g = Graphics.FromImage (b))
using (var f = new Font ("Arial", 40))
{
    g.SmoothingMode = SmoothingMode.AntiAlias;
    g.FillEllipse (Brushes.CadetBlue, 0, 0, 400, 200);
    g.DrawString ("LINQPad", f, Brushes.Black, 75, 70);
    b.Dump();
}

Note that you can also dump images by calling Util.Image, passing in a filename or URI. You can use the latter to draw graphs using Google's Chart API; for example, the following:

Util.Image ("http://chart.apis.google.com/chart?cht=p3&chd=s:Uf9a&chs=350x140&chl=January|February|March|April")

generates this output:

Google Chart Demo

like image 165
Joe Albahari Avatar answered Sep 24 '22 13:09

Joe Albahari