Create a gist now

Instantly share code, notes, and snippets.

@justinyoo /Hello-2.ts Secret
Created Mar 2, 2017

What would you like to do?
Accessing to Camera on Mobile Devices from Vue.js + TypeScript + ASP.NET Core Applications
takePhoto (): void {
if (!this._hasUserMedia) {
return;
}
var canvas: HTMLCanvasElement = this.getCanvas();
this.photo = canvas.toDataURL(this.screenshotFormat);
}
private getCanvas (): HTMLCanvasElement {
if (!this._hasUserMedia) {
return null;
}
if (this._ctx == null) {
var canvas: HTMLCanvasElement = document.createElement("canvas");
canvas.height = this._video.clientHeight;
canvas.width = this._video.clientWidth;
this._ctx = canvas.getContext("2d");
this._ctx.drawImage(this._video, 0, 0, canvas.width, canvas.height);
return canvas;
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment