我有一个Activity
,其中定义了一个自定义的ImageView
,用于对图像进行捏合缩放功能。现在,我的问题是我想从捏合缩放功能中获取缩放后的Bitmap
。例如,如果用户在图像上执行缩放操作,则我想将图像的确切大小和位置作为Bitmap
存储。
这是我在XML中声明的自定义ImageView。
<com.cam.view.PinchZoom_ImageView
android:id="@+id/gallery_selected_image_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/icon"
android:scaleType="center"
/>
更新:
我尝试使用下面的代码来获取缩放后的图像,但它返回了一个空白的位图。
pinchZoom.setDrawingCacheEnabled(true);
pinchZoom.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
pinchZoom.layout(0, 0, pinchZoom.getMeasuredWidth(), pinchZoom.getMeasuredHeight());
pinchZoom.buildDrawingCache(true);
Bitmap_gallery_Item = Bitmap.createBitmap(pinchZoom.getDrawingCache());
pinchZoom.setDrawingCacheEnabled(false);
希望能得到任何帮助。谢谢。