• <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
            分析在哪里?  回復  更多評論
              

            老男人久久青草av高清| 国产激情久久久久影院老熟女免费| 国产女人aaa级久久久级| 91久久精品电影| 久久久久久久精品妇女99| 久久香蕉一级毛片| 三上悠亚久久精品| 天天影视色香欲综合久久| 亚洲国产精品久久久久| 久久婷婷色综合一区二区| 国产韩国精品一区二区三区久久| 伊人情人综合成人久久网小说| 久久精品国产99国产电影网 | 国产精品久久久久久久人人看| 久久精品人人做人人爽电影蜜月| 久久国内免费视频| 久久精品国产秦先生| 久久精品免费一区二区| 国产精品成人99久久久久 | 久久久久亚洲爆乳少妇无 | 亚洲中文字幕伊人久久无码| 久久精品www人人爽人人| 武侠古典久久婷婷狼人伊人| 国产成人香蕉久久久久| 9191精品国产免费久久| 人妻无码αv中文字幕久久| 久久久久久久波多野结衣高潮| 久久精品二区| 久久狠狠爱亚洲综合影院| 久久久这里有精品中文字幕| 国产精品无码久久四虎| 国产精品九九久久免费视频 | 国产 亚洲 欧美 另类 久久| 久久ZYZ资源站无码中文动漫 | 无码专区久久综合久中文字幕| 久久久一本精品99久久精品88| 大香伊人久久精品一区二区| 亚洲精品99久久久久中文字幕| 亚洲一区精品伊人久久伊人| 亚洲精品成人久久久| 精品国产99久久久久久麻豆|