简体   繁体   中英

CamanJS: Dynamically load an image onto canvas

Using CamanJS, how can I dynamically load an image onto the canvas?

All I have is the base64 encoding of a PNG.

I find the API documentation of CamanJS to be anything but complete. It doesn't even have the this.save() function documented.

You have to load required image first. After that pass the image object to camanjs function as below.

var myimage = new Image();
    myimage.onload = function() {
          $('#myImageDiv').html('<img id="my-image" src='+myimage.src+' />');
          Caman('#my-image', function () {
                 this.brightness(10);
                 this.contrast(30);
                 this.sepia(60);
                 this.saturation(-30);
                 this.render();
          });
    }
    myimage.src = 'images/myimage.jpg';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM