public class MapDemoActivity extends Activity {
Button capture;
ImageView image;
int cameracode=100;
Bitmap bm;
Boolean result;
FileOutputStream fos;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
capture=(Button)findViewById(R.id.capture);
capture.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
image=(ImageView)findViewById(R.id.image);
Intent i=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameracode);
image.setDrawingCacheEnabled(true);
bm = image.getDrawingCache();
try {
fos = new FileOutputStream("sdcard/image.jpg");
result=bm.compress(CompressFormat.JPEG, 75, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
if(requestCode==100)
{
bm=(Bitmap) data.getExtras().get("data");
image.setImageBitmap(bm);
}
super.onActivityResult(requestCode, resultCode, data);
}
}
JPEG圖像在這個PROG我正在拍攝的圖像從相機&顯示在圖像視圖,然後我試圖 其轉換爲JPEG在SD卡存儲... 但是,當我榨捕獲圖像按鈕PROG得到強制關閉.. &空JPEG文件的SD卡創建...我希望存儲JPEG文件到SD卡保存圖像視圖中的SD卡
無可否認,我的答案要徹底得多。這傢伙有你的答案。 –
它的工作原理......但現在通過使用相機PROG得到強制關閉捕獲圖像之後 – user1461473
請在logcat的堆棧跟蹤添加到您的問題 –