Code example for Bitmap

Methods: compress, insertImage

0
		String FtoSave = tempDir + System.currentTimeMillis() + "." + format;
		File file = new File(FtoSave);
		try { 
			FileOutputStream mFileOutStream = new FileOutputStream(file);
			// mBitmap = Bitmap.createScaledBitmap(mBitmap, 100, 100, true); 
			mBitmap.compress(format, 90, mFileOutStream);
			mFileOutStream.flush();
			mFileOutStream.close();
			String url = Images.Media.insertImage(getContentResolver(),
					mBitmap, "title", null);
			Log.v("log_tag", "url" + url);
		} catch (Exception e) {
			Log.v("log_tag", e.toString());
		} 
	} 
 
	public void clear(View v) {
		view.clear();
	} 
 
	public void cancel(View v) {
		finish();
	} 
 
	public void save(View v) {
		Log.v("log_tag", "Width: " + v.getWidth());
		Log.v("log_tag", "Height: " + v.getHeight());
		if (mBitmap == null) {
			mBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),
					Bitmap.Config.ARGB_8888);
		} 
		try { 
			ByteArrayOutputStream bao = new ByteArrayOutputStream();
			Canvas canvas = new Canvas(mBitmap);
			view.draw(canvas);
			mBitmap.compress(format, 100, bao);
			String ba1 = Base64.encodeToString(bao.toByteArray(),
					Base64.DEFAULT);
//			LogUtils.debug("Signature is : " + ba1); 
			Intent resultIntent = new Intent();
			resultIntent.putExtra(SIGNATURE, ba1);