Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67469

Could not display the full image draw canvas using HTML and JavaScript

$
0
0

I can not able to draw the full image using canvas. Here is my code:

<div class="form-group">
 <label for="exampleInputEmail1">Coupon Title</label>
<input type="text" name="emails" id="copTitle" class="form-control" placeholder="Add Coupon Title" value="<?php echo $email; ?>" required>
</div>
 <div class="couponimg" style="display:none;" id="blankImagediv">
<img class="img-responsive thumbnail" style="margin-bottom:9px; display:none;" src="http://oditek.inimages/coupon-banner-blank.jpg" crossorigin="anonymous" id="requiredImage">
<canvas id="canvas" class="img-responsive thumbnail" style="margin-bottom:9px;"></canvas>
</div>
var canvas = document.getElementById('canvas'),
    ctx = canvas.getContext('2d');
    canvas.width = $('#requiredImage').width();
    canvas.crossOrigin = "Anonymous";
    canvas.height = $('#requiredImage').height();
    ctx.drawImage($('#requiredImage').get(0), 0, 0);
    ctx.font = ":26pt Calibri";
    $(document).on('input','#copTitle',function(){
        $('#blankImagediv').css('display','block');
        ctx.clearRect(0,0,canvas.width,canvas.height);
        ctx.drawImage($('#requiredImage').get(0), 0, 0);
        ctx.fillStyle = "#0D5F90";
        ctx.fillText($(this).val(),40,80);
    })

Here I am getting the half of the image of original image while drawing. The right hand side of the image is not displaying.


Viewing all articles
Browse latest Browse all 67469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>