好的,基本上,我製作了這個程序,要求用戶提供一個圖片鏈接,然後詢問用戶他們想要使用的過濾器類型,並將過濾器應用到圖片圖片過濾器不起作用
function start(){
askForImage();
askForFilter();
}
function askForImage(){
var link = readLine("Please give the link to the image");
println("Fitting the image to canvas as best a possible.");
var image = new WebImage(link);
image.setPosition(0, 0);
image.setSize(getWidth(), getHeight());
add(image);
}
function askForFilter(){
var filterType = readLine("What filter would you like to use on your photo?");
if(filterType == "darken"){
setTimeout(function(){
darkenFilter(image);
}, IMAGE_LOAD_WAIT_TIME);
}else if(filterType == "brighten"){
setTimeout(function(){
brightenFilter(image);
}, IMAGE_LOAD_WAIT_TIME);
}else if(filterType == "invert"){
setTimeout(function(){
invert(image);
}, IMAGE_LOAD_WAIT_TIME);
}else if(filterType == "grayscale"){
setTimeout(function(){
blackAndWhiteFilter(image);
}, IMAGE_LOAD_WAIT_TIME);
}else if(filterType == "remove blue"){
setTimeout(function(){
removeBlue(image);
}, IMAGE_LOAD_WAIT_TIME);
}else if(filterType == "remove red"){
setTimeout(function(){
removeRed(image);
}, IMAGE_LOAD_WAIT_TIME);
}else if(filterType == "remove green"){
setTimeout(function(){
removeGreen(image);
}, IMAGE_LOAD_WAIT_TIME);
}else if(filterType == "saturate"){
setTimeout(function(){
saturate(image);
}, IMAGE_LOAD_WAIT_TIME);
}else{
println("That is not a possible filter option.");
}
}
(對不起,我縮短了儘可能多的代碼來傳達出點) 這是我似乎遇到問題的部分。我忽略了所有過濾圖像的函數,因爲我知道過濾器正常工作,我測試了它們。顯然的問題似乎是過濾器以錯誤的方式拍攝圖像。我試圖使用一個常量URL作爲圖像,並且運行良好,但是當用戶輸入URL時,過濾器不起作用。我認爲該程序可能會在之前運行過濾器加載圖片,但我不知道如何解決該問題,即使這是問題所在。我非常感謝幫助解決我的代碼,謝謝!
--- This是提到的代碼的鏈接---
正在通過PHP加載圖像可能的選項爲您的應用程序?或者將邏輯改爲_「用戶從硬盤上傳」_而不是當前_「通過鏈接上傳」_ –