Have an account?

» Forgot your username or password?

» Register for Free

Piczard v1.x Support Forum Archive


The Piczard v1.x Support Forum is no longer active. This is a static read-only copy of it.
It's not possible to post new messages or replies.
Search | Active Topics

Filter for rounding image corners
kitchenpc
#1 Posted : Sunday, October 07, 2012 1:22:00 AM(UTC)

Rank: Newbie

Joined: 10/7/2012(UTC)
Posts: 1
Points: 3
Location: Redmond, WA

Thanks: 0 times
Was thanked: 1 time(s) in 1 post(s)
Hi all - I've decided to replace my own image processing code with Piczard, which I just found tonight. It's a fantastic product and it works much better than what I had before. However, one thing that I was doing with my own code was rounding image corners for effect. I decided to take a stab at writing this as an ImageProcessingFilter, and this is what I came up with.

Feel free to use it, steel it, provide feedback on, or improve upon.


public class CurvedCornerFilter : ImageProcessingFilter
{
int Radius { get; set; }

public CurvedCornerFilter(int radius) : base()
{
Radius = radius;
}

protected override void Apply(ImageProcessingActionExecuteArgs args)
{
int rad = Radius * 2;
Bitmap roundedImg = new Bitmap(args.Image.Width, args.Image.Height);
Graphics g = Graphics.FromImage(roundedImg);
g.SmoothingMode = SmoothingMode.HighQuality;
Brush brush = new TextureBrush(args.Image);
GraphicsPath gp = new GraphicsPath();
gp.AddArc(0, 0, rad, rad, 180, 90);
gp.AddArc(0 + args.Image.Width - rad, 0, rad, rad, 270, 90);
gp.AddArc(0 + args.Image.Width - rad, 0 + args.Image.Height - rad, rad, rad, 0, 90);
gp.AddArc(0, 0 + args.Image.Height - rad, rad, rad, 90, 90);
g.FillPath(brush, gp);

args.Image = roundedImg;
}
}
1 user thanked kitchenpc for this useful post.
smsavage32 on 1/20/2013(UTC)
sergioturolla
#2 Posted : Sunday, October 07, 2012 3:23:16 PM(UTC)

Rank: Administration

Joined: 3/11/2011(UTC)
Posts: 159
Points: 489

Thanks: 0 times
Was thanked: 28 time(s) in 28 post(s)
Hi,

Thank you for your contribution !
It's surely an useful image filter!

Have a nice day

Sergio
smsavage32
#3 Posted : Sunday, January 20, 2013 12:52:28 AM(UTC)
Rank: Newbie

Joined: 1/20/2013(UTC)
Posts: 4
Points: 12

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
Nice job!
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.