我正试图用棕褐色滤镜打印出一张照片,但它只打印了两次相同的(未经编辑的)照片。如何在底部使用我的棕褐色代码?代码将图片转换为灰度,然后是棕褐色。
import images.*;
public class Sepia{
public static void main(String[]args){
APImage image = new APImage("lobster.jpg");
image.draw();
APImage aCopy = image.clone();
for (Pixel p: aCopy){
int red = p.getRed();
int green = p.getGreen();
int blue = p.getBlue();
int average = (red + green + blue) / 3;
p.setRed(average);
p.setGreen(average);
p.setBlue(average);
if (red < 63){
red = (int)(red *1.1);
blue = (int)(blue * 0.9);
}else if (red < 192){
red = (int)(red*1.15);
blue = (int)(blue *0.85);
}else{
red = Math.min((int)(red*1.08),255);
blue = (int)(blue *0.93);
}
aCopy.draw();
aCopy.save();
}
}
}
答案 0 :(得分:0)
在抽奖前尝试添加此内容。
function calcDistance(origin1,destinationB){
var geocoder = new google.maps.Geocoder();
var service = new google.maps.DistanceMatrixService();
var temp_duration = 0;
var temp_distance = 0;
var testres;
service.getDistanceMatrix(
{
origins: [origin1],
destinations: [destinationB],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, function(response, status) {
if (status !== google.maps.DistanceMatrixStatus.OK) {
alert('Error was: ' + status);
testres= {"duration":0,"distance":0};
} else {
var originList = response.originAddresses;
var destinationList = response.destinationAddresses;
var showGeocodedAddressOnMap = function (asDestination) {
testres= function (results, status) {
};
};
var duration_total;
for (var i = 0; i < originList.length; i++) {
var results = response.rows[i].elements;
geocoder.geocode({'address': originList[i]},
showGeocodedAddressOnMap(false));
for (var j = 0; j < results.length; j++) {
geocoder.geocode({'address': destinationList[j]},
showGeocodedAddressOnMap(true));
temp_duration+=results[j].duration.value;
temp_distance+=results[j].distance.value;
}
}
testres= {"duration":temp_duration,"distance":temp_distance};
}
}
);
}
result = calcDistance(source,dest);
</script>
另外,取出画面并保存出来的for循环