我正在尝试缩小通过相机拍摄的图像并将其放置在我的应用程序的 mapview 中。但是我可以拍摄图像,但似乎无法将其缩小为缩略图大小的图像。这是我的 MainActivity.java 代码
AlertDialog alert = new AlertDialog.Builder(MainActivity.this).create();
alert.setTitle("Create Marker");
alert.setButton(DialogInterface.BUTTON_POSITIVE, "Take Photo", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//TODO Auto=generated method stub
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photo));
o = Uri.fromFile(photo);
startActivityForResult(intent, TAKE_PICTURE);
BitmapDrawable bd = (BitmapDrawable) Drawable.createFromPath(new File(Environment.getExternalStorageDirectory(), "pic.jpg").getAbsolutePath());
Bitmap b = Bitmap.createScaledBitmap(bd.getBitmap(), (int) (bd.getIntrinsicHeight() * 0.8),
(int) (bd.getIntrinsicWidth() * 0.8), false);
OverlayItem overlayItem = new OverlayItem(touchedPoint, "What's Up", "2nd String");
CustomPinPoint custom = new CustomPinPoint(d, MainActivity.this);
custom.insertPinpoint(overlayItem);
overlayList.add(custom);
}
});
alert.show();
{
return true;
}
}
return false;
和我的 CustomPinPoint.java
public class CustomPinPoint extends ItemizedOverlay<OverlayItem>{
BitmapDrawable bd;
Bitmap b;
private ArrayList<OverlayItem> pinpoints = new ArrayList<OverlayItem>();
private Context c;
public CustomPinPoint(Drawable defaultMarker) {
super(boundCenter(defaultMarker));
BitmapDrawable bd = (BitmapDrawable) Drawable.createFromPath(new File(Environment.getExternalStorageDirectory(), "pic.jpg").getAbsolutePath());
Bitmap b = Bitmap.createScaledBitmap(bd.getBitmap(), (int) (bd.getIntrinsicHeight() * 0.8),
(int) (bd.getIntrinsicWidth() * 0.8), false);
// TODO Auto-generated constructor stub
}
public CustomPinPoint(Drawable m, Context context) {
this(m);
c = context;
// TODO Auto-generated constructor stub
}
@Override
protected OverlayItem createItem(int i) {
// TODO Auto-generated method stub
return pinpoints.get(i);
}
@Override
public int size() {
// TODO Auto-generated method stub
return pinpoints.size();
}
public void insertPinpoint(OverlayItem item){
pinpoints.add(item);
this.populate();
}
public void add(CustomPinPoint custom) {
// TODO Auto-generated method stub
}
public void add(OverlayItem i) {
// TODO Auto-generated method stub
}
}
谁能告诉我我做错了什么?