异常:Resources$NotFoundException:资源 ID #0x4
我需要放大图像,我正在使用以下代码
int imageId = (Integer) intent.getExtras().get(ProfilePageNormalUser.class.getName());
imageView = (ImageView)findViewById(R.id.imageviewEnlarged);
System.out.println("*********"+imageId);
InputStream is = this.getResources().openRawResource(imageId);
Bitmap originalBitmap = BitmapFactory.decodeStream(is);
Matrix imageMatrix = new Matrix(); imageMatrix.postRotate(90);
Bitmap scaledBitmap = Bitmap.createBitmap(originalBitmap, imageView.getWidth(), imageView.getHeight(), originalBitmap.getWidth(), originalBitmap.getHeight(), imageMatrix, false);
imageView.setImageBitmap(scaledBitmap);
,但给了我上述异常。
Resources$NotFoundException: Resource ID #0x4
谁能告诉我哪里可能有问题。 谢谢
I need to enlarge image I am using the following code for it
int imageId = (Integer) intent.getExtras().get(ProfilePageNormalUser.class.getName());
imageView = (ImageView)findViewById(R.id.imageviewEnlarged);
System.out.println("*********"+imageId);
InputStream is = this.getResources().openRawResource(imageId);
Bitmap originalBitmap = BitmapFactory.decodeStream(is);
Matrix imageMatrix = new Matrix(); imageMatrix.postRotate(90);
Bitmap scaledBitmap = Bitmap.createBitmap(originalBitmap, imageView.getWidth(), imageView.getHeight(), originalBitmap.getWidth(), originalBitmap.getHeight(), imageMatrix, false);
imageView.setImageBitmap(scaledBitmap);
But is giving me the above exception .
Resources$NotFoundException: Resource ID #0x4
Can anyone tell me where could be the problem.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想使用 this.getResources().openRawResource(id) 。您必须将资源移动到 res/raw 文件夹。
尝试在 res 文件夹下创建一个名为 raw 的文件夹,并将您的资源粘贴到其中。
让我知道进展如何..
i think to use
this.getResources().openRawResource(id)
. You'll have to move your resource to res/raw folder.Try creating a folder named raw under res folder and paste your resource there.
Let me know how it goes..
OpenRawResource
无法从您正在使用的imageId
找到资源。检查您的图像 ID。
您可以直接使用:我认为:
InputStream ins = getResources().openRawResource(R.raw.my_db_file);
像上面提到的那样从原始文件夹中指定imageId。
先这样检查一下是否有效。
OpenRawResource
couldn't find the resouce fromimageId
that you are using.Check your imageId.
You can use directly: I think :
InputStream ins = getResources().openRawResource(R.raw.my_db_file);
the specify imageId like mentioned above from raw folder.
Check first like this , it works or not.