I retrieve a user from the database who has profile picture. This picture is base64 and drawImage to the canvas. but it failed to draw.
Here's my code:
var userId = {'userId' : 1};
$scope.user = UserProfileService.getUserProfile.query(userId, function() {
var canvas = document.getElementById("mycanvasweb");
var ctx = canvas.getContext("2d");
var image = new Image();
image.onload = function() {
ctx.drawImage(this, 0, 0);
};
image.src = $scope.user.profilePic;
});
Please help.