Hello i'm trying to take a screen shot of an Imageview that i have some drawing on it. I'm able to do the drawing part and saving part because I using my method below. However it gives me two black bars on the side of my screenshot. I am not sure how to get rid of those when capturing the screen shot.
//In constructor to let u guys know how i set up the imageView
imageView.setImageBitmap(bitmap);
...
imageView = (ImageView) this.findViewById(R.id.ImageView);
...
Method to capture screen shot of the imageView once button is pressed
case R.id.BtnSave:
imageView.setDrawingCacheEnabled(true);
Bitmap bm = Bitmap.createBitmap(imageView.getDrawingCache());
Toast.makeText(Draw.this, "Taking Screenshot", Toast.LENGTH_SHORT).show();
MediaStore.Images.Media.insertImage(getContentResolver(), bm, null, null);
break;
XML here:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Draw" >
<ImageView
android:id="@+id/ImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/btnLoad2"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_launcher" />
<Button
android:id="@+id/BtnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/ImageView"
android:layout_alignTop="@+id/btnLoad2"
android:text="Save Picture" />
<Button
android:id="@+id/btnLoad2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/ImageView"
android:layout_alignParentBottom="true"
android:layout_marginBottom="40dp"
android:layout_toLeftOf="@+id/BtnSave"
android:text="@string/Load" />
</RelativeLayout>
This is screenshot of eclipse that was displayed on the emulator then drawned with one line at the top then saved and loaded back to the imageView. First screenshot is before and the second one is after i loaded the screen capture from gallery, there are two black bars on the side. I tired taking away padding, but it doesn't help. I tired searching for people who had similar problems, but did not find much. Is it possible to use
imageView.getWidth(), imageView.getHeight()
in my bmp creation on the same line with getdrawingcache?