-
Notifications
You must be signed in to change notification settings - Fork 0
/
decoder.html
325 lines (267 loc) · 9.63 KB
/
decoder.html
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ValentineCode</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!--link rel="stylesheet/less" href="less/bootstrap.less" type="text/css" /-->
<!--link rel="stylesheet/less" href="less/responsive.less" type="text/css" /-->
<!--script src="js/less-1.3.3.min.js"></script-->
<!--append ‘#!watch’ to the browser URL, then refresh the page. -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="img/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="img/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="img/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="img/favicon.png">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>
<script type="text/javascript" src="./filters.js"></script>
<script type="text/javascript"> $('#myModal').modal(options) </script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<ul class="nav navbar-nav">
<a class="navbar-brand" href="./index.html">ValentineCode</a>
<li>
<a href="./encoder.html">Encoder</a>
</li>
<li class="active">
<a href="./decoder.html">Decoder</a>
</li>
</ul>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#" class="btn-success" data-id="page-top" data-toggle="modal" data-target="#myModal"><font color="white">Inspiration</font></a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<center>
<h1>
<br>
Decode
</h1>
</center>
</div>
</div>
</div>
<div class="row clearfix">
<br>
<div class="col-md-12 column">
<center>
<canvas id="mycanvas"></canvas>
<p>
<!-- <a id="download" href="#" type="button" class="btn btn-success btn-lg" onclick="decode()">Decode</a> -->
<a id="download" href="#" type="button" class="btn btn-success btn-lg">Download PNG</a>
</p>
</center>
</div>
<div class="col-md-6 column">
<div id="SuperPosition">
<canvas id="openheart"></canvas>
<!-- <a id="download" href="#" type="button" class="btn btn-success btn-lg" onclick="downloadImage()">Download PNG</a> -->
</div>
</div>
</div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Inspiration</h4>
</div>
<div class="modal-body">
<center>
<a href="http://mathminton.blogspot.com/2011/01/steganography.html"><h4>http://mathminton.blogspot.com/2011/01/steganography.html</h4></a> <br>
<img src="mathLove1.png" width="500px" height="271px"></img>
<br><br>
<img src="mathLove2.png" width="500px" height="271px"></img>
</center>
</div>
<div class="modal-footer">
<a href="#" type="button" class="btn btn-danger" data-dismiss="modal">Close</a>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="http://counter1.allfreecounter.com/private/countertab.js?c=57243b5edfb2a9a3337e39edc3adf5c6"></script>
</body>
<script>
var self = this;
var image = document.createElement("img");
var canvas = document.getElementById("mycanvas"),
ct = canvas.getContext("2d");
image.src = './normal.png';
function clearObjCanvas () {
ct.clearRect(0, 0, canvas.width, canvas.height);
}
function drawImageCanvas() {
clearObjCanvas();
ct.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
console.log('gg');
}
function render () {
}
</script>
<script>
var textData = [];
function valueUpdate (id) {
textData = [];
renderCanvas();
}
function renderCanvas () {
drawImageCanvas();
// drawText();
}
</script>
<script>
(function () {
var canvas = document.getElementById("mycanvas"),
context = canvas.getContext("2d"),
img = document.createElement("img"),
mouseDown = false,
brushColor = "rgb(0, 0, 0)",
hasText = true,
clearCanvas = function () {
if (hasText) {
context.clearRect(0, 0, canvas.width, canvas.height);
hasText = false;
}
};
// Adding instructions
context.fillText("Drop an image onto the canvas", 240, 200);
context.fillText("Click a spot to set as brush color", 240, 220);
// Image for loading
img.addEventListener("load", function () {
clearCanvas();
if (img.width > 480 || img.height > 480) {
if (img.width / 480.0 >= img.height / 480.0) {
canvas.width = 480;
canvas.height = 480.0 * img.height / img.width;
}
else {
canvas.height = 480;
canvas.width = 480.0 * img.width / img.height;
}
}
else {
canvas.width = img.width;
canvas.height = img.height;
}
console.log('Image for loading');
self.image = img;
// drawImageCanvas();
renderCanvas();
// context.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
}, false);
// Draw, if mouse button is pressed
canvas.addEventListener("mousemove", function (evt) {
if (mouseDown) {
context.strokeStyle = brushColor;
context.lineWidth = 20;
context.lineJoin = "round";
context.lineTo(evt.layerX+1, evt.layerY+1);
context.stroke();
console.log('Draw, if mouse button is pressed');
}
}, false);
// To enable drag and drop
canvas.addEventListener("dragover", function (evt) {
evt.preventDefault();
}, false);
// Handle dropped image file - only Firefox and Google Chrome
canvas.addEventListener("drop", function (evt) {
var files = evt.dataTransfer.files;
if (files.length > 0) {
var file = files[0];
if (typeof FileReader !== "undefined" && file.type.indexOf("image") != -1) {
var reader = new FileReader();
// Note: addEventListener doesn't work in Google Chrome for this event
reader.onload = function (evt) {
img.src = evt.target.result;
};
reader.readAsDataURL(file);
}
}
evt.preventDefault();
}, false);
})();
</script>
<script>
var canvas = document.getElementById('mycanvas'),
ctx = canvas.getContext('2d');
canvas.height = 500;
canvas.width = 397;
function doCanvas() {
/* draw something */
//ctx.fillStyle = '#f90';
ctx.fillRect(0, 0, canvas.width, canvas.height);
eiei = document.createElement('img');
eiei.src = './robot_ku.png';
setTimeout(function() {
ctx.drawImage(eiei, 0, 0, canvas.width, canvas.height);
},1000);
}
function downloadCanvas(link, canvasId, filename) {
// link.href = document.getElementById(canvasId).toDataURL();
// link.download = filename;
var textCanvas = document.createElement('canvas'); // use textCanvas // don't forgot rgb scale
textCanvas.width = image.width;
textCanvas.height = image.height;
var textContext = textCanvas.getContext("2d");
textContext.rect(0, 0, textCanvas.width, textCanvas.height);
textContext.fillStyle = "#444444";
textContext.fill();
//TEST Code
var dummyCanvas = document.createElement('canvas');
dummyCanvas.width = image.width;
dummyCanvas.height = image.height;
var dummyContext = dummyCanvas.getContext('2d');
dummyContext.drawImage(image, 0, 0, image.width, image.height, 0, 0, image.width, image.height);
var pixelsCode = textContext.getImageData(0,0,textCanvas.width,textCanvas.height);
var pixelsImg = dummyContext.getImageData(0,0,dummyCanvas.width,dummyCanvas.height);
var d = pixelsImg.data;
var e = pixelsCode.data;
for (var i=0; i<d.length; i+=4) {
var v = pixelsImg.data[i]%4 + pixelsImg.data[i+1]%8*4 + pixelsImg.data[i+2]%8*32;
pixelsImg.data[i] = pixelsImg.data[i+1] = pixelsImg.data[i+2] = v;
}
var downloadResultCanvas = document.createElement('canvas');
downloadResultCanvas.width = image.width;
downloadResultCanvas.height = image.height;
var downloadResultContext = downloadResultCanvas.getContext('2d');
downloadResultContext.putImageData(pixelsImg,0,0);
link.href = downloadResultCanvas.toDataURL();
link.download = filename;
}
document.getElementById('download').addEventListener('click', function() {
var textCanvas = document.createElement('canvas');
downloadCanvas(this, 'mycanvas', 'test.png');
}, false);
doCanvas();
</script>
</html>