-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockembedcs.cs
103 lines (73 loc) · 2.42 KB
/
blockembedcs.cs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Filtermap
{
class blockembed
{
public static Bitmap hideblocks(bool[] arr, Bitmap bmp)
{
int p=0;
// pass through the rows
for (int i = 0; i < bmp.Width ; i++)
{
// pass through each row
for (int j = 0; j < bmp.Height; j++)
{
// pass through each row
int R = 0, G = 0, B = 0;
// holds the pixel that is currently being processed
Color pixel = bmp.GetPixel(i, j);
G = pixel.G;
B = pixel.B;
try
{
if (arr[p]== true)
{
R = pixel.R | 1;
}
else
R = pixel.R - pixel.R % 2;
}
catch (Exception e)
{
e.ToString();
}
bmp.SetPixel(i, j, Color.FromArgb(R, G, B));
p++;
}
}
return bmp;
}
public static Bitmap extractImg(Bitmap bmp)
{
int boolindex = 0;
Display d = new Display();
int wh;
wh = bmp.Width * bmp.Height;
int[,] img;
bool[] outarr = new bool[wh];
// pass through the rows
// pass through each row
for (int i = 0; i < bmp.Width; i++)
{
// pass through each row
for (int j = 0; j < bmp.Height; j++)
{
Color pixel = bmp.GetPixel(i, j);
int lsb = pixel.R %2;
if (lsb == 1)
outarr[boolindex] = true;
else
outarr[boolindex] = false;
boolindex++;
}
}
img = conversion.intarray(outarr);
return extrctbmp.extract(img);
}
}
}