LuckSiege / LuckSiege/PictureSelector

Bounds for bitmap could not be retrieved from the Uri

Open
#2,222 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
13.6k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Description

将 decodeSampledBitmap = BitmapFactory.decodeStream(stream, null, options);

替换 byte[] data = inputStream2ByteArr(stream);
//将InputStream转为byte数组,可以多次读取
decodeSampledBitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options);

就没有报错了

private byte[] inputStream2ByteArr(InputStream inputStream) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buff = new byte[1024];
int len = 0;
while ( (len = inputStream.read(buff)) != -1) {
outputStream.write(buff, 0, len);
}
inputStream.close();
outputStream.close();
return outputStream.toByteArray();
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the bitmap-decoding path that calls BitmapFactory.decodeStream with the URI's InputStream, then compare it with the reported decodeByteArray workaround. Reproduce the bounds-retrieval failure using a URI-backed stream; the work is done when bitmap bounds can be retrieved reliably without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.