Notice
                              
                            
                          
                        
                          
                          
                            Recent Posts
                            
                        
                          
                          
                            Recent Comments
                            
                        
                          
                          
                        반응형
    
    
    
  오늘도 공부
Called reconfigure on a bitmap that is in use! This may cause graphical corruption! 본문
      Android/Tip&Tech
      
    Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
행복한 수지아빠 2017. 2. 14. 12:03반응형
    
    
    
  public class TileBitmapProvider implements BitmapProvider {
    private final TileProvider provider;
    private final Bitmap.Config bitmapConfig;
    private final int backgroundColor;
    private final BitmapPool bitmapPool;
    private final Rect frameRect = new Rect();
    public TileBitmapProvider(final TileProvider provider,
                              final BitmapPool bitmapPool,
                              final Bitmap.Config bitmapConfig,
                              final int backgroundColor) {
        this.provider = provider;
        this.bitmapConfig = bitmapConfig;
        this.backgroundColor = backgroundColor;
        this.bitmapPool = bitmapPool;
    }
    @Override public Bitmap getBitmap(final Tile tile, final Context context) {
        try {
            Bitmap bmp = tile.getBitmap();
            if (bmp == null || bmp.isRecycled()) {
                bmp = bitmapPool.poll();
                bmp = bmp != null ? bmp : Bitmap.createBitmap(tile.getWidth(), tile.getHeight(), bitmapConfig);
                // tiles at edges need to be padded so that they fit correctly
                bmp.eraseColor(backgroundColor);
                final BitmapFactory.Options ops = new BitmapFactory.Options();
                ops.inPreferredConfig = bitmapConfig;
                ops.inBitmap = bmp;
                ops.inMutable = true;
                frameRect.set(0, 0, tile.getWidth(), tile.getHeight());
                bmp = BitmapRegionDecoder.newInstance(provider.readTile(tile), false).decodeRegion(frameRect, ops);
            }
            return bmp;
        } catch (final IOException e) {
            Logger.getInstance().critical(getClass().getSimpleName(), e, "Error loading tile:");
        }
        return null;
    }
}
다음은 경고를 트리거하는 코드입니다.
public class TileBitmapProvider implements BitmapProvider {
    private final TileProvider provider;
    private final Bitmap.Config bitmapConfig;
    private final int backgroundColor;
    private final BitmapPool bitmapPool;
    public TileBitmapProvider(final TileProvider provider,
                              final BitmapPool bitmapPool,
                              final Bitmap.Config bitmapConfig,
                              final int backgroundColor) {
        this.provider = provider;
        this.bitmapConfig = bitmapConfig;
        this.backgroundColor = backgroundColor;
        this.bitmapPool = bitmapPool;
    }
    @Override public Bitmap getBitmap(final Tile tile, final Context context) {
        try {
            Bitmap bmp = tile.getBitmap();
            if (bmp == null || bmp.isRecycled()) {
                bmp = bitmapPool.poll();
                bmp = bmp != null ? bmp : Bitmap.createBitmap(tile.getWidth(), tile.getHeight(), bitmapConfig);
                // tiles at edges need to be padded so that they fit correctly
                bmp.eraseColor(backgroundColor);
                final BitmapFactory.Options ops = new BitmapFactory.Options();
                ops.inPreferredConfig = bitmapConfig;
                ops.inBitmap = bmp;
                ops.inMutable = true;
                bmp = BitmapFactory.decodeStream(provider.readTile(tile), null, ops);
            }
            return bmp;
        } catch (final IOException e) {
            Logger.getInstance().critical(getClass().getSimpleName(), e, "Error loading tile:");
        }
        return null;
    }
}반응형
    
    
    
  'Android > Tip&Tech' 카테고리의 다른 글
| Android GridLayoutManager 샘플 소스 (0) | 2017.08.03 | 
|---|---|
| List of Android Top 1000 Libraries (0) | 2016.06.08 | 
| 줌인되는 커스텀 리스트 뷰 소스 (0) | 2015.09.04 | 
| [펌]안드로이드 구글 맵 반경그리기 (1) | 2015.01.25 | 
| Android ListView CheckBox 스크롤후 없어지는 문제 (0) | 2015.01.24 | 
