kamera

Download Kamera

If you can't read please download the document

Upload: steven-wang

Post on 24-Sep-2015

214 views

Category:

Documents


1 download

DESCRIPTION

Kamera

TRANSCRIPT

Android Image+. Intent buat cameraIntent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);+. capture gambar dalam BitmapBundle extra = intent.getExtra();Bitmap bmp = (Bitmap) extra.get("data");iv.setImageBitmap(bmp);+. Capture gambar besarmenggunakan EXTRA_OUTPUT pada MediaStore//note: gambar harus disimpan dalam microSDString imageFilePath = Environment.getExternalStorageDirectory().getAbsolutePath()+ "/myfavoritepicture.jpg";File imageFile = new File(imageFilePath);Uri imageFileUri = Uri.fromFile(imageFile);Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);startActivityForResult(i, CAMERA_RESULT);+. Menampilkan Gambar yang besarMenggunakan class BitmapFactorymembuat sample image untuk dipreview, contohnya sample image 1/8 dari image asliBitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();bmpFactoryOptions.inSampleSize = 8;Bitmap bmp = BitmapFactory.decodeFile(imageFilePath, bmpFactoryOptions);imv.setImageBitmap(bmp);mendapatkan ukuran layarDisplay currentDisplay = getWindowManager().getDefaultDisplay();int dw = currentDisplay.getWidth();int dh = currentDisplay.getHeight();mendapatkan ukuran image// Load up the image's dimensions not the image itselfBitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();bmpFactoryOptions.inJustDecodeBounds = true;Bitmap bmp = BitmapFactory.decodeFile(imageFilePath, bmpFactoryOptions);int heightRatio = (int)Math.ceil(bmpFactoryOptions.outHeight/(float)dh);int widthRatio = (int)Math.ceil(bmpFactoryOptions.outWidth/(float)dw);Log.v("HEIGHTRATIO",""+heightRatio);Log.v("WIDTHRATIO",""+widthRatio);share image ke aplikasi lain dengan menggunakan content provider===========================================ADVANCED CAMERA===========================================Untuk menggunakan kamera harus menggunakan permission Untuk menampilkan image pada class Camera menggunakan SurfaceViewSurfaceView cameraView = (CameraView) this.findViewById(R.id.CameraView);SurfaceHolder surfaceHolder = cameraView.getHolder();surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);Kita membuat inteface implements SurfaceHolder.Callback agar bisa memasukkan fungsi saat event Surface terjadiubah display ke landscapesetRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);mengambil parameter orientasi pada kameraCamera.Parameters parameters = camera.getParameters();parameters.set("some parameter", "some value");// orparameters.set("some parameter", some_int);camera.setParameters(parameters);