Browse Source

impove sample

af/merge-core
Scott Williams 9 years ago
parent
commit
87e43acdaa
  1. 19
      samples/AvatarWithRoundedCorner/Program.cs

19
samples/AvatarWithRoundedCorner/Program.cs

@ -11,18 +11,25 @@ namespace AvatarWithRoundedCorner
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
System.IO.Directory.CreateDirectory("output");
using (var image = Image.Load("fb.jpg"))
GenerateAvatar("fb.jpg", "output/fb.png", new ImageSharp.Size(200, 200), 20);
GenerateAvatar("fb.jpg", "output/fb-round.png", new ImageSharp.Size(200, 200), 100);
GenerateAvatar("fb.jpg", "output/fb-rounder.png", new ImageSharp.Size(200, 200), 150);
}
private static void GenerateAvatar(string source, string destination, ImageSharp.Size size, float cornerRadius)
{
using (var image = Image.Load(source))
{ {
image.Resize(new ImageSharp.Processing.ResizeOptions image.Resize(new ImageSharp.Processing.ResizeOptions
{ {
Size = new ImageSharp.Size(200, 200), Size = size,
Mode = ImageSharp.Processing.ResizeMode.Crop Mode = ImageSharp.Processing.ResizeMode.Crop
}); });
ApplyRoundedCourners(image, 30); ApplyRoundedCourners(image, cornerRadius);
System.IO.Directory.CreateDirectory("output"); image.Save(destination);
image.Save("output/fb.png");
} }
} }

Loading…
Cancel
Save