Fad*_*amy 1 java eclipse android android-camera
我想制作一个应用程序,当我按下某个按钮时我想打开凸轮然后捕获图像并在我捕获它之后.
我想在一个新的活动中打开这个图像,将这个图像放在这个新的活动中,除了两个按钮一个删除它,另一个按钮将它保存在平板电脑的某个目录中.
我用代码打开凸轮:
Open_CAM.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
Run Code Online (Sandbox Code Playgroud)
我不知道在那之后我该怎么办?
请帮忙...
Open_CAM.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent photoPickerIntent= new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempFile());
photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
photoPickerIntent.putExtra("return-data", true);
startActivityForResult(photoPickerIntent,TAKE_PICTURE);}}
private Uri getTempFile()
{
File root = new File(Environment.getExternalStorageDirectory(), "ServiceMySigns");
if (!root.exists())
{
root.mkdirs();
}
final Calendar c = Calendar.getInstance();
int y = c.get(Calendar.YEAR);
int m = c.get(Calendar.MONTH);
int d = c.get(Calendar.DAY_OF_MONTH);
int h = c.get(Calendar.HOUR_OF_DAY);
int mi = c.get(Calendar.MINUTE);
//String filename=""+y+"-"+"-"+(m+1)+"-"+d+" "+h+":"+mi;
String filename=""+System.currentTimeMillis();
File file = new File(root,filename+".jpeg" );
muri = Uri.fromFile(file);
selectedImagePath=muri.getPath();
Log.v("take picture path",selectedImagePath);
return muri;
}
public void onActivityResult(int requestcode,int resultcode ,Intent data)
{
switch(requestcode)
{
case TAKE_PICTURE:
if(resultcode==RESULT_OK)
{
BitmapFactory.Options o = new BitmapFactory.Options();
o.inSampleSize=8;
Bitmap newImage = Bitmap.createScaledBitmap(BitmapFactory.decodeFile(selectedImagePath,o),
150,
150,
false);}}}
Run Code Online (Sandbox Code Playgroud)
在onActivityResult中获得位图后,您可以通过intent将该位图发送到另一个活动.
| 归档时间: |
|
| 查看次数: |
2571 次 |
| 最近记录: |