From a69d21a46881bc1832d9a4f7ca04b03ae6cdecb8 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Wed, 13 Feb 2019 23:55:09 +0800 Subject: [PATCH 1/3] [iOS] Fix image wrong scale factor when load image from file system --- React/Base/RCTUtils.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/React/Base/RCTUtils.m b/React/Base/RCTUtils.m index 44e1e7fe5c1730..d0611303402bf8 100644 --- a/React/Base/RCTUtils.m +++ b/React/Base/RCTUtils.m @@ -708,13 +708,11 @@ BOOL RCTIsLocalAssetURL(NSURL *__nullable imageURL) if (!image) { // Attempt to load from the file system - NSData *fileData; - if (imageURL.pathExtension.length == 0) { - fileData = [NSData dataWithContentsOfURL:[imageURL URLByAppendingPathExtension:@"png"]]; - } else { - fileData = [NSData dataWithContentsOfURL:imageURL]; + NSString *filePath = imageURL.path; + if (filePath.pathExtension.length == 0) { + filePath = [filePath stringByAppendingPathExtension:@"png"]; } - image = [UIImage imageWithData:fileData]; + image = [UIImage imageWithContentsOfFile:filePath]; } if (!image && !bundle) { From 0b4319151ffd617341a8b116222580e1d6266bd7 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Thu, 14 Feb 2019 23:31:04 +0800 Subject: [PATCH 2/3] Add url file check --- React/Base/RCTUtils.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/React/Base/RCTUtils.m b/React/Base/RCTUtils.m index d0611303402bf8..2e065c70d2f45f 100644 --- a/React/Base/RCTUtils.m +++ b/React/Base/RCTUtils.m @@ -706,7 +706,7 @@ BOOL RCTIsLocalAssetURL(NSURL *__nullable imageURL) image = [UIImage imageNamed:imageName]; } - if (!image) { + if (!image && imageURL.isFileURL) { // Attempt to load from the file system NSString *filePath = imageURL.path; if (filePath.pathExtension.length == 0) { From aab095d2e5e503a032c51b1c41bcb510a8a3aaa0 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Fri, 15 Feb 2019 09:31:38 +0800 Subject: [PATCH 3/3] Add file system path check --- React/Base/RCTUtils.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/React/Base/RCTUtils.m b/React/Base/RCTUtils.m index 2e065c70d2f45f..37fff6a2a530e0 100644 --- a/React/Base/RCTUtils.m +++ b/React/Base/RCTUtils.m @@ -706,9 +706,9 @@ BOOL RCTIsLocalAssetURL(NSURL *__nullable imageURL) image = [UIImage imageNamed:imageName]; } - if (!image && imageURL.isFileURL) { + if (!image) { // Attempt to load from the file system - NSString *filePath = imageURL.path; + NSString *filePath = [NSString stringWithUTF8String:[imageURL fileSystemRepresentation]]; if (filePath.pathExtension.length == 0) { filePath = [filePath stringByAppendingPathExtension:@"png"]; }