2013-05-20 50 views
1

嘿,我試圖混合兩個圖像pixastic。一個圖像可以拖放到其他圖像上(使用jqueryUI),並且在獲得正確位置後,兩個圖像將成爲一個圖像。用pixastic混合兩個圖像不起作用。如何獲得新的圖像?

所以我想使用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

我想過使用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函數有一個回調函數,它適用於所有效果。