Code example for Bitmap

Methods: createScaledBitmapgetHeightgetWidth

0
			return; 
		} 
 
		Display display = activiy.getWindowManager().getDefaultDisplay();
		int width = display.getWidth();
		double k = (double) width / bmp.getWidth();
 
		Bitmap scaled = Bitmap.createScaledBitmap(bmp, width, (int) (bmp.getHeight() * k), false);
		BitmapDrawable bitmapDrawable = new BitmapDrawable(scaled);
		bitmapDrawable.setGravity(Gravity.TOP);
		bitmapDrawable.setAlpha(80);
		bitmapDrawable.setTileModeY(Shader.TileMode.MIRROR);
 
		myHandler.setBitmapDrawable(bitmapDrawable);
		myHandler.sendEmptyMessage(0);
 
	} 
 
	class MyHandler extends Handler {
 
		private BitmapDrawable bitmapDrawable;
 
		public void handleMessage(Message msg) {
			if (bgView != null) {
				bgView.setBackgroundDrawable(getBitmapDrawable());
			} 
		} 
 
		public void setBitmapDrawable(BitmapDrawable bitmapDrawable) {
			this.bitmapDrawable = bitmapDrawable;
		} 
 
		public BitmapDrawable getBitmapDrawable() {
			return bitmapDrawable;
		}; 
 
	}; 
 
	class Task extends AsyncTask<Void, Void, Void> {
 
		private final String url;
 
		public Task(String url) {
			this.url = url;
 
		} 
 
		@Override 
		protected Void doInBackground(Void... params) {
			Bitmap bmp = ImageUtil.fetchImage(url);
			drawBackgound(bmp);
			((FoobnixApplication) activiy.getApplication()).getCache().setDiscCover(bmp);
			return null; 
		} 
	}; 
 
}