C
C
Comatu2017-10-23 22:01:51
Android
Comatu, 2017-10-23 22:01:51

Which Bitmap parameter should be specified in the method to save the image?

There is a method

public void saveImage(Context context, Bitmap b, String imageName) 
{
    FileOutputStream foStream;
    try 
    {
        foStream = context.openFileOutput(imageName, Context.MODE_PRIVATE);
        b.compress(Bitmap.CompressFormat.PNG, 100, foStream);
        foStream.close();
    } 
    catch (Exception e) 
    {
        Log.d("saveImage", "Exception 2, Something went wrong!");
        e.printStackTrace();
    }
}

Can you please tell me which Bitmap parameter should be specified when calling the method? I write:
saveImage(MainActivity.this, ?????, filename);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-10-24
@red-barbarian

For example, if from resources, then BitmapFactory.decodeResource(getResources(), r.drawable.id)
Generally (what you wrote) to save a bipmap that is in memory for long-term memory, in the file imageName

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question