Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created March 2, 2017 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinyoo/db7b9e5bd7b1405fc5ef7f42330213bd to your computer and use it in GitHub Desktop.
Save justinyoo/db7b9e5bd7b1405fc5ef7f42330213bd to your computer and use it in GitHub Desktop.
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