首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

api demos中的里面的FingerPaint所画的保存到sdcard下

2012-09-18 
api demos中的里面的FingerPaint所画的保存到sdcard上转载:http://www.eoeandroid.com/thread-12270-1-1.h

api demos中的里面的FingerPaint所画的保存到sdcard上
转载:http://www.eoeandroid.com/thread-12270-1-1.html
每个canvas对应着一个Bitmap,像素信息保存在里面,将Bitmap保存为文件
先在sd卡上创建Note目录
直接在api demos上改的,touch_up中保存,这样每次保存最新的

 private void touch_up() {            mPath.lineTo(mX, mY);            // commit the path to our offscreen            mCanvas.drawPath(mPath, mPaint);            // kill this so we don't double draw            mPath.reset();                        try {                saveMyBitmap(Integer.toString(count++));            } catch (IOException e) {                // TODO Auto-generated catch block                e.printStackTrace();            }        }public void saveMyBitmap(String bitName) throws IOException {File f = new File("/sdcard/Note/" + bitName + ".png");f.createNewFile();FileOutputStream fOut = null;try {fOut = new FileOutputStream(f);} catch (FileNotFoundException e) {e.printStackTrace();}mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);try {fOut.flush();} catch (IOException e) {e.printStackTrace();}try {fOut.close();} catch (IOException e) {e.printStackTrace();}}

热点排行