• <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++博客 :: 首頁(yè) :: 新隨筆 :: 聯(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 閱讀(1130) 評(píng)論(1)  編輯 收藏 引用 所屬分類: Android開發(fā)

            評(píng)論

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

            久久天天躁狠狠躁夜夜网站| 品成人欧美大片久久国产欧美...| 久久九九亚洲精品| 亚洲午夜久久久久妓女影院| 欧美久久久久久| 欧美久久天天综合香蕉伊| 91精品观看91久久久久久| 精品久久久久久久无码| 久久天天躁狠狠躁夜夜躁2O2O| 久久久这里只有精品加勒比| 久久受www免费人成_看片中文| 久久精品国产亚洲AV不卡| 久久精品国产福利国产秒| 欧美日韩中文字幕久久伊人| 伊人热人久久中文字幕| 99精品伊人久久久大香线蕉| 狠狠色综合久久久久尤物| 久久99精品国产麻豆不卡| 久久99精品久久久久久水蜜桃| 久久丝袜精品中文字幕| 综合久久一区二区三区 | 久久综合亚洲色HEZYO国产| 国产综合精品久久亚洲| 无码乱码观看精品久久| 国内精品久久久久影院薰衣草| 亚洲乱码精品久久久久..| 久久久久亚洲Av无码专| 99久久国产免费福利| 久久夜色精品国产亚洲| 久久91精品国产91久久小草| 精品水蜜桃久久久久久久| 香蕉久久永久视频| 国产高潮国产高潮久久久| 国产综合精品久久亚洲| 久久99精品久久久大学生| 夜夜亚洲天天久久| 亚洲国产精品无码久久青草| 精品久久无码中文字幕| 久久这里有精品视频| 国内精品九九久久久精品| 久久亚洲精品无码观看不卡|