• <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 閱讀(1145) 評論(1)  編輯 收藏 引用 所屬分類: Android開發

            評論

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

            久久超碰97人人做人人爱| 久久大香香蕉国产| 久久亚洲av无码精品浪潮| 久久影院午夜理论片无码 | 一级做a爰片久久毛片人呢| 91久久成人免费| 性做久久久久久久久浪潮| 久久人人爽人人爽人人av东京热| 色综合久久夜色精品国产| 99国产精品久久| 免费久久人人爽人人爽av| 久久精品国产亚洲一区二区| 伊人久久大香线蕉综合热线| 久久久久久毛片免费播放| 看全色黄大色大片免费久久久| 亚洲国产精品无码久久SM| 青草久久久国产线免观| 国产精品毛片久久久久久久| 久久人人爽人人爽人人av东京热 | 青青草原综合久久| 日韩亚洲国产综合久久久| 欧美综合天天夜夜久久| 色综合久久中文字幕无码| 精品久久久久久无码中文野结衣| 久久男人Av资源网站无码软件| 亚洲AⅤ优女AV综合久久久| 91久久精品无码一区二区毛片| 久久精品蜜芽亚洲国产AV| 一本久道久久综合狠狠爱| 青青草国产97免久久费观看| 国产精品欧美久久久久天天影视 | 伊人久久精品无码二区麻豆| 亚洲天堂久久久| 久久久久无码精品| 久久本道久久综合伊人| 91久久精品国产91性色也| 国产高清国内精品福利99久久| 久久免费高清视频| 久久99精品国产麻豆婷婷| 一本久久a久久精品综合夜夜| 91精品婷婷国产综合久久|