Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
eeacf738
Unverified
提交
eeacf738
authored
11月 04, 2024
作者:
Alex Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🔥
Remove thumbnail and format files
上级
eb54b610
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
25 行增加
和
30 行删除
+25
-30
FluwxDelegate.m
ios/Classes/FluwxDelegate.m
+1
-2
FluwxPlugin.m
ios/Classes/FluwxPlugin.m
+0
-0
FluwxStringUtil.m
ios/Classes/FluwxStringUtil.m
+1
-8
ThumbnailHelper.h
ios/Classes/ThumbnailHelper.h
+2
-1
ThumbnailHelper.m
ios/Classes/ThumbnailHelper.m
+20
-19
FluwxDelegate.h
ios/Classes/public/FluwxDelegate.h
+1
-0
没有找到文件。
ios/Classes/FluwxDelegate.m
浏览文件 @
eeacf738
...
@@ -20,9 +20,8 @@
...
@@ -20,9 +20,8 @@
return
instance
;
return
instance
;
}
}
-
(
void
)
registerWxAPI
:
(
NSString
*
)
appId
universalLink
:
(
NSString
*
)
universalLink
{
-
(
void
)
registerWxAPI
:
(
NSString
*
)
appId
universalLink
:
(
NSString
*
)
universalLink
{
[
WXApi
registerApp
:
appId
universalLink
:
universalLink
];
[
WXApi
registerApp
:
appId
universalLink
:
universalLink
];
}
}
@end
@end
ios/Classes/FluwxPlugin.m
浏览文件 @
eeacf738
差异被折叠。
点击展开。
ios/Classes/FluwxStringUtil.m
浏览文件 @
eeacf738
...
@@ -8,24 +8,17 @@
...
@@ -8,24 +8,17 @@
@implementation
FluwxStringUtil
@implementation
FluwxStringUtil
+
(
BOOL
)
isBlank
:(
NSString
*
)
string
{
+
(
BOOL
)
isBlank
:(
NSString
*
)
string
{
if
(
string
==
nil
)
{
if
(
string
==
nil
)
{
return
YES
;
return
YES
;
}
}
if
([
string
isKindOfClass
:[
NSNull
class
]])
{
if
([
string
isKindOfClass
:[
NSNull
class
]])
{
return
YES
;
return
YES
;
}
}
return
[[
string
stringByTrimmingCharactersInSet
:[
NSCharacterSet
whitespaceCharacterSet
]]
length
]
==
0
;
return
[[
string
stringByTrimmingCharactersInSet
:[
NSCharacterSet
whitespaceCharacterSet
]]
length
]
==
0
;
}
}
+
(
NSString
*
)
nilToEmpty
:(
NSString
*
)
string
{
+
(
NSString
*
)
nilToEmpty
:(
NSString
*
)
string
{
return
string
==
nil
?
@""
:
string
;
return
string
==
nil
?
@""
:
string
;
}
}
@end
@end
ios/Classes/ThumbnailHelper.h
浏览文件 @
eeacf738
...
@@ -6,11 +6,12 @@
...
@@ -6,11 +6,12 @@
@interface
ThumbnailHelper
:
NSObject
@interface
ThumbnailHelper
:
NSObject
+
(
UIImage
*
)
compressImage
:(
UIImage
*
)
image
toByte
:(
NSUInteger
)
maxLength
isPNG
:(
BOOL
)
isPNG
;
+
(
UIImage
*
)
compressImage
:(
UIImage
*
)
image
toByte
:(
NSUInteger
)
maxLength
isPNG
:(
BOOL
)
isPNG
;
/// NSData 压缩后转NSData
/// NSData 压缩后转NSData
/// @param imageData 来源data
/// @param imageData 来源data
/// @param maxLength 压缩目标值,压缩结果在maxLength的0.9~1之间
/// @param maxLength 压缩目标值,压缩结果在maxLength的0.9~1之间
+
(
NSData
*
)
compressImageData
:(
NSData
*
)
imageData
toByte
:(
NSUInteger
)
maxLength
;
+
(
NSData
*
)
compressImageData
:(
NSData
*
)
imageData
toByte
:(
NSUInteger
)
maxLength
;
@end
@end
ios/Classes/ThumbnailHelper.m
浏览文件 @
eeacf738
...
@@ -11,9 +11,9 @@
...
@@ -11,9 +11,9 @@
// Compress by quality
// Compress by quality
CGFloat
compression
=
1
;
CGFloat
compression
=
1
;
NSData
*
data
=
imageData
;
NSData
*
data
=
imageData
;
NSLog
(
@"压缩前 %lu
%lu "
,
(
unsigned
long
)
data
.
length
,
maxLength
);
NSLog
(
@"压缩前 %lu
%lu"
,
(
unsigned
long
)
data
.
length
,
maxLength
);
if
(
data
.
length
<
maxLength
)
return
data
;
if
(
data
.
length
<
maxLength
)
return
data
;
UIImage
*
image
=
[
UIImage
imageWithData
:
imageData
];
UIImage
*
image
=
[
UIImage
imageWithData
:
imageData
];
CGFloat
max
=
1
;
CGFloat
max
=
1
;
CGFloat
min
=
0
;
CGFloat
min
=
0
;
...
@@ -29,20 +29,20 @@
...
@@ -29,20 +29,20 @@
}
}
}
}
NSLog
(
@"压缩第一次 %lu
%lu "
,
(
unsigned
long
)
data
.
length
,
maxLength
);
NSLog
(
@"压缩第一次 %lu
%lu"
,
(
unsigned
long
)
data
.
length
,
maxLength
);
if
(
data
.
length
<
maxLength
)
return
data
;
if
(
data
.
length
<
maxLength
)
return
data
;
UIImage
*
resultImage
;
UIImage
*
resultImage
;
resultImage
=
[
UIImage
imageWithData
:
data
];
resultImage
=
[
UIImage
imageWithData
:
data
];
// Compress by size
// Compress by size
NSUInteger
lastDataLength
=
0
;
NSUInteger
lastDataLength
=
0
;
while
(
data
.
length
>
maxLength
&&
data
.
length
!=
lastDataLength
)
{
while
(
data
.
length
>
maxLength
&&
data
.
length
!=
lastDataLength
)
{
lastDataLength
=
data
.
length
;
lastDataLength
=
data
.
length
;
CGFloat
ratio
=
(
CGFloat
)
maxLength
/
data
.
length
;
CGFloat
ratio
=
(
CGFloat
)
maxLength
/
data
.
length
;
CGSize
size
=
CGSizeMake
((
NSUInteger
)
(
resultImage
.
size
.
width
*
sqrtf
(
ratio
)),
CGSize
size
=
CGSizeMake
((
NSUInteger
)
(
resultImage
.
size
.
width
*
sqrtf
(
ratio
)),
(
NSUInteger
)
(
resultImage
.
size
.
height
*
sqrtf
(
ratio
)));
// Use NSUInteger to prevent white blank
(
NSUInteger
)
(
resultImage
.
size
.
height
*
sqrtf
(
ratio
)));
// Use NSUInteger to prevent white blank
UIGraphicsBeginImageContext
(
size
);
UIGraphicsBeginImageContext
(
size
);
[
resultImage
drawInRect
:
CGRectMake
(
0
,
0
,
size
.
width
,
size
.
height
)];
[
resultImage
drawInRect
:
CGRectMake
(
0
,
0
,
size
.
width
,
size
.
height
)];
resultImage
=
UIGraphicsGetImageFromCurrentImageContext
();
resultImage
=
UIGraphicsGetImageFromCurrentImageContext
();
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
data
=
UIImageJPEGRepresentation
(
resultImage
,
compression
);
data
=
UIImageJPEGRepresentation
(
resultImage
,
compression
);
}
}
NSLog
(
@"压缩第二次
%lu %lu "
,
(
unsigned
long
)
data
.
length
,
maxLength
);
NSLog
(
@"压缩第二次
%lu %lu"
,
(
unsigned
long
)
data
.
length
,
maxLength
);
return
data
;
return
data
;
}
}
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
CGFloat
compression
=
1
;
CGFloat
compression
=
1
;
NSData
*
data
=
UIImageJPEGRepresentation
(
image
,
compression
);
NSData
*
data
=
UIImageJPEGRepresentation
(
image
,
compression
);
if
(
data
.
length
<
maxLength
)
return
image
;
if
(
data
.
length
<
maxLength
)
return
image
;
CGFloat
max
=
1
;
CGFloat
max
=
1
;
CGFloat
min
=
0
;
CGFloat
min
=
0
;
for
(
int
i
=
0
;
i
<
6
;
++
i
)
{
for
(
int
i
=
0
;
i
<
6
;
++
i
)
{
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
break
;
break
;
}
}
}
}
UIImage
*
resultImage
;
UIImage
*
resultImage
;
if
(
isPNG
)
{
if
(
isPNG
)
{
NSData
*
tmp
=
UIImagePNGRepresentation
([
UIImage
imageWithData
:
data
]);
NSData
*
tmp
=
UIImagePNGRepresentation
([
UIImage
imageWithData
:
data
]);
...
@@ -81,24 +81,24 @@
...
@@ -81,24 +81,24 @@
}
else
{
}
else
{
resultImage
=
[
UIImage
imageWithData
:
data
];
resultImage
=
[
UIImage
imageWithData
:
data
];
}
}
if
(
data
.
length
<
maxLength
)
return
resultImage
;
if
(
data
.
length
<
maxLength
)
return
resultImage
;
// Compress by size
// Compress by size
NSUInteger
lastDataLength
=
0
;
NSUInteger
lastDataLength
=
0
;
while
(
data
.
length
>
maxLength
&&
data
.
length
!=
lastDataLength
)
{
while
(
data
.
length
>
maxLength
&&
data
.
length
!=
lastDataLength
)
{
lastDataLength
=
data
.
length
;
lastDataLength
=
data
.
length
;
CGFloat
ratio
=
(
CGFloat
)
maxLength
/
data
.
length
;
CGFloat
ratio
=
(
CGFloat
)
maxLength
/
data
.
length
;
CGSize
size
=
CGSizeMake
((
NSUInteger
)
(
resultImage
.
size
.
width
*
sqrtf
(
ratio
)),
CGSize
size
=
CGSizeMake
((
NSUInteger
)
(
resultImage
.
size
.
width
*
sqrtf
(
ratio
)),
(
NSUInteger
)
(
resultImage
.
size
.
height
*
sqrtf
(
ratio
)));
// Use NSUInteger to prevent white blank
(
NSUInteger
)
(
resultImage
.
size
.
height
*
sqrtf
(
ratio
)));
// Use NSUInteger to prevent white blank
UIGraphicsBeginImageContext
(
size
);
UIGraphicsBeginImageContext
(
size
);
[
resultImage
drawInRect
:
CGRectMake
(
0
,
0
,
size
.
width
,
size
.
height
)];
[
resultImage
drawInRect
:
CGRectMake
(
0
,
0
,
size
.
width
,
size
.
height
)];
resultImage
=
UIGraphicsGetImageFromCurrentImageContext
();
resultImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
UIGraphicsEndImageContext
();
data
=
UIImageJPEGRepresentation
(
resultImage
,
compression
);
data
=
UIImageJPEGRepresentation
(
resultImage
,
compression
);
}
}
return
resultImage
;
return
resultImage
;
}
}
...
@@ -107,27 +107,28 @@
...
@@ -107,27 +107,28 @@
CGSize
imageSize
=
image
.
size
;
CGSize
imageSize
=
image
.
size
;
CGFloat
width
=
imageSize
.
width
;
CGFloat
width
=
imageSize
.
width
;
CGFloat
height
=
imageSize
.
height
;
CGFloat
height
=
imageSize
.
height
;
if
(
width
<=
newSize
.
width
&&
height
<=
newSize
.
height
)
{
if
(
width
<=
newSize
.
width
&&
height
<=
newSize
.
height
)
{
return
image
;
return
image
;
}
}
if
(
width
==
0
||
height
==
0
)
{
if
(
width
==
0
||
height
==
0
)
{
return
image
;
return
image
;
}
}
CGFloat
widthFactor
=
newSize
.
width
/
width
;
CGFloat
widthFactor
=
newSize
.
width
/
width
;
CGFloat
heightFactor
=
newSize
.
height
/
height
;
CGFloat
heightFactor
=
newSize
.
height
/
height
;
CGFloat
scaleFactor
=
(
widthFactor
<
heightFactor
?
widthFactor
:
heightFactor
);
CGFloat
scaleFactor
=
(
widthFactor
<
heightFactor
?
widthFactor
:
heightFactor
);
CGFloat
scaledWidth
=
width
*
scaleFactor
;
CGFloat
scaledWidth
=
width
*
scaleFactor
;
CGFloat
scaledHeight
=
height
*
scaleFactor
;
CGFloat
scaledHeight
=
height
*
scaleFactor
;
CGSize
targetSize
=
CGSizeMake
(
scaledWidth
,
scaledHeight
);
CGSize
targetSize
=
CGSizeMake
(
scaledWidth
,
scaledHeight
);
UIGraphicsBeginImageContext
(
targetSize
);
UIGraphicsBeginImageContext
(
targetSize
);
[
image
drawInRect
:
CGRectMake
(
0
,
0
,
scaledWidth
,
scaledHeight
)];
[
image
drawInRect
:
CGRectMake
(
0
,
0
,
scaledWidth
,
scaledHeight
)];
UIImage
*
newImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIImage
*
newImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
UIGraphicsEndImageContext
();
return
newImage
;
return
newImage
;
}
}
@end
@end
ios/Classes/public/FluwxDelegate.h
浏览文件 @
eeacf738
...
@@ -15,4 +15,5 @@
...
@@ -15,4 +15,5 @@
+
(
instancetype
)
defaultManager
;
+
(
instancetype
)
defaultManager
;
-
(
void
)
registerWxAPI
:(
NSString
*
)
appId
universalLink
:(
NSString
*
)
universalLink
;
-
(
void
)
registerWxAPI
:(
NSString
*
)
appId
universalLink
:(
NSString
*
)
universalLink
;
@end
@end
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论