-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageFrame.cs
More file actions
48 lines (47 loc) · 1.66 KB
/
Copy pathImageFrame.cs
File metadata and controls
48 lines (47 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Edge_Detection
{
class ImageFrame
{
public Bitmap AddFrame(Bitmap Image)
{
int width = Image.Width;
int height = Image.Height;
int fpix = Properties.Settings.Default.FramingPixel;
Color c = Properties.Settings.Default.FramingColor;
Bitmap result = new Bitmap(width + (2 * fpix), height + (2 * fpix));
LockBitmap org = new LockBitmap(Image);
LockBitmap res = new LockBitmap(result);
org.LockBits();
res.LockBits();
for (int i = 0; i < fpix; i++)
for (int j = 0; j < width + (2 * fpix); j++)
{
res.SetPixel(j, i, c);
res.SetPixel(j, height+fpix+i, c);
}
for(int i=fpix;i<height+fpix;i++)
{
for (int j = 0; j < fpix; j++)
res.SetPixel(j, i, c);
for (int j = fpix; j < width + fpix; j++)
{
int x=org.GetPixel(j-fpix,i-fpix).R;
int y=org.GetPixel(j - fpix, i-fpix).G;
int z= org.GetPixel(j - fpix, i-fpix).B;
res.SetPixel(j, i, Color.FromArgb(x,y,z));
}
for (int j = width+fpix; j < width+(2*fpix); j++)
res.SetPixel(j, i, c);
}
res.UnlockBits();
org.UnlockBits();
return result;
}
}
}