Code example for Bitmap

Methods: createScaledBitmapgetHeightgetWidth

0
	static ByteArrayOutputStream processPicture(Bitmap image) {
		// Compress JPEG PICTURE_COMPRESSION_QUALITY % quality and PICTURE_MIN_SIZE min size		 
		try { 
			ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 
			Pair<Integer, Integer> desiredSize = resolveDesiredSize(image.getWidth(), image.getHeight());
			Bitmap resized = Bitmap.createScaledBitmap(image, desiredSize.first, desiredSize.second, false);
			resized.compress(CompressFormat.JPEG, Config.PICTURE_COMPRESSION_QUALITY, outputStream);
			outputStream.close();
 
			return outputStream;
		} catch (IOException e) {
			e.printStackTrace();
		} 
		 
		return null; 
	} 
	 
	/** 
	 * Resolves the sample size nearest to the desired minimal size.