用pixastic混合两个图像不起作用。如何获得新图像?

时间:2013-05-20 15:52:09

标签: image drag-and-drop blend pixastic

嘿,我正在尝试将两个图像与pixastic混合。一个图像可以拖放到另一个图像上(使用jqueryUI),在它到达正确位置后,两个图像将成为一个。

所以我想使用pixastic混合效果。

到目前为止我试过这个:

function BlendTheImages() {
   var img = new Image();
   img.onload = function() {
var blendImg = new Image();
 blendImg.onload = function() {
  Pixastic.process(img, "blend", 
        {
            amount : 1, 
            mode : "multiply", 
            image : blendImg
        }
    );
}
blendImg.src = "Small_Image.png";
     }
img.src = "Background_Big_Image.jpg";
    }    

当较小的图像具有混合两个图像的正确位置时,应该调用BlendTheImages函数。

我不知道它是否有效或如何获得新的混合图像..

请帮帮我!感谢

1 个答案:

答案 0 :(得分:1)

我考虑使用html2canvas来抓取图像,但是当我发现它时,我真的很惊讶,即使它没有在Pixastic的网站上记录,Blend效果也有一个回调函数(就像其他效果一样):

var img = new Image();
img.onload = function() {
    Pixastic.process(img, "blend", 
        {
            amount : 1.0, 
            mode : "Multiply", 
            image : someOtherImage
        }, function(blendedImg) {
            console.log(blendedImg);
            applySepia(blendedImg);
        }
    );
}
document.body.appendChild(img);
img.src = "myimage.jpg";

Pixastic.process函数有一个回调函数,它适用于所有效果。