• <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++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              197 隨筆 :: 3 文章 :: 37 評(píng)論 :: 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();
            調(diào)節(jié)大的圖片,使它按比例適合我們的畫布
                    
            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);
                            }
            這里是調(diào)節(jié)小的圖片,如果給的圖片小于畫布,我們便使用原圖的尺寸
            //            } 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 閱讀(1128) 評(píng)論(1)  編輯 收藏 引用 所屬分類: Android開發(fā)

            評(píng)論

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

            精品免费久久久久久久| 少妇久久久久久被弄到高潮| 久久久久亚洲AV无码观看 | 日韩av无码久久精品免费| 久久99热这里只有精品国产| 伊人久久久AV老熟妇色| 1000部精品久久久久久久久| 狠狠狠色丁香婷婷综合久久俺| 国产成人精品久久亚洲| 麻豆av久久av盛宴av| 久久免费线看线看| 久久亚洲sm情趣捆绑调教| 国产午夜久久影院| 亚洲美日韩Av中文字幕无码久久久妻妇 | 久久精品国产久精国产果冻传媒 | 亚洲国产精品久久66| 欧美午夜A∨大片久久| 97热久久免费频精品99| 一级做a爰片久久毛片看看| 国产欧美久久久精品| 国内精品久久久久影院薰衣草 | www.久久热.com| 久久久久18| 丁香狠狠色婷婷久久综合| 欧美日韩精品久久久久| 国产亚洲欧美成人久久片| 欧美亚洲国产精品久久| 国产ww久久久久久久久久| 狠狠色丁香久久婷婷综合五月 | 久久久久久青草大香综合精品| 国产三级久久久精品麻豆三级| 日产精品久久久久久久| 亚洲AV伊人久久青青草原| 狠狠精品干练久久久无码中文字幕 | 久久99国产乱子伦精品免费| 久久99精品综合国产首页| 久久亚洲国产精品123区| 国产免费久久久久久无码| 2021久久国自产拍精品| 国产精品久久一区二区三区| 久久99精品国产自在现线小黄鸭|