Code example for Bitmap

Methods: copyPixelsToBuffergetHeightgetRowBytes

0
	} 
 
	// converts a bmp to byte[] 
	public static byte[] bitmapToBinary(Bitmap bmp)
	{ 
		int size = bmp.getRowBytes() * bmp.getHeight();
		ByteBuffer b = ByteBuffer.allocate(size);
		bmp.copyPixelsToBuffer(b);
 
		byte [] thumbnailArray = new byte[size];
 
		try { 
		    b.get(thumbnailArray, 0, thumbnailArray.length);
		} 
		catch (BufferUnderflowException e)
		{ 
		    //always happens 
		} 
 
		return thumbnailArray;
Connect your IDE to all the code out there  Get Codota for Java