读书人

api demos中的里面的FingerPaint所画的

发布时间: 2012-09-18 16:21:42 作者: rapoo

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();}}

读书人网 >操作系统

热点推荐