C# System.Drawing.Rectangle into Ellipse on System.Drawing.Bitmap -


i have facial recognition library working gives me array of rectangle. right i'm using way draw rectangle.

foreach (rectangle box in boxes) {      (int x = box.x; x <= box.x + box.width; x++)      {           (int y = box.y; y <= box.y + box.height; y++)           {                outputbmp.setpixel(x, y, color.fromknowncolor(knowncolor.red));           }      } } 

enter image description here

i'm looking simple as:

ellipse ellipse = new ellipse(box); //cast rect ellipse outputbmp.drawellipse(ellipse); 

which more like:

enter image description here

where outline of ellipse touching rectangle corners.

based on approach used above, easy draw rectangle ellipse, require me know points in ellipse. wonder if there's make life easier.

don't try draw directly bitmap, there higher level object can create, called graphics gives kinds of wonderful drawing tools. faster drawing pixel pixel.

you can create graphics given bitmap calling graphics.fromimage , passing in bitmap. must remember ti call dispose on graphics though, or leak resources.

once have graphics instance bitmap can call drawellipse , pass in bounds expect.

from msdn:

private void drawellipseint(graphics g) {     // create pen.     pen blackpen = new pen(color.black, 3);      // create location , size of ellipse.     int x = 0;     int y = 0;     int width = 200;     int height = 100;      // draw ellipse screen.     g.drawellipse(blackpen, x, y, width, height); } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -