android canvas讀取背景圖片,塗鴉之後儲存

來源:互聯網
上載者:User

標籤:android   style   color   io   os   ar   java   for   sp   

============問題描述============


利用下面的代碼讀取到sd卡內的圖片,顯示出來
setBackgroundDrawable(new BitmapDrawable(BitmapFactory.decodeFile("/storage/sdcard/bg.jpg")));

然後進行塗鴉,塗鴉完成後進行儲存,只剩下我畫筆畫的那些塗鴉部分,背景圖沒儲存
因為是在背景圖上進行塗鴉的,如何讓塗鴉和背景圖一起儲存
儲存代碼:
myCanvas.save(Canvas.ALL_SAVE_FLAG);myCanvas.restore();File f = new File("/storage/sdcard/","bg.jpg");        if(f.exists()){        f.delete();        }FileOutputStream fos = null;try {fos = new FileOutputStream(f);myBitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos);try {fos.flush();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}try {fos.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}

============解決方案1============


可以在儲存canvas之前載入曆史背景圖片,然後再載入一下要儲存的介面,這樣就可以儲存住了

android canvas讀取背景圖片,塗鴉之後儲存

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.