From 864cdaa6b42681aa049efd19ede263ffdadb6983 Mon Sep 17 00:00:00 2001 From: shenfei Date: Sat, 18 Sep 2021 15:11:29 +0800 Subject: [PATCH] fixed: fixed the glide mathod: overrude(width,height) and submit(width,heigt),does not work --- .../glide/load/resource/bitmap/Downsampler.java | 13 +++++++++---- .../src/main/java/com/bumptech/glide/util/Util.java | 8 ++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java index 79411926d..6cef541ce 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java @@ -392,7 +392,12 @@ public final class Downsampler { ? Math.max(widthScaleFactor, heightScaleFactor) : Math.min(widthScaleFactor, heightScaleFactor); - + int powerOfTwoSampleSize = Math.max(1,Integer.highestOneBit(scaleFactor)); + if (rounding == SampleSizeRounding.MEMORY + &&powerOfTwoSampleSize < (1.f/exactScaleFactor)) { + powerOfTwoSampleSize=powerOfTwoSampleSize << 1; + } + options.sampleSize = powerOfTwoSampleSize; if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.info( TAG, @@ -531,10 +536,10 @@ public final class Downsampler { return getBitmapString(); } - + @Nullable private static String getBitmapString() { - + return "[There is no inbitmap in HMOS" + "] "; } @@ -579,7 +584,7 @@ public final class Downsampler { return decodingOpts; } - private static void releaseOptions(ImageSource.DecodingOptions decodingOpts) { + private static void releaseOptions(ImageSource.DecodingOptions decodingOpts) { resetOptions(decodingOpts); synchronized (OPTIONS_QUEUE) { OPTIONS_QUEUE.offer(decodingOpts); diff --git a/library/src/main/java/com/bumptech/glide/util/Util.java b/library/src/main/java/com/bumptech/glide/util/Util.java index 66f8743dc..4a11383e1 100644 --- a/library/src/main/java/com/bumptech/glide/util/Util.java +++ b/library/src/main/java/com/bumptech/glide/util/Util.java @@ -285,6 +285,14 @@ public static void getImageInfo(InputStream is, ImageSource.DecodingOptions opt } public static PixelMap decodePixelMap(InputStream is, ImageSource.DecodingOptions options, String formatHint)throws IOException{ + if (options.sampleSize != 0) { + /*TODO + the sampleSize attribute in DecodingOptions is not supported by the system currently and will + be optimized in the future; + */ + options.desiredSize.width = options.desiredSize.width / options.sampleSize; + options.desiredSize.height = options.desiredSize.height / options.sampleSize; + } ImageSource.SourceOptions srcOpts = new ImageSource.SourceOptions(); srcOpts.formatHint = formatHint; ImageSource imageSource =ImageSource.create(is, srcOpts); -- Gitee