1

I have an custom ImageView and I want to "clip" a section of it and then pass it to another activity. I've got the "passing to another Activity" part via a Bundle..but the clipping part has me stumped. I've tried something based on this question: Android View.getDrawingCache returns null, only null

But I still end up with a null Bitmap (I am assuming I need the bitmap in order to then clip it and pass the clip to another Activity..this may be a false assumption). Here is my actual code:

view.setDrawingCacheEnabled(true);
view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight())    ; 

    view.buildDrawingCache(true);
        view.buildDrawingCache();
        Bitmap bmap = view.getDrawingCache();
        view.setDrawingCacheEnabled(false);
        Log.d("IMAGE","HEIGHT: "+bmap.getHeight());

This results in a null pointer exception at the last line. Suggestions?

Community
  • 1
  • 1
David Hamilton
  • 339
  • 3
  • 19

0 Answers0