【发布时间】:2012-01-29 20:57:33
【问题描述】:
在 android 中,我正在尝试从下载并复制到 res 下的可绘制文件夹中的 jpeg 创建位图。
附上我的代码:
public void draw(Canvas g, Resources res, int x, int y, int w, int h) {
Bitmap im = BitmapFactory.decodeResource(res, R.drawable.green_dragon);
Bitmap im = BitmapFactory.decodeFile(R.drawable.green_dragon);
g.drawBitmap(im, null, new Rect(x*w, y*h, (x*w)+w, (y*h)+h), new Paint());
}
Android 无法识别 decodeResource 或 decodeFile 行中的 R.drawable.green_dragon。我也尝试过刷新和清理应用程序。都没有帮助。当我查看图像属性时,类型是文件,路径是 .jpg。
提前感谢您的帮助。
【问题讨论】: