草庐IT

strMimeType

全部标签

android - 如何从图库中获取图像的图像格式

我想知道我从图库中获取的图像的图像格式(即JPFG/PNG等)。我的需求是从设备图库中截取图片并将其以Base64格式发送到服务器,但服务器想知道图片格式。感谢任何帮助。 最佳答案 编辑:使用以下方法从图库中检索图像的MIME类型:publicstaticStringGetMimeType(Contextcontext,UriuriImage){StringstrMimeType=null;Cursorcursor=context.getContentResolver().query(uriImage,newString[]{Med