zoukankan      html  css  js  c++  java
  • Google glass GDK

    网上转的都太不靠谱了 = = 在一个MP3播放器里面挖了出来,用时就用上了~

     1     public static Bitmap getAlbumArtWork(String filePath) {
     2         try {
     3             MediaMetadataRetriever metaRetriver = new MediaMetadataRetriever();
     4             metaRetriver.setDataSource(filePath);
     5             byte[] album = metaRetriver.getEmbeddedPicture();
     6             if (album != null) {
     7                 BitmapFactory.Options opts = new BitmapFactory.Options();
     8                 opts.inJustDecodeBounds = true;
     9                 BitmapFactory.decodeByteArray(album, 0, album.length, opts);
    10                 opts.inSampleSize = calculateInSampleSize(opts);
    11                 opts.inJustDecodeBounds = false;
    12                 return BitmapFactory.decodeByteArray(album, 0, album.length, opts);
    13             }
    14             return null;
    15         } catch (Exception e) {
    16             return null;
    17         }
    18     }   
    19     public static int calculateInSampleSize(BitmapFactory.Options options) {
    20         // Raw height and width of image
    21         final int height = options.outHeight;
    22         final int width = options.outWidth;
    23         int inSampleSize = 1;
    24         //Our height and width will always be the same since all glass has the same resolution, for now...
    25         if (height > 360 || width > 640) {
    26             final int halfHeight = height / 2;
    27             final int halfWidth = width / 2;
    28             // Calculate the largest inSampleSize value that is a power of 2 and keeps both
    29             // height and width larger than the requested height and width.
    30             while ((halfHeight / inSampleSize) > 360 && (halfWidth / inSampleSize) > 640) {
    31                 inSampleSize *= 2;
    32             }
    33         }
    34 
    35         return inSampleSize;
    36     }
  • 相关阅读:
    python3写的exe小工具的准备事项
    信息网站罗列
    you-get下载视频
    sprintboot入门
    linux 常用指令nfs,根据时间删除文件,路由router
    ubuntu下adsl拨号设置
    Hadoop的Archive归档命令使用指南
    MVC5 + EF6 完整入门教程三:EF来了
    MVC5 + EF6 入门完整教程二:从前端的UI开始
    MVC5 + EF6 入门完整教程一:从0开始
  • 原文地址:https://www.cnblogs.com/ch3rry/p/3871387.html
Copyright © 2011-2022 走看看