0
這是我的代碼,它使用相機,並且這些卡扣存儲在SD卡中,這是完美的。現在我需要將這些對齊回到我自己的框架中。我該怎麼做,建議任何人?如何在我的相機拍攝後將我的圖片顯示到我自己的相框中
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.ImageView;
public class CampicsaveActivity extends Activity {
/** Called when the activity is first created. */
ImageView iv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.camdemo);
iv=(ImageView)findViewById(R.id.imageView1);
iv.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
saveImage(0);
} });
}
public void saveImage(int IMAGE_CAPTURE)
{
try {
FileOutputStream fos = openFileOutput(
"MyFile.jpeg", Context.MODE_WORLD_WRITEABLE);
fos.close();
File f = new File(getFilesDir() + File.separator + "MyFile.jpeg");
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,90);
startActivityForResult(intent,IMAGE_CAPTURE);
startActivityForResult(new Intent(
MediaStore.ACTION_IMAGE_CAPTURE).putExtra(
MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)),IMAGE_CAPTURE);
}
catch(IOException e) {
}
}
}
這裏是我的camera.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/kk" />
</LinearLayout>