Commit 79d3a8d1 authored by 林生雨's avatar 林生雨

commit

parent f72993a8
This diff is collapsed.
...@@ -31,7 +31,7 @@ android { ...@@ -31,7 +31,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk { ndk {
abiFilters 'armeabi-v7a' abiFilters 'armeabi-v7a'
} }
...@@ -49,6 +49,7 @@ dependencies { ...@@ -49,6 +49,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion" implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion" implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.8.0' implementation 'com.github.bumptech.glide:glide:4.8.0'
} }
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
\ No newline at end of file
...@@ -14,7 +14,7 @@ import android.os.Build ...@@ -14,7 +14,7 @@ import android.os.Build
import android.os.Environment import android.os.Environment
import android.os.Handler import android.os.Handler
import android.provider.MediaStore import android.provider.MediaStore
import android.support.v4.content.FileProvider import androidx.core.content.FileProvider
import android.util.Log import android.util.Log
import android.widget.Toast import android.widget.Toast
import com.example.gengmei_flutter_plugin.act.PreviewActivity import com.example.gengmei_flutter_plugin.act.PreviewActivity
...@@ -23,6 +23,7 @@ import com.example.gengmei_flutter_plugin.result.ResultManager ...@@ -23,6 +23,7 @@ import com.example.gengmei_flutter_plugin.result.ResultManager
import com.example.gengmei_flutter_plugin.sharedPrefernces.SharedManager import com.example.gengmei_flutter_plugin.sharedPrefernces.SharedManager
import com.example.gengmei_flutter_plugin.utils.DebugUtil import com.example.gengmei_flutter_plugin.utils.DebugUtil
import com.example.gengmei_flutter_plugin.utils.MyUtil.Companion.getFileName import com.example.gengmei_flutter_plugin.utils.MyUtil.Companion.getFileName
import com.example.gengmei_flutter_plugin.utils.PhotoBitmapUtils
import com.example.gengmei_flutter_plugin.utils.addTo import com.example.gengmei_flutter_plugin.utils.addTo
import com.example.myimagepicker.luban.Luban import com.example.myimagepicker.luban.Luban
import com.example.myimagepicker.repository.ImageRespository import com.example.myimagepicker.repository.ImageRespository
...@@ -140,6 +141,10 @@ class GengmeiFlutterPlugin : MethodCallHandler { ...@@ -140,6 +141,10 @@ class GengmeiFlutterPlugin : MethodCallHandler {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
android.util.Log.e("lsy", " RESULT OKKKKK ") android.util.Log.e("lsy", " RESULT OKKKKK ")
if (nativeImage != null && nativeImage!!.exists()) { if (nativeImage != null && nativeImage!!.exists()) {
val bitmapDegree = PhotoBitmapUtils.getBitmapDegree(nativeImage!!.absolutePath)
if(bitmapDegree!=0){
PhotoBitmapUtils.rotateBitmapByDegree(nativeImage!!.absolutePath,bitmapDegree)
}
ImageRespository.getInstance().scareImg(nativeImage!!.absolutePath).subscribe({ ImageRespository.getInstance().scareImg(nativeImage!!.absolutePath).subscribe({
val map = HashMap<String, Any>() val map = HashMap<String, Any>()
map.put("realPath", it.first) map.put("realPath", it.first)
......
package com.example.gengmei_flutter_plugin.act package com.example.gengmei_flutter_plugin.act
import android.os.Bundle import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.example.gengmei_flutter_plugin.R import com.example.gengmei_flutter_plugin.R
import com.example.gengmei_flutter_plugin.act.view.PinchImageView import com.example.gengmei_flutter_plugin.act.view.PinchImageView
......
...@@ -2,10 +2,10 @@ package com.example.gengmei_flutter_plugin.act ...@@ -2,10 +2,10 @@ package com.example.gengmei_flutter_plugin.act
import android.os.Bundle import android.os.Bundle
import android.provider.CalendarContract import android.provider.CalendarContract
import android.support.v7.app.AppCompatActivity
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.MediaController import android.widget.MediaController
import android.widget.VideoView import android.widget.VideoView
import androidx.appcompat.app.AppCompatActivity
import com.example.gengmei_flutter_plugin.R import com.example.gengmei_flutter_plugin.R
import com.example.gengmei_flutter_plugin.utils.MyUtil import com.example.gengmei_flutter_plugin.utils.MyUtil
......
...@@ -2,13 +2,17 @@ package com.example.gengmei_flutter_plugin.act.view ...@@ -2,13 +2,17 @@ package com.example.gengmei_flutter_plugin.act.view
import android.animation.ValueAnimator import android.animation.ValueAnimator
import android.content.Context import android.content.Context
import android.graphics.* import android.graphics.Canvas
import android.support.v7.widget.AppCompatImageView import android.graphics.Matrix
import android.graphics.PointF
import android.graphics.RectF
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log
import android.view.GestureDetector import android.view.GestureDetector
import android.view.MotionEvent import android.view.MotionEvent
import androidx.appcompat.widget.AppCompatImageView
import java.util.* import java.util.*
import kotlin.collections.ArrayList
/** /**
* 手势缩放ImageView * 手势缩放ImageView
......
...@@ -13,7 +13,7 @@ import java.io.FileOutputStream ...@@ -13,7 +13,7 @@ import java.io.FileOutputStream
import java.io.IOException import java.io.IOException
import java.lang.Exception import java.lang.Exception
import android.view.ViewGroup import android.view.ViewGroup
import android.support.v4.view.ViewCompat.setFitsSystemWindows import androidx.core.view.ViewCompat.setFitsSystemWindows
import android.app.Activity import android.app.Activity
import android.view.WindowManager import android.view.WindowManager
import android.os.Build import android.os.Build
......
package com.example.gengmei_flutter_plugin.utils; package com.example.gengmei_flutter_plugin.utils;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.text.TextUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/** /**
* @author lsy * @author lsy
* @date 2020-02-26 * @date 2020-02-26
*/ */
public class PhotoBitmapUtils { public class PhotoBitmapUtils {
/**
* 读取图片的旋转的角度
*
* @param path 图片绝对路径
* @return 图片的旋转角度
*/
public static int getBitmapDegree(String path) {
int degree = 0;//被旋转的角度
try {
// 从指定路径下读取图片,并获取其EXIF信息
ExifInterface exifInterface = new ExifInterface(path);
// 获取图片的旋转信息
int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270;
break;
}
} catch (IOException e) {
e.printStackTrace();
}
return degree;
}
/**
* 将图片按照某个角度进行旋转
*
* @param degree 旋转角度
* @return 旋转后的图片
*/
public static boolean rotateBitmapByDegree(String filePath, int degree) {
File file = new File(filePath);
if (!file.exists()) {
return false;
}
Bitmap bm = BitmapFactory.decodeFile(filePath);
Bitmap returnBm = null;
FileOutputStream fos = null;
// 根据旋转角度,生成旋转矩阵
Matrix matrix = new Matrix();
matrix.postRotate(degree);
try {
// 将原始图片按照旋转矩阵进行旋转,并得到新的图片
returnBm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
fos = new FileOutputStream(file);
returnBm.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
} catch (OutOfMemoryError e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fos != null) {
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
} }
...@@ -562,9 +562,9 @@ PHImageRequestOptions *baseImageRequestOption; ...@@ -562,9 +562,9 @@ PHImageRequestOptions *baseImageRequestOption;
if([[self.scanMap allKeys] containsObject:path]){ if([[self.scanMap allKeys] containsObject:path]){
PHAsset * assets=self.scanMap[path]; PHAsset * assets=self.scanMap[path];
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init]; PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
options.version = PHImageRequestOptionsVersionCurrent; // options.version = PHImageRequestOptionsVersionCurrent;
options.networkAccessAllowed = true; options.networkAccessAllowed = true;
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic; // options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
[[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) { [[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
AVURLAsset *urlAsset = (AVURLAsset *)asset; AVURLAsset *urlAsset = (AVURLAsset *)asset;
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTempVideo] :[NSString stringWithFormat:@"%@",urlAsset.URL]]; [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTempVideo] :[NSString stringWithFormat:@"%@",urlAsset.URL]];
......
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
dispatch_async(self.queue, ^{ dispatch_async(self.queue, ^{
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init]; PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
// options.version = PHImageRequestOptionsVersionCurrent; options.version = PHImageRequestOptionsVersionCurrent;
options.networkAccessAllowed = true; options.networkAccessAllowed = true;
// options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic; options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
[[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) { [[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
AVURLAsset *urlAsset = (AVURLAsset *)asset; AVURLAsset *urlAsset = (AVURLAsset *)asset;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment