1

I researched a lot on the internet but no use. I am very new to Android programming and java. I wrote a simple program in Android studio that lets you write a text in a cool font I set, optionally the user can chose color and font size. I want to save this text, with its font, font size, and font color; as an image viewable with any galley application. I tried lots of things spent hours on it but universe is still against me. I managed to create a bitmap image, and I can view it in an ImageView,but I can't save it to storage. Can someone please explain this very simply ? Im very new to both Android and Java.

  • All you need is draw view's (in this case your TextView) content to Bitmap, and save to storage. Try [this](https://gist.github.com/savaskoc/ea401c44d9636b39ff09) PS: saveImageToInternalStorage is taken from answer below. – Hyperion Jul 14 '15 at 00:43

1 Answers1

-1
public boolean saveImageToInternalStorage(Bitmap image) {

    try {
        // Use the compress method on the Bitmap object to write image to
        // the OutputStream
        FileOutputStream fos = context.openFileOutput("desiredFilename.png", Context.MODE_PRIVATE);

        // Writing the bitmap to the output stream
        image.compress(Bitmap.CompressFormat.PNG, 100, fos);
        fos.close();
        return true;
    } 
    catch (Exception e) {
        Log.e("saveToInternalStorage()", e.getMessage());
        return false;
    }  
}
Jack Ryan
  • 1,287
  • 12
  • 26