如何获取图像文件,然后读取图像文件的名称?
我不知道位图的工作原理。
答案 0 :(得分:0)
1)将图像移动到drawable
文件夹
2)在您活动的XML布局文件(例如ActivityMain.xml)中添加:
<ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/myImage" android:id="@+id/myImage" />
3)你需要位图的地方:
Bitmap bm = ((BitmapDrawable) ((ImageView) findViewById(R.id.cImg)).getDrawable()).getBitmap();
此外,Java不是JavaScript,请删除您的标记。继续编码!