사용자가 장소 선택기 활동에서 장소를 선택할 때지도의 스냅 샷을 찍고 싶습니다. 이 이미지를 SD 카드에 저장합니다. 그러나 그것은 매우 낮은 품질을 제공합니다. 나는 이유를 이해할 수 없다? 또한이 코드 줄에서 이미지 품질을 100으로 설정했습니다 : bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
. 난 단지 텍스트 "구글"을 포함하는 다음 그림에서처럼 좋은 품질의 조금 더 큰 이미지를 원하는품질이 좋지 않고 맵 활동의 스냅 샷이 너무 작습니다.
:하지만 같은
스냅 샷 보인다
대화 상자에 표시되는지도의 중간 이미지를 원합니다. 나는 this answer.
다음있어이미지를 처리하고 스냅 샷을 내 코드는 다음과 같습니다 :
//opening place picker activity.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST
&& resultCode == Activity.RESULT_OK) {
final Place place = PlacePicker.getPlace(this, data);
final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
String attributions = (String) place.getAttributions();
if (attributions == null) {
attributions = "";
}
// tv4.setText(place.getLatLng().toString()+"\n"+name+"\n"+address+"\n"+attributions); To get latitide and longitudes.
tv4.setText(address+"\n"+attributions);
LatLngBounds selectedPlaceBounds = PlacePicker.getLatLngBounds(data);
// move camera to selected bounds
CameraUpdate camera = CameraUpdateFactory.newLatLngBounds(selectedPlaceBounds,0);
mMap.moveCamera(camera);
// take snapshot and implement the snapshot ready callback
mMap.snapshot(new GoogleMap.SnapshotReadyCallback() {
Bitmap bitmap=null;
public void onSnapshotReady(Bitmap snapshot) {
// handle snapshot here
bitmap = snapshot;
try {
FileOutputStream out = new FileOutputStream("/mnt/sdcard/Download/000p.png");
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
Toast.makeText(Main2Activity.this,"dsfds",Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(Main2Activity.this,e.toString(),Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
});
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
내가 이것을 달성하기 위해 무엇을 변경해야합니까? 이 스냅 샷을 얻는 다른 방법이 있습니까?
도움 주셔서 감사합니다.
자세한 정보를 제공해 줄 수 있습니까? –
물론, 당신은 무엇을 알고 싶습니까? 현재 mMap.move (cameraUpdate)를 호출하면 맵이 움직여야하는데 시간이 오래 걸린다. 그래서'mMap.move (...)'다음에'mMap.snapshot (...)'을 호출하면 맵이 준비되지 않을 수 있습니다. 나는 이것을 테스트하지 않았지만 그것은 단지 이론 일 뿐이지 만, 당신은 내가 대답 한 것을 시도해 볼 수 있습니다. – jpvillegas