forked from jollen/html5-game-bubble-r2
-
Notifications
You must be signed in to change notification settings - Fork 3
/
camera.html
70 lines (61 loc) · 2.15 KB
/
camera.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="main.css" />
<script src="cordova.js" type="text/javascript"></script>
<script src="modernizr.js" type="text/javascript"></script>
<script src="loader.camera.js" type="text/javascript"></script>
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Bubble</a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="index.html">Game Console</a></li>
<li><a href="chat.html">Chatroom</a></li>
<li><a href="camera.html">Camera</a></li>
</ul>
</div>
</nav>
<div id="camera">
<button class="btn btn-default" type="button" onclick="capturePhoto();">Take Picture</button>
<div><img style="display:block;" id="largeImage" src="" /></div>
</div>
</body>
<script type="text/javascript" charset="utf-8">
var pictureSource;
var destinationType;
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady() {
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
}
function onPhotoDataSuccess(imageData) {
$("#largeImage").attr('src', "data:image/jpeg;base64," + imageData);
}
function onFail(message) {
}
function capturePhoto() {
navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
quality: 60,
encodingType: Camera.EncodingType.JPEG,
destinationType: 0, //base64
targetWidth: 192,
targetHeight: 192,
}
);
}
</script>
</html>