我正在使用此功能:
var size = CGSize(width: 320, height: 358) // 348
UIGraphicsBeginImageContext(size)
//let areaSize = CGRect(x: 0, y: 0, width: size.width, height: size.height)
let areaSize = CGRect(x: 20, y: 5, width: size.width-40, height: size.height-30)
let areaSizeTop = CGRect(x: 0, y: 0, width: size.width, height: size.height)
bottomImage.drawInRect(areaSize)
topImage.drawInRect(areaSizeTop, blendMode: kCGBlendModeNormal, alpha: 1) //0.8 default
var newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage
合并两个不同的图像(A)+(B),但是当我这样做时,最终图像(C)的结果质量非常低,我该如何解决?有一些代码可以使(C)图像看起来更好吗?这是(C,合并)图像的屏幕: https://developers.google.com/drive/web/quickstart/quickstart-js
答案 0 :(得分:4)
您应该使用<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script>
var locations = [];
var map;
getLocations();
function getLocations(){
$.post("./../all_donors.php",
{
},
function (data, status) {
var obj = jQuery.parseJSON(data);
for($j=0; $j<obj.length; $j++){
marker.push(new google.maps.Marker({
position: new google.maps.LatLng(obj[j]['latitude'], obj[i]['longitude']),
map: map
}));
}
});
}
function initialize() {
var myLatlng = new google.maps.LatLng(9.6667,80.0000);
var mapOptions = {
zoom: 10,
center: myLatlng
}
map = new google.maps.Map(document.getElementById('page-wrapper'), mapOptions);
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
// process multiple info windows
(function(marker, i) {
// add click event
google.maps.event.addListener(marker, 'click', function() {
infowindow = new google.maps.InfoWindow({
content: 'Doner Name: ' + locations[i][0] + '<br/>Blood Group: ' + locations[i][3]
});
infowindow.open(map, marker);
});
})(marker, i);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
,并以0为标度。使用0的比例使其与当前设备屏幕的比例相匹配。 (Retina用于视网膜设备)
通过调用UIGraphicsBeginImageContextWithOptions
,您强制输出图像为非视网膜。在视网膜设备(除iPad 2之外的所有当前设备)上,您将失去一半的分辨率。这可能是你问题的原因。
@ Daij-Djan在评论中指出,你正在创造一个非常小的图像。修复开始图像上下文调用后,如果输出图像较大,则可能需要设置较大的图像上下文。