高分求C# 对图片进行描边的处理

mcdjxiao 2009-12-01 03:31:16
就这种效果 功能就是PS的描边功能
图片为PNG格式已知背景是透明的
...全文
645 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lang_csdn 2009-12-01
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 wartim 的回复:]
倒分?
[/Quote]

哈哈!!!真不好意思!居然检到分了!
wartim 2009-12-01
  • 打赏
  • 举报
回复
倒分?
mcdjxiao 2009-12-01
  • 打赏
  • 举报
回复
2楼的Q号多少哎呀 ··
mcdjxiao 2009-12-01
  • 打赏
  • 举报
回复
哈哈谢谢 结贴我没分哥们 。。。。。
lang_csdn 2009-12-01
  • 打赏
  • 举报
回复
顶!楼上,高手!
wartim 2009-12-01
  • 打赏
  • 举报
回复
高分?20分?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace WindowsApplication182
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

PictureBox PB = new PictureBox();
PB.Parent = this;
PB.Dock = DockStyle.Fill;
PB.Load(@"c:\pic.png");

Bitmap Bmp = new Bitmap(PB.Image);
GraphicsPath GP = new GraphicsPath();
Color C = Color.FromArgb(0, 0, 0, 0);

for (int i = 0; i < Bmp.Width; i++)
for (int j = 0; j < Bmp.Height; j++)
// 这点不透明而且左右上下四点至少有一点是透明的,那这点就是边缘
if (Bmp.GetPixel(i, j) != C
&& (i > 0 && Bmp.GetPixel(i - 1, j) == C
|| i < Bmp.Width - 1 && Bmp.GetPixel(i + 1, j) == C
|| j > 0 && Bmp.GetPixel(i, j - 1) == C
|| j < Bmp.Height - 1 && Bmp.GetPixel(i, j + 1) == C))
GP.AddRectangle(new Rectangle(new Point(i, j), new Size(1, 1)));

using (Graphics G = Graphics.FromImage(Bmp))
G.DrawPath(Pens.Black, GP);

PB.Image = Bmp;
}
}
}

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧