提交 9ec89913 编写于 作者: J judds 提交者: Sam Judd

Ignore fixBitmapToRequestedDimensions if we're unable to determine source dimens.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171204273
上级 1e2fb234
...@@ -271,7 +271,8 @@ public final class Downsampler { ...@@ -271,7 +271,8 @@ public final class Downsampler {
if ((options.inSampleSize == 1 || isKitKatOrGreater) && shouldUsePool(imageType)) { if ((options.inSampleSize == 1 || isKitKatOrGreater) && shouldUsePool(imageType)) {
int expectedWidth; int expectedWidth;
int expectedHeight; int expectedHeight;
if (fixBitmapToRequestedDimensions && isKitKatOrGreater) { if (sourceWidth >= 0 && sourceHeight >= 0
&& fixBitmapToRequestedDimensions && isKitKatOrGreater) {
expectedWidth = targetWidth; expectedWidth = targetWidth;
expectedHeight = targetHeight; expectedHeight = targetHeight;
} else { } else {
...@@ -336,6 +337,10 @@ public final class Downsampler { ...@@ -336,6 +337,10 @@ public final class Downsampler {
BitmapFactory.Options options) throws IOException { BitmapFactory.Options options) throws IOException {
// We can't downsample source content if we can't determine its dimensions. // We can't downsample source content if we can't determine its dimensions.
if (sourceWidth <= 0 || sourceHeight <= 0) { if (sourceWidth <= 0 || sourceHeight <= 0) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Unable to determine dimensions for: " + imageType
+ " with target [" + targetWidth + "x" + targetHeight + "]");
}
return; return;
} }
......
...@@ -57,7 +57,7 @@ public class MarkEnforcingInputStream extends FilterInputStream { ...@@ -57,7 +57,7 @@ public class MarkEnforcingInputStream extends FilterInputStream {
public long skip(long byteCount) throws IOException { public long skip(long byteCount) throws IOException {
long toSkip = getBytesToRead(byteCount); long toSkip = getBytesToRead(byteCount);
if (toSkip == END_OF_STREAM) { if (toSkip == END_OF_STREAM) {
return END_OF_STREAM; return 0;
} }
long read = super.skip(toSkip); long read = super.skip(toSkip);
......
...@@ -135,7 +135,7 @@ public class MarkEnforcingInputStreamTest { ...@@ -135,7 +135,7 @@ public class MarkEnforcingInputStreamTest {
is.mark(MARK_LIMIT); is.mark(MARK_LIMIT);
assertEquals(MARK_LIMIT, is.skip(DATA_SIZE)); assertEquals(MARK_LIMIT, is.skip(DATA_SIZE));
assertEquals(-1, is.skip(1)); assertEquals(0, is.skip(1));
} }
@Test @Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册