GameView.java 文件源码

java
阅读 44 收藏 0 点赞 0 评论 0

项目:buildAPKsSamples 作者:
private Bitmap getResBitmap(int bmpResId) {
    Options opts = new Options();
    opts.inDither = false;

    Resources res = getResources();
    Bitmap bmp = BitmapFactory.decodeResource(res, bmpResId, opts);

    if (bmp == null && isInEditMode()) {
        // BitmapFactory.decodeResource doesn't work from the rendering
        // library in Eclipse's Graphical Layout Editor. Use this workaround instead.

        Drawable d = res.getDrawable(bmpResId);
        int w = d.getIntrinsicWidth();
        int h = d.getIntrinsicHeight();
        bmp = Bitmap.createBitmap(w, h, Config.ARGB_8888);
        Canvas c = new Canvas(bmp);
        d.setBounds(0, 0, w - 1, h - 1);
        d.draw(c);
    }

    return bmp;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号