A slight improvement for Dave Jarvis.
Instead of hard coding, the mime type in
images.put(id, "data:image/jpg;base64," + Base64.encodeBytes(data));
You can try to open the mime type as follows:
// Find out the mime type final ByteArrayInputStream bis = new ByteArrayInputStream( data ); final String mimeType = URLConnection.guessContentTypeFromStream( bis ); // Convert to an embedded "data" url. final String base64Data = "data:"+mimeType+";base64,"+Base64.encodeBytes( data ); imagesMap.put( id, base64Data );
Dannyb
source share