• <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
            /**
                 * Returns a bitmap suitable for the all apps view.  The bitmap will be a power
                 * of two sized ARGB_8888 bitmap that can be used as a gl texture.
                 
            */
                
            private Bitmap createIconBitmap(Drawable icon) {
                    
            int width = mIconWidth;
                    
            int height = mIconHeight;

                    
            if (icon instanceof PaintDrawable) {
                        PaintDrawable painter 
            = (PaintDrawable) icon;
                        painter.setIntrinsicWidth(width);
                        painter.setIntrinsicHeight(height);
                    } 
            else if (icon instanceof BitmapDrawable) {
                        
            // Ensure the bitmap has a density.
                        BitmapDrawable bitmapDrawable = (BitmapDrawable) icon;
                        Bitmap bitmap 
            = bitmapDrawable.getBitmap();
                        
            if (bitmap.getDensity() == Bitmap.DENSITY_NONE) {
                            bitmapDrawable.setTargetDensity(mDisplayMetrics);
                        }
                    }
                    
            int sourceWidth = icon.getIntrinsicWidth();
                    
            int sourceHeight = icon.getIntrinsicHeight();
            調節大的圖片,使它按比例適合我們的畫布
                    
            if (sourceWidth > 0 && sourceWidth > 0) {
                        
            // There are intrinsic sizes.
            //            if (width < sourceWidth || height < sourceHeight) {
                            
            // It's too big, scale it down.
                            final float ratio = (float) sourceWidth / sourceHeight;
                            
            if (sourceWidth > sourceHeight) {
                                height 
            = (int) (width / ratio);
                            } 
            else if (sourceHeight > sourceWidth) {
                                width 
            = (int) (height * ratio);
                            }
            這里是調節小的圖片,如果給的圖片小于畫布,我們便使用原圖的尺寸
            //            } else if (sourceWidth < width && sourceHeight < height) {
            //                // It's small, use the size they gave us.
            //                width = sourceWidth;
            //                height = sourceHeight;
            //            }
                    }

                    
            // no intrinsic size --> use default size
                    int textureWidth = mIconTextureWidth;
                    
            int textureHeight = mIconTextureHeight;

                    
            final Bitmap bitmap = Bitmap.createBitmap(textureWidth, textureHeight,
                            Bitmap.Config.ARGB_8888);
                    
            final Canvas canvas = mCanvas;
                    canvas.setBitmap(bitmap);

                    
            final int left = (textureWidth-width) / 2;
                    
            final int top = (textureHeight-height) / 2;

                    
            if (false) {
                        
            // draw a big box for the icon for debugging
                        canvas.drawColor(sColors[mColorIndex]);
                        
            if (++mColorIndex >= sColors.length) mColorIndex = 0;
                        Paint debugPaint 
            = new Paint();
                        debugPaint.setColor(
            0xffcccc00);
                        canvas.drawRect(left, top, left
            +width, top+height, debugPaint);
                    }

                    mOldBounds.set(icon.getBounds());
                    icon.setBounds(left, top, left
            +width, top+height);
                    icon.draw(canvas);
                    icon.setBounds(mOldBounds);
                    
            return bitmap;
                }
            posted on 2012-03-21 16:54 life02 閱讀(1143) 評論(1)  編輯 收藏 引用 所屬分類: Android開發

            評論

            # re: IconUtilities類的createIconBitmap方法分析 2012-04-23 20:40 bs
            分析在哪里?  回復  更多評論
              

            国产激情久久久久久熟女老人| 精品无码久久久久国产| 久久久精品波多野结衣| 亚洲国产成人久久综合碰| 久久久久无码精品国产| 国内精品久久久久久久亚洲| 一本大道久久东京热无码AV| 久久午夜无码鲁丝片| 精品水蜜桃久久久久久久| 亚洲午夜久久久久妓女影院 | 亚洲精品无码久久久| 亚洲国产一成人久久精品| 四虎国产永久免费久久| 亚洲AV无码久久精品色欲| 97精品伊人久久久大香线蕉| 中文字幕日本人妻久久久免费| 国产精品亚洲综合专区片高清久久久 | 成人国内精品久久久久影院| 99久久精品免费看国产免费| 国产成人精品综合久久久久| 精品久久久无码中文字幕天天| 久久精品夜色噜噜亚洲A∨ | 久久精品99无色码中文字幕| 午夜精品久久久久久久久| 久久久久18| 狠狠色伊人久久精品综合网| 97久久精品人妻人人搡人人玩| 97久久婷婷五月综合色d啪蜜芽| 久久天天躁狠狠躁夜夜不卡| 国产一区二区精品久久| 精品乱码久久久久久久| 97久久婷婷五月综合色d啪蜜芽| 久久综合五月丁香久久激情| 久久久受www免费人成| 精品人妻伦一二三区久久| 国产精品青草久久久久福利99| 亚洲成色999久久网站| 99久久精品免费看国产| 久久久久人妻精品一区三寸蜜桃| 亚洲精品高清久久| 国产高潮国产高潮久久久91|