Note that there are some explanatory texts on larger screens.

plurals
  1. POSaving created Bitmap Image to internal storage
    primarykey
    data
    text
    <p>I have a basic application that uses just squares and circles that appear when the screen is touched. I want to be able to save this created image, the design is build on a bitmap image, and displayed on the canvas so I want to be able to save that as an image to the mobile device. </p> <pre class="lang-js prettyprint-override"><code>public MyDraw(Context context) { super(context); g = new Random(); Bitmap.Config conf = Bitmap.Config.ARGB_8888; bmp = Bitmap.createBitmap(1100, 1800, conf); } </code></pre> <p><strong>Drawing code</strong>:</p> <pre class="lang-js prettyprint-override"><code>protected void onDraw(Canvas c) { c.drawBitmap(bmp, 0, 0, paint); super.onDraw(c); } </code></pre> <p><strong>Menu Code</strong>:</p> <pre class="lang-js prettyprint-override"><code>public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuItem menu1 = menu.add(0, 0, Menu.NONE, "Filled Shape"); MenuItem menu2 = menu.add(0, 1, Menu.NONE, "Outline Shape"); MenuItem menu3 = menu.add(0, 2, Menu.NONE, "Rectangle"); MenuItem menu4 = menu.add(0, 3, Menu.NONE, "Oval"); MenuItem menu5 = menu.add(0, 4, Menu.NONE, "Save!"); return true; } public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0: MyApp.fill = 0; return true; case 1: MyApp.fill = 1; return true; case 2: MyApp.shape = 0; return true; case 3: MyApp.shape = 1; return true; case 4: // MyDraw.bmp; default: return super.onOptionsItemSelected(item); } } </code></pre> <p>I want to be able to click the save button on the menu and for the bitmap that has been created to save into the phones internal storage (preferably the gallery).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload