Hi all,
I am trying to get the origionale sizes from the picture taken by the camera but some how they are being rezised.
anyone an idea how I can acoumlpisch this with script below.
thanks in advance
Code:
Ext.define('Kitchensink.view.CapturePicture', { extend: 'Ext.Component',
xtype: 'capturepicture',
config: {
captured: false,
quality: 100,
width: 250,
height: 350,
cls: 'picture-capture',
html: [
'<div class="icon"><i class="icon-camera"></i> Foto Opdrachtbon</div>',
'<img class="image-tns" />',
'<input type="file" capture="camera" accept="image/*" />' //Step 1
].join('')
},
initialize: function() {
this.callParent(arguments);
this.file = this.element.down('input[type=file]');
this.img = this.element.down('img');
//Ext.getCmp('capturepictureb').setValue(this.img.toDataURL("image/png"));
this.file.on('change', this.setPicture, this); //Step 2
//FIX for webkit
window.URL = window.URL || window.webkitURL; //Step 3
},
setPicture: function(event) {
var files = event.target.files;
if (files.length === 1 && files[0].type.indexOf("image/") === 0) {
this.img.setStyle('display', 'block');
this.img.set({
src: URL.createObjectURL(files[0]) //Step 4
});
this.setCaptured(true);
console.log(files[0]);
var reader = new window.FileReader();
var tempfile = files[0];
reader.readAsDataURL(tempfile);
reader.onloadend = function() {
base64data = reader.result;
console.log(base64data);
}
}
},
reset: function() {
this.img.setStyle('display', 'none');
this.img.set({
src: ''
});
this.setCaptured(false);
},
getImageDataUrl: function() { //Step 6
var img = this.img.dom,
imgCanvas = document.createElement("canvas"),
imgContext = imgCanvas.getContext("2d");
//Ext.getCmp('capturepictureb').setValue(imgContext.toDataURL("image/png"));
if (this.getCaptured()) {
// Make sure canvas is as big as the picture
imgCanvas.width = img.width;
imgCanvas.height = img.height;
// Draw image into canvas element
imgContext.drawImage(img, 0, 0, img.width, img.height);
// Return the image as a data URL
return imgCanvas.toDataURL("image/png");
}
}
});
Aucun commentaire:
Enregistrer un commentaire