Create a circle avatar image in .net

Tija

I want to create a default avatar image which is a circle with initials in it. I want to do this on the server side as a png. Is this possible using the .net graphics library?

Tija

I ended up doing this. Thanks for pointing me in the right direction TaW

public ActionResult Avatar()
        {
            using (var bitmap = new Bitmap(50, 50))
            {
                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    g.Clear(Color.White);
                    using (Brush b = new SolidBrush(ColorTranslator.FromHtml("#eeeeee")))
                    {

                        g.FillEllipse(b, 0, 0, 49, 49);
                    }

                    float emSize = 12;
                    g.DrawString("AM", new Font(FontFamily.GenericSansSerif, emSize, FontStyle.Regular),
                        new SolidBrush(Color.Black), 10, 15);
                }

                using (var memStream = new System.IO.MemoryStream())
                {
                    bitmap.Save(memStream, System.Drawing.Imaging.ImageFormat.Png);
                    var result = this.File(memStream.GetBuffer(), "image/png");
                    return result;
                }
            }
        }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Create a circular Image avatar with child circle as status

Create a circle avatar from a rectangle image keeping proportions and just using centre of image

How to assign image to Circle avatar -flutter

How to display a circle avatar image in flutter?

How to display picked image in a circle avatar in Flutter?

Network Image is not being shown in circle avatar flutter

How to create circle avatar with a status circle using css?

how to add Image.file as backgroundimage of Circle avatar

Flutter: How can I set a background image for Circle Avatar

how to fetch an image from gallery or camera in circle avatar?

How to create Circle avatar with gradient color outline in flutter

How to create pentagon shape for avatar image?

CSS - Create a circle on image start

Flutter circle avatar

Flutter CIrcle Avatar With Border

Image does not show on leading part of list tile when using Circle Avatar and back ground image

How do I create star shape for avatar image?

Flutter/Dart - Convert image(base64) show error in circle avatar

I am trying to create circle avatar in Flutter. I have tried this but not giving me circle please check the code bellow:

Have a circle around Avatar component

How to display circle avatar on AppBar?

Flutter - Circle Avatar with Progress Bar

Stack circle avatar on top of drawer

How to create a circle div around an image in CSS?

Create Circle button with network image and ripple effect

How to create circle image in pug file/css

Online - avatar Image with viewport

Display an image in avatar React

Avatar image in Leverice