Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android BitmapFactory.DecodeResource无法识别可提取项_Android_Image_Visual Studio_Xamarin - Fatal编程技术网

Android BitmapFactory.DecodeResource无法识别可提取项

Android BitmapFactory.DecodeResource无法识别可提取项,android,image,visual-studio,xamarin,Android,Image,Visual Studio,Xamarin,我正试图在VisualStudio中使用C#加载一个简单的图像作为GPS应用程序的背景 资源位于 资源/可绘制/资源文件 现在我试着像这样显示这些文件,“Arrow”en“Map” Kaart=BitmapFactory.DecodeResource(context.Resources,Resource.Drawable.Map,opt) Pijl=BitmapFactory.DecodeResource(context.Resources,Resource.Drawable.Arrow,opt

我正试图在VisualStudio中使用C#加载一个简单的图像作为GPS应用程序的背景

资源位于

资源/可绘制/资源文件

现在我试着像这样显示这些文件,“Arrow”en“Map”

Kaart=BitmapFactory.DecodeResource(context.Resources,Resource.Drawable.Map,opt)

Pijl=BitmapFactory.DecodeResource(context.Resources,Resource.Drawable.Arrow,opt)

我在类的开头声明了“Kaart”和“Pijl”als位图,但是“Map”和“Arrow”仍然无法识别,并且用红色下划线表示Resource.Drawable不包含“Arrow”和“Map”的定义

谢谢

Resources res = getContext().getResources();
int id = R.drawable.image; 
Bitmap b = BitmapFactory.decodeResource(res, id);
这将返回解码后的
位图
,如果图像无法解码,则返回null

注意:如果
“image”
存在于所有位图中,则
位图将不同
可绘制文件夹(如ldpi、mdpi、hdpi等)。因此,理想的做法是保持
原始
drawable
文件夹中的图像不变