Hello
my name is
Tomomi
@girlie_macLuc Viatour | www.Lucnix.be • & • caitbiology.wikispaces.com
AP PHOTO / Kevin Lamarque
http://www.flickr.com/photos/mi-ki/2454554920/
http://www.flickr.com/photos/potyike/4599545293/
http://www.flickr.com/photos/insane_capture/8113802393/
http://www.flickr.com/photos/hezicohen/4648981682/
http://www.flickr.com/photos/u-suke/100870738/
iphonelife.com
http://lemarquis.deviantart.com/art/HTML5-Wallpaper-243682854
To accelerate the adoption of the Mobile Web as a compelling platform for the development of modern mobile Web applications
http://coremob.github.com/coremob-2012/
http://coremob.github.com/coremob-2012/
Watch the Video: http://sdrv.ms/UF55gM
Taking a photo with using a native camera
<input type="file" accept="image/*"
capture="camera">
// New spec
<input type="file" accept="image/*" capture>
Returning the photo as a file
object
var input = document.querySelector('input[type=file]');
camera.addEventListener('change', function() {
var localFile = input.files[0];
var reader = new FileReader();
reader.readAsDataURL(localFile);
reader.onload = function(e){
preview.src = e.target.result;
}
}, false);
Applying filters to the photo
var c = document.createElement('canvas');
var ctx = this.c.getContext('2d');
ctx.drawImage(imgObj, 0, 0);
var imgData = ctx.getImageData(x, y, w, h);
//...Pixel manipulation ...
ctx.putImageData(imgData, 0, 0);
// Grayscale using CIE 1931 luminance
var d = imgData.data;
for (var i = 0; i < d.length; i += 4) {
var r = d[i];
var g = d[i + 1];
var b = d[i + 2];
var avg = 0.2126*r + 0.7152*g + 0.0722*b;
d[i] = d[i + 1] = d[i + 2] = avg;
}
Converting the filtered photo (canvas) to blob
if (canvas.toBlob) {
var blob = canvas.toBlob(function(blob){
// async callback
}, 'image/jpeg');
}
Displaying Blob
<img src="blob:958c1b50-09a0-2543-8528-8697ae387667">
var URL = window.URL || window.webkitURL*;
var imgURL = URL.createObjectURL(blob);
Storing the photos locally
if(window.indexedDB) {
var req = indexedDB.open('coremobCamera');
req.onsuccess = function(e) {
// async
}
}
Chrome 18 and BlackBerry requires the webkit prefix.
var indexedDB = window.indexedDB || window.webkitIndexedDB;
"Basic" Async iDB Support
setVersion()
vs. onupgradeneeded
IDBTransaction.READ_WRITE
vs. "readwrite"
blob
Sending a photo
var formData = new FormData();
formData.append('photo', blob);
Sending a photo
var xhr = new XMLHttpRequest();
xhr.open('POST', '/gallery');
xhr.upload.addEventListener('progress', handleProgress, false);
xhr.addEventListener('load', handleFinish, false);
xhr.addEventListener('error', handleError, false);
xhr.addEventListener('abort', handleAbort, false);
xhr.send(formData);
Sending a photo
function handleProgress(e) {
if (e.lengthComputable) {
el.textContent =
(e.loaded / e.total * 100) >>> 0 + '%';
}
}
Access-Control-Allow-Origin: http://some-domain.org
//Apache .htaccess
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
Photo Gallery Carousel
el.addEventListener('touchstart',
startHandler, false);
el.addEventListener('touchmove'...);
el.addEventListener('touchend'...);
You probably want to include mouse events too (mousedown
, mousemove
, and mouseup
).
For any input devices: touch, mouse, pen...
if (navigator.pointerEnabled) {
el.addEventListener('pointerdown',
startHandler, false);
el.addEventListener('pointermove', ...);
el.addEventListener('pointerup', ...);
}
Only IE10 supports so far...
if (navigator.msPointerEnabled) {
el.addEventListener('MSPointerDown', startHandler, false);
el.addEventListener('MSPointerMove', moveHandler, false);
el.addEventListener('MSPointerUp', endHandler, false);
}
** Experimental Chromium build (26.0.1409.0) - no vendor prefix
popstate
event)orientationchange
event)@font-face
)hidden
attributedata-*
custom attributeHTML5 + Native
Filling the gap of missing HTML5 features
github.com/coremob/camera
coremob.github.io/camera/vanilla/index.html
goo.gl/My8mf
Tomomi Imura