Android8.thumbnails,thumbnails - Android: ThumbnailUtils.createVideoThumbnail return black bitmap - ...

端木昱
2023-12-01

You can use this method to create Thumbnail

private Bitmap getThumbnailBitmap(String file_name,String file_type)

{

try

{

String file_path= Environment.getExternalStorageDirectory()+File.separator+ Constants.APP_FOLDER_NAME+File.separator+ Constants.ATTACHMENTS_FOLDER_NAME+File.separator+file_name;

if(file_type.equals(Constants.FILE_TYPE_IMAGE))

{

int dimens=(int) Env.currentActivity.getResources().getDimension(R.dimen.thumbnailHW);

FileInputStream fis = new FileInputStream(file_path);

Bitmap imageBitmap = BitmapFactory.decodeStream(fis);

return ThumbnailUtils.extractThumbnail(imageBitmap, dimens, dimens);

}

else if(file_type.equals(Constants.FILE_TYPE_VIDEO))

{

return ThumbnailUtils.createVideoThumbnail(file_path, MediaStore.Video.Thumbnails.MICRO_KIND);

}

}catch (Exception e)

{

e.printStackTrace();

}

return null;

}

 类似资料:

相关阅读

相关文章

相关问答