1

I have relativelayout (A template) where it contain textboxes whose content is populated at runtime.On clicking save button,I need to save the template as an image in SD card.Is it possible.

I referred the below link: How do I convert a RelativeLayout with an Imageview and TextView to a PNG image? But the image saved cannot be opened.

Is my requiremnet possible.Or else please advice how can I achieve it.

I am behind this for several days.I am new to ANdroid.Please help.

Thanks in Advance.

Community
  • 1
  • 1
Archana
  • 59
  • 8
  • Its ok if you just take a screenshot? http://stackoverflow.com/questions/20136121/android-how-to-take-screenshot-programatically – Nanoc Nov 10 '15 at 11:27
  • Could you please specify your issue. You see the saved image in file manager but can't open it? or you are trying to get access to it programmatically? – DmitryArc Nov 10 '15 at 12:13
  • @DmitryArc Actually I need to push the image to server.(Template image with text).Before that I just try to save it in save card.The bitmap gets saved.But while opening it from its path,no content is shown.Thanks – Archana Nov 10 '15 at 12:35

1 Answers1

0

You can pass any view or layout to devBitmapFrmViewFnc function and get the bitmap. You can save the bitmap in jpeg using devImjFylFnc.

|==| Dev Bitmap Image from View :

Bitmap devBitmapFrmViewFnc(View viewVar)
{
    viewVar.setDrawingCacheEnabled(true);
    viewVar.buildDrawingCache();
    return viewVar.getDrawingCache();
}

|==| Create a JPG File from Bitmap :

static void devImjFylFnc(String MobUrlVar, Bitmap BitmapVar)
{
    try
    {
        FileOutputStream FylVar = new FileOutputStream(MobUrlVar);
        BitmapVar.compress(Bitmap.CompressFormat.JPEG, 100, FylVar);
        FylVar.close();
    }
    catch (Exception ErrVar) { ErrVar.printStackTrace(); }
}
Sujay U N
  • 4,974
  • 11
  • 52
  • 88