Click here to Skip to main content
15,882,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have image view inside frame layout ,i put random sticker on image view at run time but when i save image bitmap using frame layout drawing-catch then image save but with unnecessary black part comes in saved image.
http://i.stack.imgur.com/vWwfl.jpg[^]
http://i.stack.imgur.com/OIhdp.jpg[^]
http://i.stack.imgur.com/zJVK2.jpg[^]

i want bitmap without this black part.Please help.Here is my layout and code.

<FrameLayout
    android:id="@+id/fl_effect_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/rl_title"
    android:layout_marginBottom="83dp" >

    <ImageView
        android:id="@+id/im_gselected_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
         >
    </ImageView>
</FrameLayout>

Here is code that i use to create bitmap.

Java
FrameLayout fl=(FrameLayout) findViewById(R.id.fl_effect_view);
f1.setDrawingCacheEnabled(true);
Bitmap b=Bitmap.createBitmap(f1.getDrawingCache());
f1.setDrawingCacheEnabled(false);
Posted

1 solution

use ImageView, not FrameLayout
Java
ImageView fl=(ImageView) findViewById(R.id.im_gselected_image);
f1.setDrawingCacheEnabled(true);
Bitmap b=Bitmap.createBitmap(f1.getDrawingCache());
f1.setDrawingCacheEnabled(false);
 
Share this answer
 
Comments
pranav11 18-Dec-13 6:58am    
In that case only image comes..means without spec on it.Because spec is Added in Frame layout at run time.
Xiao Ling 18-Dec-13 20:48pm    
If so, I think the best way is to crop the bitmap that you got from FrameLayout.createBitmap(Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter)
Returns an immutable bitmap from subset of the source bitmap, transformed by the optional matrix.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900