Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Fix certain JPEG files are failed to be decoded with BitmapRegionDecoder #219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amliu
Copy link

@amliu amliu commented Apr 11, 2016

@jdamcd jdamcd added the bug label May 27, 2016
@ivanviragine
Copy link

Tested on certain files and it worked! Thanks!

@amliu
Copy link
Author

amliu commented Jun 30, 2016

@ivanviragine glad to know that! thanks for your response

@ivanviragine
Copy link

Unfortunately, this isn't working. Some pictures are getting "y + height must be <= bitmap.height()" exception. I will dig in to understand the problem, but sounds like it's a width and height rounding problem...

@ivanviragine
Copy link

Here's what I've got so far:

original photo: 4128 x 2322

crop should be (squared example): 2322 x 2322

so, the rectangle should be left = 903 (that is imageWidth-cropWidth / 2), right = 3225 (that is left+cropWidth), top = 0, bottom = 2322 (that is cropHeight)

Ok?

The code is generating these values instead: left = 900 (-3 of actual value), right = 3224 (-1 of actual value), top = 0, bottom = 2324 (+2 of actual value)
These values are coming from cropRect var, which holds these values: left = 225, right = 806, top = 0, bottom = 581.

But, somehow,

croppedImage = decoder.decodeRegion(rect, new BitmapFactory.Options());

finds its way, even with these wrong parameters (like 2324 as height instead of the actual 2322 height), but

croppedImage = Bitmap.createBitmap(croppedImage, rect.left, rect.top, rect.width(), rect.height());

doesn't.

@amliu
Copy link
Author

amliu commented Jul 15, 2016

@ivanviragine May you provide your tested picture in this case so I can reproduce the issue and take a deeper look. Thanks.

mtrakal added a commit to mtrakal/android-crop that referenced this pull request Mar 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants