Commit 732b57d5 authored by 林生雨's avatar 林生雨

coomit

parent 9e406c65
...@@ -5,12 +5,7 @@ ...@@ -5,12 +5,7 @@
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="Show only selected application" /> <option name="TOOL_WINDOW_CONFIGURED_FILTER" value="Show only selected application" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="5be6bbb5-7d6e-4540-a24f-d2b3bf78b3ba" name="Default Changelist" comment=""> <list default="true" id="5be6bbb5-7d6e-4540-a24f-d2b3bf78b3ba" name="Default Changelist" comment="" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/ios/Classes/GengmeiFlutterPlugin.m" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/ios/Classes/GengmeiFlutterPlugin.m" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/.dart_tool/" /> <ignored path="$PROJECT_DIR$/.dart_tool/" />
<ignored path="$PROJECT_DIR$/.idea/" /> <ignored path="$PROJECT_DIR$/.idea/" />
<ignored path="$PROJECT_DIR$/.pub/" /> <ignored path="$PROJECT_DIR$/.pub/" />
...@@ -106,8 +101,8 @@ ...@@ -106,8 +101,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"> <entry file="file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="11616"> <state relative-caret-position="11506">
<caret line="549" column="22" selection-start-line="549" selection-start-column="22" selection-end-line="549" selection-end-column="22" /> <caret line="544" column="22" selection-start-line="544" selection-start-column="22" selection-end-line="544" selection-end-column="22" />
</state> </state>
</provider> </provider>
</entry> </entry>
...@@ -188,7 +183,8 @@ ...@@ -188,7 +183,8 @@
</option> </option>
</component> </component>
<component name="ProjectFrameBounds" extendedState="6"> <component name="ProjectFrameBounds" extendedState="6">
<option name="y" value="35" /> <option name="x" value="-33" />
<option name="y" value="23" />
<option name="width" value="1440" /> <option name="width" value="1440" />
<option name="height" value="811" /> <option name="height" value="811" />
</component> </component>
...@@ -306,8 +302,9 @@ ...@@ -306,8 +302,9 @@
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="9" y="23" width="1440" height="811" extended-state="6" /> <frame x="9" y="23" width="1440" height="811" extended-state="6" />
<editor active="true" />
<layout> <layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.19742489" /> <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.19742489" />
<window_info id="Captures" order="1" side_tool="true" /> <window_info id="Captures" order="1" side_tool="true" />
<window_info id="Structure" order="2" side_tool="true" /> <window_info id="Structure" order="2" side_tool="true" />
<window_info id="Image Layers" order="3" /> <window_info id="Image Layers" order="3" />
...@@ -322,7 +319,7 @@ ...@@ -322,7 +319,7 @@
<window_info anchor="bottom" id="Android Profiler" order="3" show_stripe_button="false" /> <window_info anchor="bottom" id="Android Profiler" order="3" show_stripe_button="false" />
<window_info anchor="bottom" id="Logcat" order="4" weight="0.4534075" /> <window_info anchor="bottom" id="Logcat" order="4" weight="0.4534075" />
<window_info anchor="bottom" id="Debug" order="5" /> <window_info anchor="bottom" id="Debug" order="5" />
<window_info anchor="bottom" id="Terminal" order="6" visible="true" weight="0.29346314" /> <window_info active="true" anchor="bottom" id="Terminal" order="6" visible="true" weight="0.29346314" />
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" /> <window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
<window_info anchor="bottom" id="Flutter Performance" order="8" side_tool="true" /> <window_info anchor="bottom" id="Flutter Performance" order="8" side_tool="true" />
<window_info anchor="bottom" id="Version Control" order="9" /> <window_info anchor="bottom" id="Version Control" order="9" />
...@@ -534,8 +531,8 @@ ...@@ -534,8 +531,8 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"> <entry file="file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="11616"> <state relative-caret-position="11506">
<caret line="549" column="22" selection-start-line="549" selection-start-column="22" selection-end-line="549" selection-end-column="22" /> <caret line="544" column="22" selection-start-line="544" selection-start-column="22" selection-end-line="544" selection-end-column="22" />
</state> </state>
</provider> </provider>
</entry> </entry>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
@end @end
@implementation GengmeiFlutterPlugin @implementation GengmeiFlutterPlugin
dispatch_queue_t concurrentQueue;
FlutterEventSink _eventSink; FlutterEventSink _eventSink;
NSMutableArray<AlbumItem *> *assetCollectionList; NSMutableArray<AlbumItem *> *assetCollectionList;
UIViewController * viewController; UIViewController * viewController;
...@@ -43,7 +43,7 @@ NSString *cacheDirectory; ...@@ -43,7 +43,7 @@ NSString *cacheDirectory;
[registrar addMethodCallDelegate:instance channel:channel]; [registrar addMethodCallDelegate:instance channel:channel];
assetCollectionList = [NSMutableArray array]; assetCollectionList = [NSMutableArray array];
viewController =[UIApplication sharedApplication].delegate.window.rootViewController; viewController =[UIApplication sharedApplication].delegate.window.rootViewController;
// queue = dispatch_queue_create("com.gengmei_flutter_plugin", DISPATCH_QUEUE_CONCURRENT); concurrentQueue = dispatch_queue_create("com.gengmei_flutter_plugin", DISPATCH_QUEUE_CONCURRENT);
queue = dispatch_queue_create("com.gengmei_flutter_plugin", DISPATCH_QUEUE_SERIAL); queue = dispatch_queue_create("com.gengmei_flutter_plugin", DISPATCH_QUEUE_SERIAL);
FlutterEventChannel* chargingChannel = [FlutterEventChannel FlutterEventChannel* chargingChannel = [FlutterEventChannel
eventChannelWithName:@"gengmei_flutter_plugin_event" eventChannelWithName:@"gengmei_flutter_plugin_event"
...@@ -228,7 +228,7 @@ NSString *cacheDirectory; ...@@ -228,7 +228,7 @@ NSString *cacheDirectory;
NSArray<NSString*> *path=call.arguments; NSArray<NSString*> *path=call.arguments;
long resultTemp=self.resultKey; long resultTemp=self.resultKey;
if(path!=nil){ if(path!=nil){
dispatch_async(queue, ^{ dispatch_async(concurrentQueue, ^{
[self.channelList removeAllObjects]; [self.channelList removeAllObjects];
if(path.count==0){ if(path.count==0){
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
...@@ -285,37 +285,40 @@ NSString *cacheDirectory; ...@@ -285,37 +285,40 @@ NSString *cacheDirectory;
}); });
} }
}else{ }else{
int picWidth=[assets pixelWidth]; // int picWidth=[assets pixelWidth];
int picHeight=[assets pixelHeight]; // int picHeight=[assets pixelHeight];
float tempScareSize=1; // float tempScareSize=1;
float limit=1560.0; // float limit=1560.0;
float max=MAX(picWidth, picHeight); // float max=MAX(picWidth, picHeight);
if(max>limit){ // if(max>limit){
tempScareSize=limit/max; // tempScareSize=limit/max;
} // }
//
CGSize temp=CGSizeMake(picWidth*tempScareSize, picHeight*tempScareSize); // CGSize temp=CGSizeMake(picWidth*tempScareSize, picHeight*tempScareSize);
[[PHImageManager defaultManager] requestImageDataForAsset:assets options:imageRequestOption resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) { [[PHImageManager defaultManager] requestImageDataForAsset:assets options:imageRequestOption resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
// [[PHImageManager defaultManager] requestImageForAsset:assets targetSize:temp contentMode:PHImageContentModeDefault options:imageRequestOption resultHandler:^(UIImage * _Nullable res, NSDictionary * _Nullable info) { // [[PHImageManager defaultManager] requestImageForAsset:assets targetSize:temp contentMode:PHImageContentModeDefault options:imageRequestOption resultHandler:^(UIImage * _Nullable res, NSDictionary * _Nullable info) {
@autoreleasepool{
UIImage * res=[UIImage imageWithData:imageData]; dispatch_async(concurrentQueue, ^{
NSData *data = UIImageJPEGRepresentation(res, 0.8) ; @autoreleasepool{
[data writeToFile:tempTake atomically:YES]; UIImage * res=[UIImage imageWithData:imageData];
res=nil; NSData *data = UIImageJPEGRepresentation(res, 0.8) ;
data=nil; [data writeToFile:tempTake atomically:YES];
} res=nil;
NSMutableDictionary *dict=[[NSMutableDictionary alloc] init]; data=nil;
[dict setObject:path[i] forKey:@"path"]; }
[dict setObject:tempTake forKey:@"realImagePath"]; NSMutableDictionary *dict=[[NSMutableDictionary alloc] init];
@synchronized (self) { [dict setObject:path[i] forKey:@"path"];
self.channelSize++; [dict setObject:tempTake forKey:@"realImagePath"];
[self.channelList addObject:dict]; @synchronized (self) {
} self.channelSize++;
if(self.channelSize==self.channelAllSize){ [self.channelList addObject:dict];
dispatch_async(dispatch_get_main_queue(), ^{ }
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :self.channelList]; if(self.channelSize==self.channelAllSize){
}); dispatch_async(dispatch_get_main_queue(), ^{
} [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :self.channelList];
});
}
});
}]; }];
} }
} }
...@@ -341,6 +344,56 @@ NSString *cacheDirectory; ...@@ -341,6 +344,56 @@ NSString *cacheDirectory;
}else{ }else{
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :nil]; [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :nil];
} }
}else if([@"IOS_IMAGE_ITEM" isEqualToString:call.method]){
long resultTemp=self.resultKey;
NSString*path=call.arguments;
PHImageRequestOptions *imageRequestOption = [[PHImageRequestOptions alloc] init];
imageRequestOption.synchronous =NO;
imageRequestOption.networkAccessAllowed = YES;
imageRequestOption.deliveryMode=PHImageRequestOptionsDeliveryModeHighQualityFormat;
imageRequestOption.resizeMode=PHImageRequestOptionsResizeModeFast;
imageRequestOption.version=PHImageRequestOptionsVersionUnadjusted;
NSString *tempPath = NSTemporaryDirectory();
NSFileManager *fileManager = [NSFileManager defaultManager];
if([[self.scanMap allKeys] containsObject:path]){
NSString* tempTake= [tempPath stringByAppendingPathComponent:[path lastPathComponent]];
PHAsset * assets=self.scanMap[path];
if([fileManager fileExistsAtPath:tempTake]){
NSMutableDictionary *dict=[[NSMutableDictionary alloc] init];
[dict setObject:path forKey:@"path"];
[dict setObject:tempTake forKey:@"realImagePath"];
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :dict];
}else{
int picWidth=[assets pixelWidth];
int picHeight=[assets pixelHeight];
float tempScareSize=1;
float limit=1560.0;
float max=MAX(picWidth, picHeight);
if(max>limit){
tempScareSize=limit/max;
}
CGSize temp=CGSizeMake(picWidth*tempScareSize, picHeight*tempScareSize);
[[PHImageManager defaultManager] requestImageForAsset:assets targetSize:temp contentMode:PHImageContentModeDefault options:imageRequestOption resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
@autoreleasepool{
NSData *data = UIImageJPEGRepresentation(result, 0.8) ;
[data writeToFile:tempTake atomically:YES];
result=nil;
data=nil;
}
NSMutableDictionary *dict=[[NSMutableDictionary alloc] init];
[dict setObject:path forKey:@"path"];
[dict setObject:tempTake forKey:@"realImagePath"];
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :dict];
}];
}
}else if ([[self.takePhotoMap allKeys] containsObject:path]){
NSMutableDictionary *dict=[[NSMutableDictionary alloc] init];
[dict setObject:path forKey:@"path"];
[dict setObject:self.takePhotoMap[path] forKey:@"realImagePath"];
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :dict];
}else{
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :nil];
}
}else{ }else{
result(FlutterMethodNotImplemented); result(FlutterMethodNotImplemented);
} }
...@@ -625,8 +678,8 @@ CFAbsoluteTime startTime; ...@@ -625,8 +678,8 @@ CFAbsoluteTime startTime;
@autoreleasepool{ @autoreleasepool{
NSData *data = UIImageJPEGRepresentation(result, 0.8) ; NSData *data = UIImageJPEGRepresentation(result, 0.8) ;
[data writeToFile:tmpPath atomically:YES]; [data writeToFile:tmpPath atomically:YES];
data=nil; data=nil;
result=nil; result=nil;
} }
} }
NSMutableDictionary* queryItemDict = [NSMutableDictionary dictionary]; NSMutableDictionary* queryItemDict = [NSMutableDictionary dictionary];
......
...@@ -46,6 +46,11 @@ class ScanImagePlugn { ...@@ -46,6 +46,11 @@ class ScanImagePlugn {
MethodChannel channel, List<String> path) async { MethodChannel channel, List<String> path) async {
return await channel.invokeMethod("IOS_IMAGE_BY_PATH", path); return await channel.invokeMethod("IOS_IMAGE_BY_PATH", path);
} }
static Future<Map> ios_album_item(
MethodChannel channel, String path) async {
return await channel.invokeMethod("IOS_IMAGE_ITEM", path);
}
} }
class ScanImageItem { class ScanImageItem {
......
...@@ -27,6 +27,10 @@ class GengmeiFlutterPlugin { ...@@ -27,6 +27,10 @@ class GengmeiFlutterPlugin {
return await ScanImagePlugn.ios_album_path(_channel, path); return await ScanImagePlugn.ios_album_path(_channel, path);
} }
static Future<Map> ios_album_item(String path) async {
return await ScanImagePlugn.ios_album_item(_channel, path);
}
static Future<bool> quitPage() async { static Future<bool> quitPage() async {
return await ScanImagePlugn.quitPage(_channel); return await ScanImagePlugn.quitPage(_channel);
} }
......
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