Code example for Bitmap

Methods: compressgetByteCountgetHeightgetWidth

0
	} 
	public Bitmap getImage() {
		return BitmapFactory.decodeByteArray(image, 0, image.length);
	} 
	public void setImage(Bitmap image) {
		int size = image.getByteCount();
		int width = image.getWidth();
		int height = image.getHeight();
		if(size > BLOB_SIZE_MAX){
			if(width * HEIGHT_MAX > height * WIDTH_MAX){
				float scale = (float)WIDTH_MAX/width;
				image = Bitmap.createScaledBitmap(image, WIDTH_MAX, (int)(scale*height), true);
			}else{ 
				float scale = (float)HEIGHT_MAX/height;
				image = Bitmap.createScaledBitmap(image, (int)(scale*width), HEIGHT_MAX, true);
			} 
		} 
		 
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		image.compress(CompressFormat.JPEG, 100, bos);
		this.image = bos.toByteArray();
	} 
} 
Connect your IDE to all the code out there  Get Codota for Java