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

            久久久久久人妻无码| 国产成人久久久精品二区三区 | 99久久久国产精品免费无卡顿| 国产精品一区二区久久精品涩爱| 久久亚洲精品成人av无码网站| 日本一区精品久久久久影院| 久久久噜噜噜久久中文字幕色伊伊| 久久99久久99精品免视看动漫| 久久精品18| 国产亚洲成人久久| 国产欧美久久久精品| 欧美牲交A欧牲交aⅴ久久| 久久亚洲国产成人影院网站 | 久久精品国产91久久麻豆自制| 亚洲欧洲精品成人久久奇米网| 69SEX久久精品国产麻豆| 2021久久精品免费观看| 久久成人18免费网站| 青青青国产精品国产精品久久久久| 人妻少妇久久中文字幕一区二区| 亚洲v国产v天堂a无码久久| 国内精品久久久久国产盗摄| 亚洲伊人久久大香线蕉苏妲己| 久久亚洲私人国产精品| 亚洲国产精品无码久久98| 精品久久久久成人码免费动漫| 内射无码专区久久亚洲| 久久这里有精品视频| 欧美久久一区二区三区| 无码人妻久久一区二区三区蜜桃| 久久久久久久久久免免费精品| 久久精品成人一区二区三区| 久久久久久久久久免免费精品| 人妻丰满?V无码久久不卡| 色悠久久久久久久综合网| 久久久国产视频| 亚洲精品无码久久久影院相关影片| 中文字幕无码精品亚洲资源网久久| 亚洲精品无码久久久影院相关影片| 无码国内精品久久人妻蜜桃| 精品午夜久久福利大片|