• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            life02

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              197 隨筆 :: 3 文章 :: 37 評論 :: 0 Trackbacks
             1             BitmapDrawable icon= oldIcon; 
             2             final Bitmap.Config c = icon.getOpacity() != PixelFormat.OPAQUE ?
             3             Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
             4             int sIconWidth,sIconHeight ;
             5             sIconWidth = sIconHeight = (int) context.getResources().getDimension(R.dimen.img_width);
             6             
             7             int width = sIconWidth;
             8             int height = sIconHeight;
             9 
            10             Bitmap bmp=BitmapFactory.decodeResource(context.getResources(), R.drawable.tb_25);  
            11             float scale = 1.0f;
            12             int iconWidth = icon.getIntrinsicWidth();
            13             int iconHeight = icon.getIntrinsicHeight();
            14             
            15 //            Log.e("12", "BitmapDrawable:iconwidth"+iconWidth);
            16 //            Log.e("12", "BitmapDrawable:iconHeight"+iconHeight);
            17 //            Log.e("12", "BitmapDrawable:width"+width);
            18 //            Log.e("12", "BitmapDrawable:height"+height);
            19             final Canvas canvas = new Canvas();
            20             Rect sOldBounds = new Rect();
            21             if (width > 0 && height > 0) {
            22 //                if (width < iconWidth || height < iconHeight || scale != 1.0f) {
            23 
            24                     final float ratio = (float) iconWidth / iconHeight;
            25 
            26                     if (iconWidth > iconHeight) {
            27                         height = (int) (width / ratio);
            28                     } else if (iconHeight > iconWidth) {
            29                         width = (int) (height * ratio);
            30                     }
            31 
            32                     final Bitmap thumb = Bitmap.createBitmap(sIconWidth, sIconHeight, c);
            33                     canvas.setBitmap(thumb);
            34                     sOldBounds.set(icon.getBounds());
            35                     final int x = (sIconWidth - width) / 2;
            36                     final int y = (sIconHeight - height) / 2;
            37                     icon.setBounds(x, y, x + width, y + height);
            38                     
            39                     canvas.drawBitmap(bmp, new Matrix(), null);
            40                     icon.draw(canvas);
            41                     icon.setBounds(sOldBounds);
            42                     icon = new BitmapDrawable(context.getResources(), thumb);
            43 
            44 //                } else if (iconWidth < width && iconHeight < height) {
            45 //
            46 //                    final Bitmap.Config c1 = Bitmap.Config.ARGB_8888;
            47 //                    final Bitmap thumb = Bitmap.createBitmap(sIconWidth, sIconHeight, c1);
            48 //                    canvas.setBitmap(thumb);
            49 //                    sOldBounds.set(icon.getBounds());
            50 //                    final int x = (width - iconWidth) / 2;
            51 //                    final int y = (height - iconHeight) / 2;
            52 //                    icon.setBounds(x, y, x + iconWidth, y + iconHeight);
            53 //                    canvas.drawBitmap(bmp, new Matrix(), null);
            54 //                    icon.draw(canvas);
            55 //                    icon.setBounds(sOldBounds);
            56 //                    icon = new BitmapDrawable(context.getResources(), thumb);
            57 //                    Log.e("12", "iconWidth < widthBitmapDrawable:iconwidth"+iconWidth);
            58 //                    Log.e("12", "BitmapDrawable:iconHeight"+iconHeight);
            59 //                    Log.e("12", "BitmapDrawable:width"+width);
            60 //                    Log.e("12", "BitmapDrawable:height"+height);
            61 //                }
            62             }
            63             return icon;
            64         }
            posted on 2012-03-14 19:43 life02 閱讀(185) 評論(0)  編輯 收藏 引用 所屬分類: Android開發
            色播久久人人爽人人爽人人片AV| 亚洲第一极品精品无码久久| 国产V亚洲V天堂无码久久久| 欧美激情精品久久久久| 久久av免费天堂小草播放| 国产一区二区精品久久岳| 99久久精品免费看国产一区二区三区| 欧美亚洲色综久久精品国产| 久久av免费天堂小草播放| 99久久夜色精品国产网站| 国产综合免费精品久久久| 综合久久精品色| 久久91亚洲人成电影网站| 久久只有这精品99| 狠狠人妻久久久久久综合蜜桃| 亚洲欧美伊人久久综合一区二区| 国产精品永久久久久久久久久 | 亚洲国产成人精品女人久久久 | 国产亚洲精品久久久久秋霞| 99999久久久久久亚洲| 国产精品亚洲综合久久| 国产亚州精品女人久久久久久 | 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 久久国产精品-国产精品| 久久久久国产精品人妻| 天堂无码久久综合东京热| 91精品国产综合久久久久久| 精产国品久久一二三产区区别| 亚洲AⅤ优女AV综合久久久| 99久久国产免费福利| 久久99国产精品久久99果冻传媒| 一本久久知道综合久久| 国内精品久久久久影院亚洲| 久久综合伊人77777| 性高湖久久久久久久久AAAAA| 久久久久久久亚洲精品| 嫩草影院久久99| 亚洲一区二区三区日本久久九| 久久精品中文字幕有码| 久久免费国产精品| 久久亚洲国产成人影院|