Skip to content

Commit

Permalink
Revert image resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1d0w committed Apr 30, 2020
1 parent 3402c38 commit ad24ac1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 35 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

### Change (v4.6.7)

## 2020-04-30

- Revert fix resizing an image causes jagged lines on Android

### Change (v4.6.6)

## 2020-04-11
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.vitanov.multiimagepicker'
version '4.6.6'
version '4.6.7'

buildscript {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.provider.MediaStore;
import android.provider.OpenableColumns;
import android.text.TextUtils;
import android.media.ThumbnailUtils;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
Expand Down Expand Up @@ -43,6 +44,8 @@
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar;

import static android.media.ThumbnailUtils.OPTIONS_RECYCLE_INPUT;


/**
* MultiImagePickerPlugin
Expand Down Expand Up @@ -114,7 +117,8 @@ protected ByteBuffer doInBackground(String... strings) {
Activity activity = activityReference.get();
if (activity == null || activity.isFinishing()) return null;

Bitmap bitmap = getCorrectlyOrientedImage(activity, uri, this.width, this.height);
Bitmap sourceBitmap = getCorrectlyOrientedImage(activity, uri);
Bitmap bitmap = ThumbnailUtils.extractThumbnail(sourceBitmap, this.width, this.height, OPTIONS_RECYCLE_INPUT);

if (bitmap == null) return null;

Expand Down Expand Up @@ -743,37 +747,6 @@ private static Bitmap getCorrectlyOrientedImage(Context context, Uri photoUri) t
return srcBitmap;
}

// https://developer.android.com/topic/performance/graphics/load-bitmap#java
private static Bitmap getCorrectlyOrientedImage(Context context, Uri photoUri, int width, int height) throws IOException {
int orientation = getOrientation(context, photoUri);

BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
InputStream is = context.getContentResolver().openInputStream(photoUri);
BitmapFactory.decodeStream(is, null, options);

// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
options.inDither = false;
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, width, height);
options.inScaled = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;

InputStream is2 = context.getContentResolver().openInputStream(photoUri);
Bitmap srcBitmap = BitmapFactory.decodeStream(is2, null, options);

if (orientation > 0) {
Matrix matrix = new Matrix();
matrix.postRotate(orientation);

srcBitmap = Bitmap.createBitmap(srcBitmap, 0, 0, srcBitmap.getWidth(),
srcBitmap.getHeight(), matrix, true);
}

return srcBitmap;
}

public static int calculateInSampleSize(
BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
Expand Down
2 changes: 1 addition & 1 deletion ios/multi_image_picker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'multi_image_picker'
s.version = '4.6.6'
s.version = '4.6.7'
s.summary = 'Multi image picker'
s.description = <<-DESC
A new flutter plugin project.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: multi_image_picker
description: Flutter plugin that allows you to display multi image picker on iOS and Android.
version: 4.6.6+rc.1
version: 4.6.7
homepage: https://github.com/Sh1d0w/multi_image_picker

dependencies:
Expand Down

0 comments on commit ad24ac1

Please sign in to comment.