Compare commits
3 Commits
7fa3229123
...
dea2c7a3ee
Author | SHA1 | Date |
---|---|---|
|
dea2c7a3ee | |
|
e22c1184f4 | |
|
47738431c9 |
|
@ -1,5 +1,9 @@
|
||||||
|
## 3.0.1-rc.1
|
||||||
|
- 新增ImageKnifeAnimatorComponent控制动图组件
|
||||||
|
- 修复部分heif图无法解码
|
||||||
|
|
||||||
## 3.0.1-rc.0
|
## 3.0.1-rc.0
|
||||||
- 文件缓存设置最大缓存数量改为无上限
|
- 文件缓存设置最大缓存数量改为无限制
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
- 修复图形变换的闪退问题
|
- 修复图形变换的闪退问题
|
||||||
|
|
25
README.md
25
README.md
|
@ -255,7 +255,29 @@ ImageKnifeComponent({
|
||||||
},syncLoad:true
|
},syncLoad:true
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
#### 10.ImageKnifeAnimatorComponent 示例
|
||||||
|
```
|
||||||
|
ImageKnifeAnimatorComponent({
|
||||||
|
imageKnifeOption:{
|
||||||
|
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
|
||||||
|
placeholderSrc:$r('app.media.loading'),
|
||||||
|
errorholderSrc:$r('app.media.failed')
|
||||||
|
},animatorOption:this.animatorOption
|
||||||
|
}).width(300).height(300).backgroundColor(Color.Orange).margin({top:30})
|
||||||
|
```
|
||||||
## 接口说明
|
## 接口说明
|
||||||
|
### ImageKnife组件
|
||||||
|
| 组件名称 | 入参内容 | 功能简介 |
|
||||||
|
|-----------------------------|---------------------------------|--------|
|
||||||
|
| ImageKnifeComponent | ImageKnifeOption | 图片显示组件 |
|
||||||
|
| ImageKnifeAnimatorComponent | ImageKnifeOption、AnimatorOption | 动图控制组件 |
|
||||||
|
|
||||||
|
### AnimatorOption参数列表
|
||||||
|
| 参数名称 | 入参内容 | 功能简介 |
|
||||||
|
|-----------------------|-------------------------------------------------------|----------|
|
||||||
|
| state | AnimationStatus | 播放状态(可选) |
|
||||||
|
| iterations | number | 播放次数(可选) |
|
||||||
|
| reverse | boolean | 播放顺序(可选) |
|
||||||
|
|
||||||
### ImageKnifeOption参数列表
|
### ImageKnifeOption参数列表
|
||||||
|
|
||||||
|
@ -342,4 +364,5 @@ DevEco Studio 5.0 Canary3(5.0.3.221)--SDK:API12
|
||||||
|
|
||||||
## 遗留问题
|
## 遗留问题
|
||||||
|
|
||||||
- 添加组件闪动问题
|
- ImageKnifeAnimator组件无法设置ImageFit属性
|
||||||
|
- ImageKnifeAnimator组件设置border属性无法将图片变为圆角
|
|
@ -12,21 +12,21 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { IEngineKey, ImageKnifeOption, PixelMapTransformation,SparkMD5 ,ImageKnifeRequestSource} from '@ohos/libraryimageknife';
|
import { IEngineKey, ImageKnifeOption, PixelMapTransformation ,MD5Tools,ImageKnifeRequestSource} from '@ohos/libraryimageknife';
|
||||||
|
|
||||||
//全局自定义key demo
|
//全局自定义key demo
|
||||||
@Sendable
|
@Sendable
|
||||||
export class CustomEngineKeyImpl implements IEngineKey {
|
export class CustomEngineKeyImpl implements IEngineKey {
|
||||||
// 生成内存缓存key
|
// 生成内存缓存key
|
||||||
generateMemoryKey(loadSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,
|
generateMemoryKey(loadSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,
|
||||||
imageKnifeOption: ImageKnifeOption, width?: number, height?: number): string {
|
imageKnifeOption: ImageKnifeOption,isAnimator?: boolean, width?: number, height?: number): string {
|
||||||
let key = ""
|
let key = ""
|
||||||
if(imageKnifeOption.signature == "aaa" && typeof loadSrc == "string") {
|
if(imageKnifeOption.signature == "aaa" && typeof loadSrc == "string") {
|
||||||
let num = loadSrc.indexOf("?")
|
let num = loadSrc.indexOf("?")
|
||||||
let src = loadSrc.substring(0,num)
|
let src = loadSrc.substring(0,num)
|
||||||
key = "loadSrc=" + src
|
key = "loadSrc=" + src
|
||||||
} else {
|
} else {
|
||||||
key = "loadSrc=" + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
key = (isAnimator == true ? "Animator=" : "loadSrc==") + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
||||||
}
|
}
|
||||||
if (requestSource === ImageKnifeRequestSource.SRC) {
|
if (requestSource === ImageKnifeRequestSource.SRC) {
|
||||||
if (imageKnifeOption.signature !== undefined && imageKnifeOption.signature !== "") {
|
if (imageKnifeOption.signature !== undefined && imageKnifeOption.signature !== "") {
|
||||||
|
@ -40,19 +40,19 @@ export class CustomEngineKeyImpl implements IEngineKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成文件缓存key
|
// 生成文件缓存key
|
||||||
generateFileKey(loadSrc: string | PixelMap | Resource, signature?: string): string {
|
generateFileKey(loadSrc: string | PixelMap | Resource, signature?: string,isAnimator?: boolean): string {
|
||||||
let src = ""
|
let src = ""
|
||||||
if(signature == "aaa" && typeof loadSrc == "string") {
|
if(signature == "aaa" && typeof loadSrc == "string") {
|
||||||
let num = loadSrc.indexOf("?")
|
let num = loadSrc.indexOf("?")
|
||||||
let key = loadSrc.substring(0,num)
|
let key = loadSrc.substring(0,num)
|
||||||
src = "loadSrc=" + key
|
src = "loadSrc=" + key
|
||||||
} else {
|
} else {
|
||||||
src = "loadSrc=" + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
src = (isAnimator == true ? "Animator=" : "loadSrc==") + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
||||||
}
|
}
|
||||||
if (signature !== undefined && signature !== "") {
|
if (signature !== undefined && signature !== "") {
|
||||||
src += "signature=" + signature + ";"
|
src += "signature=" + signature + ";"
|
||||||
}
|
}
|
||||||
return SparkMD5.hashBinary(src)
|
return MD5Tools.md5Sync(src)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTransformation(transformation: PixelMapTransformation): string {
|
private getTransformation(transformation: PixelMapTransformation): string {
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
import { AnimatorOption, ImageKnifeAnimatorComponent } from "@ohos/libraryimageknife"
|
||||||
|
|
||||||
|
@Entry
|
||||||
|
@Component
|
||||||
|
struct ImageAnimatorPage {
|
||||||
|
@State animatorOption: AnimatorOption = {
|
||||||
|
state: AnimationStatus.Running,
|
||||||
|
iterations: -1
|
||||||
|
}
|
||||||
|
build() {
|
||||||
|
Column(){
|
||||||
|
Flex(){
|
||||||
|
Button("播放").onClick(()=>{
|
||||||
|
this.animatorOption.state = AnimationStatus.Running
|
||||||
|
})
|
||||||
|
Button("暂停").onClick(()=>{
|
||||||
|
this.animatorOption.state = AnimationStatus.Paused
|
||||||
|
})
|
||||||
|
Button("停止").onClick(()=>{
|
||||||
|
this.animatorOption.state = AnimationStatus.Stopped
|
||||||
|
})
|
||||||
|
Button("无限循环").onClick(()=>{
|
||||||
|
this.animatorOption.iterations = -1
|
||||||
|
})
|
||||||
|
Button("播放一次").onClick(()=>{
|
||||||
|
this.animatorOption.iterations = 1
|
||||||
|
})
|
||||||
|
Button("播放两次").onClick(()=>{
|
||||||
|
this.animatorOption.iterations = 2
|
||||||
|
})
|
||||||
|
}
|
||||||
|
ImageKnifeAnimatorComponent({
|
||||||
|
imageKnifeOption:{
|
||||||
|
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
|
||||||
|
placeholderSrc:$r('app.media.loading'),
|
||||||
|
errorholderSrc:$r('app.media.failed')
|
||||||
|
},animatorOption:this.animatorOption
|
||||||
|
}).width(300).height(300).backgroundColor(Color.Orange).margin({top:30})
|
||||||
|
}.width("100%").height("100%")
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,10 +26,14 @@ struct Index {
|
||||||
build() {
|
build() {
|
||||||
Scroll(){
|
Scroll(){
|
||||||
Column() {
|
Column() {
|
||||||
Button("测试加载多张相同图片").onClick(()=>{
|
Button("测试ImageAnimator组件").onClick(()=>{
|
||||||
|
router.push({
|
||||||
|
uri: 'pages/ImageAnimatorPage',
|
||||||
|
});
|
||||||
|
})
|
||||||
|
Button("测试加载多张相同图片").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/TestCommonImage',
|
uri: 'pages/TestCommonImage',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button("测试HSP场景预加载").margin({top:10}).onClick(()=>{
|
Button("测试HSP场景预加载").margin({top:10}).onClick(()=>{
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
"pages/TestHspPreLoadImage",
|
"pages/TestHspPreLoadImage",
|
||||||
"pages/TestRemoveCache",
|
"pages/TestRemoveCache",
|
||||||
"pages/dataShareUriLoadPage",
|
"pages/dataShareUriLoadPage",
|
||||||
"pages/TestCommonImage"
|
"pages/TestCommonImage",
|
||||||
|
"pages/ImageAnimatorPage"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -18,6 +18,8 @@ import Constants from '../../../main/ets/common/Constants';
|
||||||
import taskpool from '@ohos.taskpool';
|
import taskpool from '@ohos.taskpool';
|
||||||
import { GlobalContext } from '../../../main/ets/common/GlobalContext';
|
import { GlobalContext } from '../../../main/ets/common/GlobalContext';
|
||||||
import { FileCache } from '@ohos/imageknife/src/main/ets/utils/FileCache';
|
import { FileCache } from '@ohos/imageknife/src/main/ets/utils/FileCache';
|
||||||
|
import { IEngineKey, ImageKnifeOption } from '@ohos/imageknife';
|
||||||
|
import { DefaultEngineKey } from '@ohos/imageknife/src/main/ets/key/DefaultEngineKey';
|
||||||
|
|
||||||
|
|
||||||
export default function FileLruCacheTest() {
|
export default function FileLruCacheTest() {
|
||||||
|
@ -149,6 +151,15 @@ export default function FileLruCacheTest() {
|
||||||
fileCache.put(JSON.stringify("xxxxx"),buf)
|
fileCache.put(JSON.stringify("xxxxx"),buf)
|
||||||
expect(fileCache.get(JSON.stringify("xxxxx"))?.byteLength).assertEqual(1024 * 1024)
|
expect(fileCache.get(JSON.stringify("xxxxx"))?.byteLength).assertEqual(1024 * 1024)
|
||||||
});
|
});
|
||||||
|
it('fileCacheEngineKey', 0, () => {
|
||||||
|
let engineKey: IEngineKey = new DefaultEngineKey()
|
||||||
|
let imageKnifeOption: ImageKnifeOption = {
|
||||||
|
loadSrc:"abc"
|
||||||
|
}
|
||||||
|
let imageKey = engineKey.generateFileKey(imageKnifeOption.loadSrc,"")
|
||||||
|
let imageAnimatorKey = engineKey.generateFileKey(imageKnifeOption.loadSrc,"",true)
|
||||||
|
expect(imageKey == imageAnimatorKey).assertFalse()
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ import image from '@ohos.multimedia.image';
|
||||||
import Constants from '../../../main/ets/common/Constants';
|
import Constants from '../../../main/ets/common/Constants';
|
||||||
import { MemoryLruCache } from '@ohos/imageknife/src/main/ets/utils/MemoryLruCache';
|
import { MemoryLruCache } from '@ohos/imageknife/src/main/ets/utils/MemoryLruCache';
|
||||||
import { ImageKnifeData } from '@ohos/imageknife/src/main/ets/model/ImageKnifeData';
|
import { ImageKnifeData } from '@ohos/imageknife/src/main/ets/model/ImageKnifeData';
|
||||||
|
import { IEngineKey, ImageKnifeOption,ImageKnifeRequestSource } from '@ohos/imageknife';
|
||||||
|
import { DefaultEngineKey } from '@ohos/imageknife/src/main/ets/key/DefaultEngineKey';
|
||||||
|
|
||||||
|
|
||||||
export default function MemoryLruCacheTest() {
|
export default function MemoryLruCacheTest() {
|
||||||
|
@ -118,6 +120,16 @@ export default function MemoryLruCacheTest() {
|
||||||
expect(memoryCache.get("ccc")).assertEqual(data)
|
expect(memoryCache.get("ccc")).assertEqual(data)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('memoryCacheEngineKey', 0, () => {
|
||||||
|
let engineKey: IEngineKey = new DefaultEngineKey()
|
||||||
|
let imageKnifeOption: ImageKnifeOption = {
|
||||||
|
loadSrc:"abc"
|
||||||
|
}
|
||||||
|
let imageKey = engineKey.generateMemoryKey(imageKnifeOption.loadSrc,ImageKnifeRequestSource.SRC,imageKnifeOption)
|
||||||
|
let imageAnimatorKey = engineKey.generateMemoryKey(imageKnifeOption.loadSrc,ImageKnifeRequestSource.SRC,imageKnifeOption,true)
|
||||||
|
expect(imageKey == imageAnimatorKey).assertFalse()
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
*/
|
*/
|
||||||
export { ImageKnifeComponent } from './src/main/ets/components/ImageKnifeComponent'
|
export { ImageKnifeComponent } from './src/main/ets/components/ImageKnifeComponent'
|
||||||
|
|
||||||
|
export { ImageKnifeAnimatorComponent } from './src/main/ets/components/ImageKnifeAnimatorComponent'
|
||||||
|
|
||||||
export { ImageKnife } from './src/main/ets/ImageKnife'
|
export { ImageKnife } from './src/main/ets/ImageKnife'
|
||||||
|
|
||||||
export { ImageKnifeOption } from './src/main/ets/ImageKnifeOption'
|
export { ImageKnifeOption , AnimatorOption } from './src/main/ets/ImageKnifeOption'
|
||||||
|
|
||||||
export { ImageKnifeRequest } from './src/main/ets/ImageKnifeRequest'
|
export { ImageKnifeRequest } from './src/main/ets/ImageKnifeRequest'
|
||||||
|
|
||||||
|
@ -36,7 +38,7 @@ export { BrightnessTransformation } from './src/main/ets/transform/BrightnessTra
|
||||||
|
|
||||||
export { BlurTransformation } from './src/main/ets/transform/BlurTransformation'
|
export { BlurTransformation } from './src/main/ets/transform/BlurTransformation'
|
||||||
|
|
||||||
export { SparkMD5 } from "./src/main/ets/3rd_party/sparkmd5/spark-md5"
|
export { MD5Tools } from "./src/main/ets/utils/MD5Tools"
|
||||||
|
|
||||||
export { GrayScaleTransformation } from './src/main/ets/transform/GrayScaleTransformation'
|
export { GrayScaleTransformation } from './src/main/ets/transform/GrayScaleTransformation'
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"main": "index.ets",
|
"main": "index.ets",
|
||||||
"repository": "https://gitee.com/openharmony-tpc/ImageKnife",
|
"repository": "https://gitee.com/openharmony-tpc/ImageKnife",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "3.0.1-rc.0",
|
"version": "3.0.1-rc.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ohos/gpu_transform": "^1.0.2"
|
"@ohos/gpu_transform": "^1.0.2"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,741 +0,0 @@
|
||||||
import buffer from '@ohos.buffer';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fastest md5 implementation around (JKM md5).
|
|
||||||
* Credits: Joseph Myers
|
|
||||||
*
|
|
||||||
* @see http://www.myersdaily.org/joseph/javascript/md5-text.html
|
|
||||||
* @see http://jsperf.com/md5-shootout/7
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* this function is much faster,
|
|
||||||
so if possible we use it. Some IEs
|
|
||||||
are the only ones I know of that
|
|
||||||
need the idiotic second function,
|
|
||||||
generated by an if clause. */
|
|
||||||
var add32 = function (a, b) {
|
|
||||||
return (a + b) & 0xFFFFFFFF;
|
|
||||||
},
|
|
||||||
hex_chr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
|
|
||||||
|
|
||||||
|
|
||||||
function cmn(q, a, b, x, s, t) {
|
|
||||||
a = add32(add32(a, q), add32(x, t));
|
|
||||||
return add32((a << s) | (a >>> (32 - s)), b);
|
|
||||||
}
|
|
||||||
|
|
||||||
function md5cycle(x, k) {
|
|
||||||
var a = x[0],
|
|
||||||
b = x[1],
|
|
||||||
c = x[2],
|
|
||||||
d = x[3];
|
|
||||||
|
|
||||||
a += (b & c | ~b & d) + k[0] - 680876936 | 0;
|
|
||||||
a = (a << 7 | a >>> 25) + b | 0;
|
|
||||||
d += (a & b | ~a & c) + k[1] - 389564586 | 0;
|
|
||||||
d = (d << 12 | d >>> 20) + a | 0;
|
|
||||||
c += (d & a | ~d & b) + k[2] + 606105819 | 0;
|
|
||||||
c = (c << 17 | c >>> 15) + d | 0;
|
|
||||||
b += (c & d | ~c & a) + k[3] - 1044525330 | 0;
|
|
||||||
b = (b << 22 | b >>> 10) + c | 0;
|
|
||||||
a += (b & c | ~b & d) + k[4] - 176418897 | 0;
|
|
||||||
a = (a << 7 | a >>> 25) + b | 0;
|
|
||||||
d += (a & b | ~a & c) + k[5] + 1200080426 | 0;
|
|
||||||
d = (d << 12 | d >>> 20) + a | 0;
|
|
||||||
c += (d & a | ~d & b) + k[6] - 1473231341 | 0;
|
|
||||||
c = (c << 17 | c >>> 15) + d | 0;
|
|
||||||
b += (c & d | ~c & a) + k[7] - 45705983 | 0;
|
|
||||||
b = (b << 22 | b >>> 10) + c | 0;
|
|
||||||
a += (b & c | ~b & d) + k[8] + 1770035416 | 0;
|
|
||||||
a = (a << 7 | a >>> 25) + b | 0;
|
|
||||||
d += (a & b | ~a & c) + k[9] - 1958414417 | 0;
|
|
||||||
d = (d << 12 | d >>> 20) + a | 0;
|
|
||||||
c += (d & a | ~d & b) + k[10] - 42063 | 0;
|
|
||||||
c = (c << 17 | c >>> 15) + d | 0;
|
|
||||||
b += (c & d | ~c & a) + k[11] - 1990404162 | 0;
|
|
||||||
b = (b << 22 | b >>> 10) + c | 0;
|
|
||||||
a += (b & c | ~b & d) + k[12] + 1804603682 | 0;
|
|
||||||
a = (a << 7 | a >>> 25) + b | 0;
|
|
||||||
d += (a & b | ~a & c) + k[13] - 40341101 | 0;
|
|
||||||
d = (d << 12 | d >>> 20) + a | 0;
|
|
||||||
c += (d & a | ~d & b) + k[14] - 1502002290 | 0;
|
|
||||||
c = (c << 17 | c >>> 15) + d | 0;
|
|
||||||
b += (c & d | ~c & a) + k[15] + 1236535329 | 0;
|
|
||||||
b = (b << 22 | b >>> 10) + c | 0;
|
|
||||||
|
|
||||||
a += (b & d | c & ~d) + k[1] - 165796510 | 0;
|
|
||||||
a = (a << 5 | a >>> 27) + b | 0;
|
|
||||||
d += (a & c | b & ~c) + k[6] - 1069501632 | 0;
|
|
||||||
d = (d << 9 | d >>> 23) + a | 0;
|
|
||||||
c += (d & b | a & ~b) + k[11] + 643717713 | 0;
|
|
||||||
c = (c << 14 | c >>> 18) + d | 0;
|
|
||||||
b += (c & a | d & ~a) + k[0] - 373897302 | 0;
|
|
||||||
b = (b << 20 | b >>> 12) + c | 0;
|
|
||||||
a += (b & d | c & ~d) + k[5] - 701558691 | 0;
|
|
||||||
a = (a << 5 | a >>> 27) + b | 0;
|
|
||||||
d += (a & c | b & ~c) + k[10] + 38016083 | 0;
|
|
||||||
d = (d << 9 | d >>> 23) + a | 0;
|
|
||||||
c += (d & b | a & ~b) + k[15] - 660478335 | 0;
|
|
||||||
c = (c << 14 | c >>> 18) + d | 0;
|
|
||||||
b += (c & a | d & ~a) + k[4] - 405537848 | 0;
|
|
||||||
b = (b << 20 | b >>> 12) + c | 0;
|
|
||||||
a += (b & d | c & ~d) + k[9] + 568446438 | 0;
|
|
||||||
a = (a << 5 | a >>> 27) + b | 0;
|
|
||||||
d += (a & c | b & ~c) + k[14] - 1019803690 | 0;
|
|
||||||
d = (d << 9 | d >>> 23) + a | 0;
|
|
||||||
c += (d & b | a & ~b) + k[3] - 187363961 | 0;
|
|
||||||
c = (c << 14 | c >>> 18) + d | 0;
|
|
||||||
b += (c & a | d & ~a) + k[8] + 1163531501 | 0;
|
|
||||||
b = (b << 20 | b >>> 12) + c | 0;
|
|
||||||
a += (b & d | c & ~d) + k[13] - 1444681467 | 0;
|
|
||||||
a = (a << 5 | a >>> 27) + b | 0;
|
|
||||||
d += (a & c | b & ~c) + k[2] - 51403784 | 0;
|
|
||||||
d = (d << 9 | d >>> 23) + a | 0;
|
|
||||||
c += (d & b | a & ~b) + k[7] + 1735328473 | 0;
|
|
||||||
c = (c << 14 | c >>> 18) + d | 0;
|
|
||||||
b += (c & a | d & ~a) + k[12] - 1926607734 | 0;
|
|
||||||
b = (b << 20 | b >>> 12) + c | 0;
|
|
||||||
|
|
||||||
a += (b ^ c ^ d) + k[5] - 378558 | 0;
|
|
||||||
a = (a << 4 | a >>> 28) + b | 0;
|
|
||||||
d += (a ^ b ^ c) + k[8] - 2022574463 | 0;
|
|
||||||
d = (d << 11 | d >>> 21) + a | 0;
|
|
||||||
c += (d ^ a ^ b) + k[11] + 1839030562 | 0;
|
|
||||||
c = (c << 16 | c >>> 16) + d | 0;
|
|
||||||
b += (c ^ d ^ a) + k[14] - 35309556 | 0;
|
|
||||||
b = (b << 23 | b >>> 9) + c | 0;
|
|
||||||
a += (b ^ c ^ d) + k[1] - 1530992060 | 0;
|
|
||||||
a = (a << 4 | a >>> 28) + b | 0;
|
|
||||||
d += (a ^ b ^ c) + k[4] + 1272893353 | 0;
|
|
||||||
d = (d << 11 | d >>> 21) + a | 0;
|
|
||||||
c += (d ^ a ^ b) + k[7] - 155497632 | 0;
|
|
||||||
c = (c << 16 | c >>> 16) + d | 0;
|
|
||||||
b += (c ^ d ^ a) + k[10] - 1094730640 | 0;
|
|
||||||
b = (b << 23 | b >>> 9) + c | 0;
|
|
||||||
a += (b ^ c ^ d) + k[13] + 681279174 | 0;
|
|
||||||
a = (a << 4 | a >>> 28) + b | 0;
|
|
||||||
d += (a ^ b ^ c) + k[0] - 358537222 | 0;
|
|
||||||
d = (d << 11 | d >>> 21) + a | 0;
|
|
||||||
c += (d ^ a ^ b) + k[3] - 722521979 | 0;
|
|
||||||
c = (c << 16 | c >>> 16) + d | 0;
|
|
||||||
b += (c ^ d ^ a) + k[6] + 76029189 | 0;
|
|
||||||
b = (b << 23 | b >>> 9) + c | 0;
|
|
||||||
a += (b ^ c ^ d) + k[9] - 640364487 | 0;
|
|
||||||
a = (a << 4 | a >>> 28) + b | 0;
|
|
||||||
d += (a ^ b ^ c) + k[12] - 421815835 | 0;
|
|
||||||
d = (d << 11 | d >>> 21) + a | 0;
|
|
||||||
c += (d ^ a ^ b) + k[15] + 530742520 | 0;
|
|
||||||
c = (c << 16 | c >>> 16) + d | 0;
|
|
||||||
b += (c ^ d ^ a) + k[2] - 995338651 | 0;
|
|
||||||
b = (b << 23 | b >>> 9) + c | 0;
|
|
||||||
|
|
||||||
a += (c ^ (b | ~d)) + k[0] - 198630844 | 0;
|
|
||||||
a = (a << 6 | a >>> 26) + b | 0;
|
|
||||||
d += (b ^ (a | ~c)) + k[7] + 1126891415 | 0;
|
|
||||||
d = (d << 10 | d >>> 22) + a | 0;
|
|
||||||
c += (a ^ (d | ~b)) + k[14] - 1416354905 | 0;
|
|
||||||
c = (c << 15 | c >>> 17) + d | 0;
|
|
||||||
b += (d ^ (c | ~a)) + k[5] - 57434055 | 0;
|
|
||||||
b = (b << 21 | b >>> 11) + c | 0;
|
|
||||||
a += (c ^ (b | ~d)) + k[12] + 1700485571 | 0;
|
|
||||||
a = (a << 6 | a >>> 26) + b | 0;
|
|
||||||
d += (b ^ (a | ~c)) + k[3] - 1894986606 | 0;
|
|
||||||
d = (d << 10 | d >>> 22) + a | 0;
|
|
||||||
c += (a ^ (d | ~b)) + k[10] - 1051523 | 0;
|
|
||||||
c = (c << 15 | c >>> 17) + d | 0;
|
|
||||||
b += (d ^ (c | ~a)) + k[1] - 2054922799 | 0;
|
|
||||||
b = (b << 21 | b >>> 11) + c | 0;
|
|
||||||
a += (c ^ (b | ~d)) + k[8] + 1873313359 | 0;
|
|
||||||
a = (a << 6 | a >>> 26) + b | 0;
|
|
||||||
d += (b ^ (a | ~c)) + k[15] - 30611744 | 0;
|
|
||||||
d = (d << 10 | d >>> 22) + a | 0;
|
|
||||||
c += (a ^ (d | ~b)) + k[6] - 1560198380 | 0;
|
|
||||||
c = (c << 15 | c >>> 17) + d | 0;
|
|
||||||
b += (d ^ (c | ~a)) + k[13] + 1309151649 | 0;
|
|
||||||
b = (b << 21 | b >>> 11) + c | 0;
|
|
||||||
a += (c ^ (b | ~d)) + k[4] - 145523070 | 0;
|
|
||||||
a = (a << 6 | a >>> 26) + b | 0;
|
|
||||||
d += (b ^ (a | ~c)) + k[11] - 1120210379 | 0;
|
|
||||||
d = (d << 10 | d >>> 22) + a | 0;
|
|
||||||
c += (a ^ (d | ~b)) + k[2] + 718787259 | 0;
|
|
||||||
c = (c << 15 | c >>> 17) + d | 0;
|
|
||||||
b += (d ^ (c | ~a)) + k[9] - 343485551 | 0;
|
|
||||||
b = (b << 21 | b >>> 11) + c | 0;
|
|
||||||
|
|
||||||
x[0] = a + x[0] | 0;
|
|
||||||
x[1] = b + x[1] | 0;
|
|
||||||
x[2] = c + x[2] | 0;
|
|
||||||
x[3] = d + x[3] | 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function md5blk(s) {
|
|
||||||
var md5blks = [],
|
|
||||||
i; /* Andy King said do it this way. */
|
|
||||||
|
|
||||||
for (i = 0; i < 64; i += 4) {
|
|
||||||
md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24);
|
|
||||||
}
|
|
||||||
return md5blks;
|
|
||||||
}
|
|
||||||
|
|
||||||
function md5blk_array(a) {
|
|
||||||
var md5blks = [],
|
|
||||||
i; /* Andy King said do it this way. */
|
|
||||||
|
|
||||||
for (i = 0; i < 64; i += 4) {
|
|
||||||
md5blks[i >> 2] = a[i] + (a[i + 1] << 8) + (a[i + 2] << 16) + (a[i + 3] << 24);
|
|
||||||
}
|
|
||||||
return md5blks;
|
|
||||||
}
|
|
||||||
|
|
||||||
function md51(s) {
|
|
||||||
var n = s.length,
|
|
||||||
state = [1732584193, -271733879, -1732584194, 271733878],
|
|
||||||
i,
|
|
||||||
length,
|
|
||||||
tail,
|
|
||||||
tmp,
|
|
||||||
lo,
|
|
||||||
hi;
|
|
||||||
|
|
||||||
for (i = 64; i <= n; i += 64) {
|
|
||||||
md5cycle(state, md5blk(s.substring(i - 64, i)));
|
|
||||||
}
|
|
||||||
s = s.substring(i - 64);
|
|
||||||
length = s.length;
|
|
||||||
tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
||||||
for (i = 0; i < length; i += 1) {
|
|
||||||
tail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3);
|
|
||||||
}
|
|
||||||
tail[i >> 2] |= 0x80 << ((i % 4) << 3);
|
|
||||||
if (i > 55) {
|
|
||||||
md5cycle(state, tail);
|
|
||||||
for (i = 0; i < 16; i += 1) {
|
|
||||||
tail[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Beware that the final length might not fit in 32 bits so we take care of that
|
|
||||||
tmp = n * 8;
|
|
||||||
tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
|
|
||||||
lo = parseInt(tmp[2], 16);
|
|
||||||
hi = parseInt(tmp[1], 16) || 0;
|
|
||||||
|
|
||||||
tail[14] = lo;
|
|
||||||
tail[15] = hi;
|
|
||||||
|
|
||||||
md5cycle(state, tail);
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function md51_array(a) {
|
|
||||||
var n = a.length,
|
|
||||||
state = [1732584193, -271733879, -1732584194, 271733878],
|
|
||||||
i,
|
|
||||||
length,
|
|
||||||
tail,
|
|
||||||
tmp,
|
|
||||||
lo,
|
|
||||||
hi;
|
|
||||||
|
|
||||||
for (i = 64; i <= n; i += 64) {
|
|
||||||
md5cycle(state, md5blk_array(a.subarray(i - 64, i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not sure if it is a bug, however IE10 will always produce a sub array of length 1
|
|
||||||
// containing the last element of the parent array if the sub array specified starts
|
|
||||||
// beyond the length of the parent array - weird.
|
|
||||||
// https://connect.microsoft.com/IE/feedback/details/771452/typed-array-subarray-issue
|
|
||||||
a = (i - 64) < n ? a.subarray(i - 64) : new Uint8Array(0);
|
|
||||||
|
|
||||||
length = a.length;
|
|
||||||
tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
||||||
for (i = 0; i < length; i += 1) {
|
|
||||||
tail[i >> 2] |= a[i] << ((i % 4) << 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
tail[i >> 2] |= 0x80 << ((i % 4) << 3);
|
|
||||||
if (i > 55) {
|
|
||||||
md5cycle(state, tail);
|
|
||||||
for (i = 0; i < 16; i += 1) {
|
|
||||||
tail[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Beware that the final length might not fit in 32 bits so we take care of that
|
|
||||||
tmp = n * 8;
|
|
||||||
tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
|
|
||||||
lo = parseInt(tmp[2], 16);
|
|
||||||
hi = parseInt(tmp[1], 16) || 0;
|
|
||||||
|
|
||||||
tail[14] = lo;
|
|
||||||
tail[15] = hi;
|
|
||||||
|
|
||||||
md5cycle(state, tail);
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function rhex(n) {
|
|
||||||
var s = '',
|
|
||||||
j;
|
|
||||||
for (j = 0; j < 4; j += 1) {
|
|
||||||
s += hex_chr[(n >> (j * 8 + 4)) & 0x0F] + hex_chr[(n >> (j * 8)) & 0x0F];
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hex(x) {
|
|
||||||
var i;
|
|
||||||
for (i = 0; i < x.length; i += 1) {
|
|
||||||
x[i] = rhex(x[i]);
|
|
||||||
}
|
|
||||||
return x.join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
// In some cases the fast add32 function cannot be used..
|
|
||||||
if (hex(md51('hello')) !== '5d41402abc4b2a76b9719d911017c592') {
|
|
||||||
add32 = function (x, y) {
|
|
||||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF),
|
|
||||||
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
||||||
return (msw << 16) | (lsw & 0xFFFF);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ArrayBuffer slice polyfill.
|
|
||||||
*
|
|
||||||
* @see https://github.com/ttaubert/node-arraybuffer-slice
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) {
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
function clamp(val, length) {
|
|
||||||
val = (val | 0) || 0;
|
|
||||||
|
|
||||||
if (val < 0) {
|
|
||||||
return Math.max(val + length, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.min(val, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayBuffer.prototype.slice = function (from, to) {
|
|
||||||
var length = this.byteLength,
|
|
||||||
begin = clamp(from, length),
|
|
||||||
end = length,
|
|
||||||
num,
|
|
||||||
target,
|
|
||||||
targetArray,
|
|
||||||
sourceArray;
|
|
||||||
|
|
||||||
if (to !== undefined) {
|
|
||||||
end = clamp(to, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (begin > end) {
|
|
||||||
return new ArrayBuffer(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
num = end - begin;
|
|
||||||
target = new ArrayBuffer(num);
|
|
||||||
targetArray = new Uint8Array(target);
|
|
||||||
|
|
||||||
sourceArray = new Uint8Array(this, begin, num);
|
|
||||||
targetArray.set(sourceArray);
|
|
||||||
|
|
||||||
return target;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helpers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function toUtf8(str) {
|
|
||||||
if (/[\u0080-\uFFFF]/.test(str)) {
|
|
||||||
// 源码是str = unescape(encodeURIComponent(str));这里的API并不对等
|
|
||||||
buffer.from(str).toString("utf-8")
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function utf8Str2ArrayBuffer(str, returnUInt8Array) {
|
|
||||||
var length = str.length,
|
|
||||||
buff = new ArrayBuffer(length),
|
|
||||||
arr = new Uint8Array(buff),
|
|
||||||
i;
|
|
||||||
|
|
||||||
for (i = 0; i < length; i += 1) {
|
|
||||||
arr[i] = str.charCodeAt(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnUInt8Array ? arr : buff;
|
|
||||||
}
|
|
||||||
|
|
||||||
function arrayBuffer2Utf8Str(buff) {
|
|
||||||
return String.fromCharCode.apply(null, new Uint8Array(buff));
|
|
||||||
}
|
|
||||||
|
|
||||||
function concatenateArrayBuffers(first, second, returnUInt8Array) {
|
|
||||||
var result = new Uint8Array(first.byteLength + second.byteLength);
|
|
||||||
|
|
||||||
result.set(new Uint8Array(first));
|
|
||||||
result.set(new Uint8Array(second), first.byteLength);
|
|
||||||
|
|
||||||
return returnUInt8Array ? result : result.buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hexToBinaryString(hex) {
|
|
||||||
var bytes = [],
|
|
||||||
length = hex.length,
|
|
||||||
x;
|
|
||||||
|
|
||||||
for (x = 0; x < length - 1; x += 2) {
|
|
||||||
bytes.push(parseInt(hex.substr(x, 2), 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
return String.fromCharCode.apply(String, bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SparkMD5 OOP implementation.
|
|
||||||
*
|
|
||||||
* Use this class to perform an incremental md5, otherwise use the
|
|
||||||
* static methods instead.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function SparkMD5() {
|
|
||||||
// call reset to init the instance
|
|
||||||
this.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends a string.
|
|
||||||
* A conversion will be applied if an utf8 string is detected.
|
|
||||||
*
|
|
||||||
* @param {String} str The string to be appended
|
|
||||||
*
|
|
||||||
* @return {SparkMD5} The instance itself
|
|
||||||
*/
|
|
||||||
SparkMD5.prototype.append = function (str) {
|
|
||||||
// Converts the string to utf8 bytes if necessary
|
|
||||||
// Then append as binary
|
|
||||||
this.appendBinary(toUtf8(str));
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends a binary string.
|
|
||||||
*
|
|
||||||
* @param {String} contents The binary string to be appended
|
|
||||||
*
|
|
||||||
* @return {SparkMD5} The instance itself
|
|
||||||
*/
|
|
||||||
SparkMD5.prototype.appendBinary = function (contents) {
|
|
||||||
this._buff += contents;
|
|
||||||
this._length += contents.length;
|
|
||||||
|
|
||||||
var length = this._buff.length,
|
|
||||||
i;
|
|
||||||
|
|
||||||
for (i = 64; i <= length; i += 64) {
|
|
||||||
md5cycle(this._hash, md5blk(this._buff.substring(i - 64, i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
this._buff = this._buff.substring(i - 64);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finishes the incremental computation, reseting the internal state and
|
|
||||||
* returning the result.
|
|
||||||
*
|
|
||||||
* @param {Boolean} raw True to get the raw string, false to get the hex string
|
|
||||||
*
|
|
||||||
* @return {String} The result
|
|
||||||
*/
|
|
||||||
SparkMD5.prototype.end = function (raw) {
|
|
||||||
var buff = this._buff,
|
|
||||||
length = buff.length,
|
|
||||||
i,
|
|
||||||
tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
ret;
|
|
||||||
|
|
||||||
for (i = 0; i < length; i += 1) {
|
|
||||||
tail[i >> 2] |= buff.charCodeAt(i) << ((i % 4) << 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._finish(tail, length);
|
|
||||||
ret = hex(this._hash);
|
|
||||||
|
|
||||||
if (raw) {
|
|
||||||
ret = hexToBinaryString(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.reset();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the internal state of the computation.
|
|
||||||
*
|
|
||||||
* @return {SparkMD5} The instance itself
|
|
||||||
*/
|
|
||||||
SparkMD5.prototype.reset = function () {
|
|
||||||
this._buff = '';
|
|
||||||
this._length = 0;
|
|
||||||
this._hash = [1732584193, -271733879, -1732584194, 271733878];
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the internal state of the computation.
|
|
||||||
*
|
|
||||||
* @return {Object} The state
|
|
||||||
*/
|
|
||||||
SparkMD5.prototype.getState = function () {
|
|
||||||
return {
|
|
||||||
buff: this._buff,
|
|
||||||
length: this._length,
|
|
||||||
hash: this._hash.slice()
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the internal state of the computation.
|
|
||||||
*
|
|
||||||
* @param {Object} state The state
|
|
||||||
*
|
|
||||||
* @return {SparkMD5} The instance itself
|
|
||||||
*/
|
|
||||||
SparkMD5.prototype.setState = function (state) {
|
|
||||||
this._buff = state.buff;
|
|
||||||
this._length = state.length;
|
|
||||||
this._hash = state.hash;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Releases memory used by the incremental buffer and other additional
|
|
||||||
* resources. If you plan to use the instance again, use reset instead.
|
|
||||||
*/
|
|
||||||
SparkMD5.prototype.destroy = function () {
|
|
||||||
delete this._hash;
|
|
||||||
delete this._buff;
|
|
||||||
delete this._length;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finish the final calculation based on the tail.
|
|
||||||
*
|
|
||||||
* @param {Array} tail The tail (will be modified)
|
|
||||||
* @param {Number} length The length of the remaining buffer
|
|
||||||
*/
|
|
||||||
SparkMD5.prototype._finish = function (tail, length) {
|
|
||||||
var i = length,
|
|
||||||
tmp,
|
|
||||||
lo,
|
|
||||||
hi;
|
|
||||||
|
|
||||||
tail[i >> 2] |= 0x80 << ((i % 4) << 3);
|
|
||||||
if (i > 55) {
|
|
||||||
md5cycle(this._hash, tail);
|
|
||||||
for (i = 0; i < 16; i += 1) {
|
|
||||||
tail[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do the final computation based on the tail and length
|
|
||||||
// Beware that the final length may not fit in 32 bits so we take care of that
|
|
||||||
tmp = this._length * 8;
|
|
||||||
tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
|
|
||||||
lo = parseInt(tmp[2], 16);
|
|
||||||
hi = parseInt(tmp[1], 16) || 0;
|
|
||||||
|
|
||||||
tail[14] = lo;
|
|
||||||
tail[15] = hi;
|
|
||||||
md5cycle(this._hash, tail);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs the md5 hash on a string.
|
|
||||||
* A conversion will be applied if utf8 string is detected.
|
|
||||||
*
|
|
||||||
* @param {String} str The string
|
|
||||||
* @param {Boolean} [raw] True to get the raw string, false to get the hex string
|
|
||||||
*
|
|
||||||
* @return {String} The result
|
|
||||||
*/
|
|
||||||
SparkMD5.hash = function (str, raw) {
|
|
||||||
// Converts the string to utf8 bytes if necessary
|
|
||||||
// Then compute it using the binary function
|
|
||||||
return SparkMD5.hashBinary(toUtf8(str), raw);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs the md5 hash on a binary string.
|
|
||||||
*
|
|
||||||
* @param {String} content The binary string
|
|
||||||
* @param {Boolean} [raw] True to get the raw string, false to get the hex string
|
|
||||||
*
|
|
||||||
* @return {String} The result
|
|
||||||
*/
|
|
||||||
SparkMD5.hashBinary = function (content, raw) {
|
|
||||||
var hash = md51(content),
|
|
||||||
ret = hex(hash);
|
|
||||||
|
|
||||||
return raw ? hexToBinaryString(ret) : ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ---------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SparkMD5 OOP implementation for array buffers.
|
|
||||||
*
|
|
||||||
* Use this class to perform an incremental md5 ONLY for array buffers.
|
|
||||||
*/
|
|
||||||
SparkMD5.ArrayBuffer = function () {
|
|
||||||
// call reset to init the instance
|
|
||||||
this.reset();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends an array buffer.
|
|
||||||
*
|
|
||||||
* @param {ArrayBuffer} arr The array to be appended
|
|
||||||
*
|
|
||||||
* @return {SparkMD5.ArrayBuffer} The instance itself
|
|
||||||
*/
|
|
||||||
SparkMD5.ArrayBuffer.prototype.append = function (arr) {
|
|
||||||
// @ts-ignore
|
|
||||||
var buff = concatenateArrayBuffers(this._buff.buffer, arr, true),
|
|
||||||
// @ts-ignore
|
|
||||||
length = buff.length,
|
|
||||||
i;
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
this._length += arr.byteLength;
|
|
||||||
|
|
||||||
for (i = 64; i <= length; i += 64) {
|
|
||||||
// @ts-ignore
|
|
||||||
md5cycle(this._hash, md5blk_array(buff.subarray(i - 64, i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
this._buff = (i - 64) < length ? new Uint8Array(buff.buffer.slice(i - 64)) : new Uint8Array(0);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finishes the incremental computation, reseting the internal state and
|
|
||||||
* returning the result.
|
|
||||||
*
|
|
||||||
* @param {Boolean} raw True to get the raw string, false to get the hex string
|
|
||||||
*
|
|
||||||
* @return {String} The result
|
|
||||||
*/
|
|
||||||
SparkMD5.ArrayBuffer.prototype.end = function (raw) {
|
|
||||||
// @ts-ignore
|
|
||||||
var buff = this._buff,
|
|
||||||
length = buff.length,
|
|
||||||
tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
i,
|
|
||||||
ret;
|
|
||||||
|
|
||||||
for (i = 0; i < length; i += 1) {
|
|
||||||
tail[i >> 2] |= buff[i] << ((i % 4) << 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._finish(tail, length);
|
|
||||||
// @ts-ignore
|
|
||||||
ret = hex(this._hash);
|
|
||||||
|
|
||||||
if (raw) {
|
|
||||||
ret = hexToBinaryString(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.reset();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the internal state of the computation.
|
|
||||||
*
|
|
||||||
* @return {SparkMD5.ArrayBuffer} The instance itself
|
|
||||||
*/
|
|
||||||
SparkMD5.ArrayBuffer.prototype.reset = function () {
|
|
||||||
// @ts-ignore
|
|
||||||
this._buff = new Uint8Array(0);
|
|
||||||
// @ts-ignore
|
|
||||||
this._length = 0;
|
|
||||||
// @ts-ignore
|
|
||||||
this._hash = [1732584193, -271733879, -1732584194, 271733878];
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the internal state of the computation.
|
|
||||||
*
|
|
||||||
* @return {Object} The state
|
|
||||||
*/
|
|
||||||
SparkMD5.ArrayBuffer.prototype.getState = function () {
|
|
||||||
var state = SparkMD5.prototype.getState.call(this);
|
|
||||||
|
|
||||||
// Convert buffer to a string
|
|
||||||
state.buff = arrayBuffer2Utf8Str(state.buff);
|
|
||||||
|
|
||||||
return state;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the internal state of the computation.
|
|
||||||
*
|
|
||||||
* @param {Object} state The state
|
|
||||||
*
|
|
||||||
* @return {SparkMD5.ArrayBuffer} The instance itself
|
|
||||||
*/
|
|
||||||
SparkMD5.ArrayBuffer.prototype.setState = function (state) {
|
|
||||||
// Convert string to buffer
|
|
||||||
state.buff = utf8Str2ArrayBuffer(state.buff, true);
|
|
||||||
|
|
||||||
return SparkMD5.prototype.setState.call(this, state);
|
|
||||||
};
|
|
||||||
|
|
||||||
SparkMD5.ArrayBuffer.prototype.destroy = SparkMD5.prototype.destroy;
|
|
||||||
|
|
||||||
SparkMD5.ArrayBuffer.prototype._finish = SparkMD5.prototype._finish;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs the md5 hash on an array buffer.
|
|
||||||
*
|
|
||||||
* @param {ArrayBuffer} arr The array buffer
|
|
||||||
* @param {Boolean} [raw] True to get the raw string, false to get the hex one
|
|
||||||
*
|
|
||||||
* @return {String} The result
|
|
||||||
*/
|
|
||||||
SparkMD5.ArrayBuffer.hash = function (arr, raw) {
|
|
||||||
var hash = md51_array(new Uint8Array(arr)),
|
|
||||||
ret = hex(hash);
|
|
||||||
|
|
||||||
return raw ? hexToBinaryString(ret) : ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
export { SparkMD5 }
|
|
||||||
|
|
|
@ -364,12 +364,12 @@ export class ImageKnife {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(request: ImageKnifeRequest): Promise<void> {
|
async execute(request: ImageKnifeRequest,isAnimator?: boolean): Promise<void> {
|
||||||
LogUtil.log("ImageKnife_DataTime_execute.start:"+request.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_execute.start:"+request.imageKnifeOption.loadSrc)
|
||||||
if (this.headerMap.size > 0) {
|
if (this.headerMap.size > 0) {
|
||||||
request.addHeaderMap(this.headerMap)
|
request.addHeaderMap(this.headerMap)
|
||||||
}
|
}
|
||||||
this.dispatcher.enqueue(request)
|
this.dispatcher.enqueue(request,isAnimator)
|
||||||
LogUtil.log("ImageKnife_DataTime_execute.end:"+request.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_execute.end:"+request.imageKnifeOption.loadSrc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ export class ImageKnifeDispatcher {
|
||||||
// 开发者可配置全局缓存
|
// 开发者可配置全局缓存
|
||||||
private engineKey: IEngineKey = new DefaultEngineKey();
|
private engineKey: IEngineKey = new DefaultEngineKey();
|
||||||
|
|
||||||
showFromMemomry(request: ImageKnifeRequest, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource): boolean {
|
showFromMemomry(request: ImageKnifeRequest, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,isAnimator?: boolean): boolean {
|
||||||
LogUtil.log("ImageKnife_DataTime_showFromMemomry.start:" + request.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_showFromMemomry.start:" + request.imageKnifeOption.loadSrc)
|
||||||
let memoryCache: ImageKnifeData | undefined;
|
let memoryCache: ImageKnifeData | undefined;
|
||||||
if ((typeof (request.imageKnifeOption.loadSrc as image.PixelMap).isEditable) == 'boolean') {
|
if ((typeof (request.imageKnifeOption.loadSrc as image.PixelMap).isEditable) == 'boolean') {
|
||||||
|
@ -62,7 +62,7 @@ export class ImageKnifeDispatcher {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
memoryCache = ImageKnife.getInstance()
|
memoryCache = ImageKnife.getInstance()
|
||||||
.loadFromMemoryCache(this.engineKey.generateMemoryKey(imageSrc, requestSource, request.imageKnifeOption));
|
.loadFromMemoryCache(this.engineKey.generateMemoryKey(imageSrc, requestSource, request.imageKnifeOption,isAnimator));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ export class ImageKnifeDispatcher {
|
||||||
LogUtil.log("ImageKnife_DataTime_MemoryCache_onLoadStart:" + request.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_MemoryCache_onLoadStart:" + request.imageKnifeOption.loadSrc)
|
||||||
}
|
}
|
||||||
LogUtil.log("ImageKnife_DataTime_MemoryCache_showPixelMap.start:" + request.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_MemoryCache_showPixelMap.start:" + request.imageKnifeOption.loadSrc)
|
||||||
request.ImageKnifeRequestCallback?.showPixelMap(request.componentVersion, memoryCache.source, requestSource)
|
request.ImageKnifeRequestCallback?.showPixelMap(request.componentVersion, memoryCache.source, requestSource,memoryCache.imageAnimator)
|
||||||
LogUtil.log("ImageKnife_DataTime_MemoryCache_showPixelMap.end:" + request.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_MemoryCache_showPixelMap.end:" + request.imageKnifeOption.loadSrc)
|
||||||
|
|
||||||
if (requestSource == ImageKnifeRequestSource.SRC) {
|
if (requestSource == ImageKnifeRequestSource.SRC) {
|
||||||
|
@ -97,10 +97,10 @@ export class ImageKnifeDispatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enqueue(request: ImageKnifeRequest): void {
|
enqueue(request: ImageKnifeRequest,isAnimator?: boolean): void {
|
||||||
|
|
||||||
//1.内存有的话直接渲染
|
//1.内存有的话直接渲染
|
||||||
if (this.showFromMemomry(request, request.imageKnifeOption.loadSrc, ImageKnifeRequestSource.SRC)) {
|
if (this.showFromMemomry(request, request.imageKnifeOption.loadSrc, ImageKnifeRequestSource.SRC,isAnimator)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 2.内存获取占位图
|
// 2.内存获取占位图
|
||||||
|
@ -114,10 +114,10 @@ export class ImageKnifeDispatcher {
|
||||||
this.jobQueue.add(request)
|
this.jobQueue.add(request)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.executeJob(request)
|
this.executeJob(request,isAnimator)
|
||||||
}
|
}
|
||||||
|
|
||||||
executeJob(request: ImageKnifeRequest): void {
|
executeJob(request: ImageKnifeRequest,isAnimator?: boolean): void {
|
||||||
LogUtil.log("ImageKnife_DataTime_executeJob.start:" + request.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_executeJob.start:" + request.imageKnifeOption.loadSrc)
|
||||||
// 加载占位符
|
// 加载占位符
|
||||||
if (request.imageKnifeOption.placeholderSrc !== undefined && request.drawPlayHolderSuccess == false) {
|
if (request.imageKnifeOption.placeholderSrc !== undefined && request.drawPlayHolderSuccess == false) {
|
||||||
|
@ -125,16 +125,16 @@ export class ImageKnifeDispatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载主图
|
// 加载主图
|
||||||
this.getAndShowImage(request, request.imageKnifeOption.loadSrc, ImageKnifeRequestSource.SRC)
|
this.getAndShowImage(request, request.imageKnifeOption.loadSrc, ImageKnifeRequestSource.SRC,isAnimator)
|
||||||
LogUtil.log("ImageKnife_DataTime_executeJob.end:" + request.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_executeJob.end:" + request.imageKnifeOption.loadSrc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取和显示图片
|
* 获取和显示图片
|
||||||
*/
|
*/
|
||||||
getAndShowImage(currentRequest: ImageKnifeRequest, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource): void {
|
getAndShowImage(currentRequest: ImageKnifeRequest, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,isAnimator?: boolean): void {
|
||||||
LogUtil.log("ImageKnife_DataTime_getAndShowImage.start:" + currentRequest.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_getAndShowImage.start:" + currentRequest.imageKnifeOption.loadSrc)
|
||||||
let memoryKey: string = this.engineKey.generateMemoryKey(imageSrc, requestSource, currentRequest.imageKnifeOption)
|
let memoryKey: string = this.engineKey.generateMemoryKey(imageSrc, requestSource, currentRequest.imageKnifeOption,isAnimator)
|
||||||
let requestList: List<ImageKnifeRequestWithSource> | undefined = this.executingJobMap.get(memoryKey)
|
let requestList: List<ImageKnifeRequestWithSource> | undefined = this.executingJobMap.get(memoryKey)
|
||||||
if (requestList == undefined) {
|
if (requestList == undefined) {
|
||||||
requestList = new List()
|
requestList = new List()
|
||||||
|
@ -175,7 +175,8 @@ export class ImageKnifeDispatcher {
|
||||||
requestSource: requestSource,
|
requestSource: requestSource,
|
||||||
isWatchProgress: isWatchProgress,
|
isWatchProgress: isWatchProgress,
|
||||||
memoryKey: memoryKey,
|
memoryKey: memoryKey,
|
||||||
fileCacheFolder: ImageKnife.getInstance().getFileCache().getCacheFolder()
|
fileCacheFolder: ImageKnife.getInstance().getFileCache().getCacheFolder(),
|
||||||
|
isAnimator:isAnimator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,7 +193,7 @@ export class ImageKnifeDispatcher {
|
||||||
|
|
||||||
LogUtil.log("ImageKnife_DataTime_getAndShowImage_execute.start:" + currentRequest.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_getAndShowImage_execute.start:" + currentRequest.imageKnifeOption.loadSrc)
|
||||||
taskpool.execute(task).then((res: Object) => {
|
taskpool.execute(task).then((res: Object) => {
|
||||||
this.doTaskCallback(res as RequestJobResult | undefined, requestList!, currentRequest, memoryKey, imageSrc, requestSource);
|
this.doTaskCallback(res as RequestJobResult | undefined, requestList!, currentRequest, memoryKey, imageSrc, requestSource,isAnimator);
|
||||||
if (isWatchProgress){
|
if (isWatchProgress){
|
||||||
emitter.off(Constants.PROGRESS_EMITTER + memoryKey)
|
emitter.off(Constants.PROGRESS_EMITTER + memoryKey)
|
||||||
}
|
}
|
||||||
|
@ -208,7 +209,7 @@ export class ImageKnifeDispatcher {
|
||||||
})
|
})
|
||||||
} else { //主线程请求
|
} else { //主线程请求
|
||||||
requestJob(request, requestList).then((res: RequestJobResult | undefined) => {
|
requestJob(request, requestList).then((res: RequestJobResult | undefined) => {
|
||||||
this.doTaskCallback(res, requestList!, currentRequest, memoryKey, imageSrc, requestSource);
|
this.doTaskCallback(res, requestList!, currentRequest, memoryKey, imageSrc, requestSource,isAnimator);
|
||||||
LogUtil.log("ImageKnife_DataTime_getAndShowImage_execute.end:"+currentRequest.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_getAndShowImage_execute.end:"+currentRequest.imageKnifeOption.loadSrc)
|
||||||
LogUtil.log("ImageKnife_DataTime_getAndShowImage.end:"+currentRequest.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_getAndShowImage.end:"+currentRequest.imageKnifeOption.loadSrc)
|
||||||
}).catch((err:BusinessError)=>{
|
}).catch((err:BusinessError)=>{
|
||||||
|
@ -234,7 +235,7 @@ export class ImageKnifeDispatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
private doTaskCallback(requestJobResult: RequestJobResult | undefined, requestList: List<ImageKnifeRequestWithSource> ,
|
private doTaskCallback(requestJobResult: RequestJobResult | undefined, requestList: List<ImageKnifeRequestWithSource> ,
|
||||||
currentRequest: ImageKnifeRequest, memoryKey: string, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource):void {
|
currentRequest: ImageKnifeRequest, memoryKey: string, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,isAnimator?: boolean):void {
|
||||||
LogUtil.log("ImageKnife_DataTime_getAndShowImage_CallBack.start:"+currentRequest.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_getAndShowImage_CallBack.start:"+currentRequest.imageKnifeOption.loadSrc)
|
||||||
if (requestJobResult === undefined){
|
if (requestJobResult === undefined){
|
||||||
return
|
return
|
||||||
|
@ -275,12 +276,21 @@ export class ImageKnifeDispatcher {
|
||||||
imageHeight: requestJobResult.size == undefined ? 0 : requestJobResult.size.height,
|
imageHeight: requestJobResult.size == undefined ? 0 : requestJobResult.size.height,
|
||||||
type:requestJobResult.type
|
type:requestJobResult.type
|
||||||
};
|
};
|
||||||
|
if(requestJobResult.pixelMapList != undefined) {
|
||||||
|
let imageAnimator: Array<ImageFrameInfo> = []
|
||||||
|
requestJobResult.pixelMapList.forEach((item,index)=>{
|
||||||
|
imageAnimator.push({
|
||||||
|
src:requestJobResult.pixelMapList![index],
|
||||||
|
duration:requestJobResult.delayList![index]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
ImageKnifeData.imageAnimator = imageAnimator
|
||||||
|
}
|
||||||
// 保存内存缓存
|
// 保存内存缓存
|
||||||
if (currentRequest.imageKnifeOption.writeCacheStrategy !== CacheStrategy.File) {
|
if (currentRequest.imageKnifeOption.writeCacheStrategy !== CacheStrategy.File) {
|
||||||
LogUtil.log("ImageKnife_DataTime_getAndShowImage_saveMemoryCache.start:"+currentRequest.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_getAndShowImage_saveMemoryCache.start:"+currentRequest.imageKnifeOption.loadSrc)
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.saveMemoryCache(this.engineKey.generateMemoryKey(imageSrc, requestSource, currentRequest.imageKnifeOption),
|
.saveMemoryCache(this.engineKey.generateMemoryKey(imageSrc, requestSource, currentRequest.imageKnifeOption,isAnimator),
|
||||||
ImageKnifeData);
|
ImageKnifeData);
|
||||||
LogUtil.log("ImageKnife_DataTime_getAndShowImage_saveMemoryCache.end:"+currentRequest.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_getAndShowImage_saveMemoryCache.end:"+currentRequest.imageKnifeOption.loadSrc)
|
||||||
}
|
}
|
||||||
|
@ -297,7 +307,7 @@ export class ImageKnifeDispatcher {
|
||||||
requestWithSource.request.requestState === ImageKnifeRequestState.PROGRESS)) {
|
requestWithSource.request.requestState === ImageKnifeRequestState.PROGRESS)) {
|
||||||
LogUtil.log("ImageKnife_DataTime_getAndShowImage_showPixelMap.start:"+currentRequest.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_getAndShowImage_showPixelMap.start:"+currentRequest.imageKnifeOption.loadSrc)
|
||||||
requestWithSource.request.ImageKnifeRequestCallback.showPixelMap(requestWithSource.request.componentVersion,
|
requestWithSource.request.ImageKnifeRequestCallback.showPixelMap(requestWithSource.request.componentVersion,
|
||||||
ImageKnifeData.source, requestWithSource.source);
|
ImageKnifeData.source, requestWithSource.source,ImageKnifeData.imageAnimator);
|
||||||
LogUtil.log("ImageKnife_DataTime_getAndShowImage_showPixelMap.end:"+currentRequest.imageKnifeOption.loadSrc)
|
LogUtil.log("ImageKnife_DataTime_getAndShowImage_showPixelMap.end:"+currentRequest.imageKnifeOption.loadSrc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +390,7 @@ async function requestJob(request: RequestJobRequest, requestList?: List<ImageKn
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成文件key
|
// 生成文件key
|
||||||
let fileKey = request.engineKey.generateFileKey(request.src, request.signature)
|
let fileKey = request.engineKey.generateFileKey(request.src, request.signature,request.isAnimator)
|
||||||
|
|
||||||
// 判断自定义下载
|
// 判断自定义下载
|
||||||
if (request.customGetImage !== undefined && request.requestSource == ImageKnifeRequestSource.SRC) {
|
if (request.customGetImage !== undefined && request.requestSource == ImageKnifeRequestSource.SRC) {
|
||||||
|
@ -556,7 +566,43 @@ async function requestJob(request: RequestJobRequest, requestList?: List<ImageKn
|
||||||
let decodingOptions: image.DecodingOptions = {
|
let decodingOptions: image.DecodingOptions = {
|
||||||
editable: true,
|
editable: true,
|
||||||
}
|
}
|
||||||
|
if(request.isAnimator) {
|
||||||
|
if (typeValue === 'gif' || typeValue === 'webp') {
|
||||||
|
let pixelMapList: Array<PixelMap> = []
|
||||||
|
let delayList: Array<number> = []
|
||||||
|
await imageSource.createPixelMapList(decodingOptions).then(async (pixelList: Array<PixelMap>) => {
|
||||||
|
//sdk的api接口发生变更:从.getDelayTime() 变为.getDelayTimeList()
|
||||||
|
await imageSource.getDelayTimeList().then(delayTimes => {
|
||||||
|
if (pixelList.length > 0) {
|
||||||
|
for (let i = 0; i < pixelList.length; i++) {
|
||||||
|
pixelMapList.push(pixelList[i]);
|
||||||
|
if (i < delayTimes.length) {
|
||||||
|
delayList.push(delayTimes[i]);
|
||||||
|
} else {
|
||||||
|
delayList.push(delayTimes[delayTimes.length - 1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
imageSource.release();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
pixelMap: "",
|
||||||
|
bufferSize: bufferSize,
|
||||||
|
fileKey: fileKey,
|
||||||
|
type: typeValue,
|
||||||
|
pixelMapList,
|
||||||
|
delayList
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
pixelMap: undefined,
|
||||||
|
bufferSize: 0,
|
||||||
|
fileKey: '',
|
||||||
|
loadFail: "ImageKnifeAnimatorComponent组件仅支持动态图",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
let resPixelmap: PixelMap | undefined = undefined
|
let resPixelmap: PixelMap | undefined = undefined
|
||||||
if (typeValue === 'gif' || typeValue === 'webp') {
|
if (typeValue === 'gif' || typeValue === 'webp') {
|
||||||
let size = (await imageSource.getImageInfo()).size
|
let size = (await imageSource.getImageInfo()).size
|
||||||
|
|
|
@ -23,6 +23,15 @@ export interface HeaderOptions {
|
||||||
value: Object;
|
value: Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Observed
|
||||||
|
export class AnimatorOption {
|
||||||
|
@Track
|
||||||
|
state?: AnimationStatus = AnimationStatus.Running
|
||||||
|
@Track
|
||||||
|
iterations?: number = -1
|
||||||
|
@Track
|
||||||
|
reverse?: boolean = false
|
||||||
|
}
|
||||||
|
|
||||||
@Observed
|
@Observed
|
||||||
export class ImageKnifeOption {
|
export class ImageKnifeOption {
|
||||||
|
|
|
@ -64,5 +64,5 @@ export enum ImageKnifeRequestState {
|
||||||
|
|
||||||
|
|
||||||
export interface ImageKnifeRequestCallback {
|
export interface ImageKnifeRequestCallback {
|
||||||
showPixelMap: (version: number, pixelMap: PixelMap | string , requestSource: ImageKnifeRequestSource) => void;
|
showPixelMap: (version: number, pixelMap: PixelMap | string , requestSource: ImageKnifeRequestSource,imageAnimator?: Array<ImageFrameInfo>) => void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the 'License');
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an 'AS IS' BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { AnimatorOption, ImageKnifeOption } from '../ImageKnifeOption';
|
||||||
|
import { ImageKnifeRequest, ImageKnifeRequestState } from '../ImageKnifeRequest';
|
||||||
|
import common from '@ohos.app.ability.common';
|
||||||
|
import { ImageKnife } from '../ImageKnife';
|
||||||
|
import { LogUtil } from '../utils/LogUtil';
|
||||||
|
import { ImageKnifeRequestSource } from '../model/ImageKnifeData';
|
||||||
|
|
||||||
|
@Component
|
||||||
|
export struct ImageKnifeAnimatorComponent {
|
||||||
|
@Watch('watchImageKnifeOption') @ObjectLink imageKnifeOption: ImageKnifeOption;
|
||||||
|
@Watch('watchAnimatorOption') @State animatorOption: AnimatorOption = new AnimatorOption();
|
||||||
|
@State pixelMap: PixelMap | string | undefined = undefined
|
||||||
|
@State imageAnimator: Array<ImageFrameInfo> | undefined = undefined
|
||||||
|
@State state: AnimationStatus = AnimationStatus.Running
|
||||||
|
@State iterations: number = -1
|
||||||
|
@State reverse: boolean = false
|
||||||
|
@State adaptiveWidth: Length = '100%'
|
||||||
|
@State adaptiveHeight: Length = '100%'
|
||||||
|
@State objectFit: ImageFit = ImageFit.Contain
|
||||||
|
private request: ImageKnifeRequest | undefined
|
||||||
|
private lastWidth: number = 0
|
||||||
|
private lastHeight: number = 0
|
||||||
|
private currentWidth: number = 0
|
||||||
|
private currentHeight: number = 0
|
||||||
|
private componentVersion: number = 0
|
||||||
|
private currentContext: common.UIAbilityContext | undefined = undefined
|
||||||
|
|
||||||
|
aboutToAppear(): void {
|
||||||
|
this.objectFit = this.imageKnifeOption.objectFit === undefined ? ImageFit.Contain : this.imageKnifeOption.objectFit
|
||||||
|
}
|
||||||
|
|
||||||
|
aboutToDisappear(): void {
|
||||||
|
if (this.request !== undefined) {
|
||||||
|
this.request.requestState = ImageKnifeRequestState.DESTROY
|
||||||
|
this.request = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aboutToRecycle() {
|
||||||
|
if (this.request !== undefined) {
|
||||||
|
this.request.requestState = ImageKnifeRequestState.DESTROY
|
||||||
|
this.request = undefined
|
||||||
|
}
|
||||||
|
this.objectFit = this.imageKnifeOption.objectFit === undefined ? ImageFit.Contain : this.imageKnifeOption.objectFit
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
ImageAnimator()
|
||||||
|
.images(this.imageAnimator)
|
||||||
|
.width(this.adaptiveWidth)
|
||||||
|
.height(this.adaptiveHeight)
|
||||||
|
.border(this.imageKnifeOption.border)
|
||||||
|
.state(this.state)
|
||||||
|
.iterations(this.iterations)
|
||||||
|
.reverse(this.reverse)
|
||||||
|
.onSizeChange((oldValue:SizeOptions, newValue:SizeOptions) => {
|
||||||
|
this.currentWidth = newValue.width as number
|
||||||
|
this.currentHeight = newValue.height as number
|
||||||
|
this.lastWidth = oldValue.width as number
|
||||||
|
this.lastHeight = oldValue.height as number
|
||||||
|
if (this.currentWidth <= 0 || this.currentHeight <= 0) {
|
||||||
|
// 存在宽或者高为0,此次重回无意义,无需进行request请求
|
||||||
|
} else {
|
||||||
|
// 前提:宽高值均有效,值>0. 条件1:当前宽高与上一次宽高不同 条件2:当前是第一次绘制
|
||||||
|
if (this.currentHeight != this.lastHeight || this.currentWidth != this.lastWidth) {
|
||||||
|
LogUtil.log("execute request:width=" + this.currentWidth + " height= " + this.currentHeight)
|
||||||
|
ImageKnife.getInstance().execute(this.getRequest(this.currentWidth, this.currentHeight),true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
watchAnimatorOption(){
|
||||||
|
if(this.animatorOption.state != undefined) {
|
||||||
|
this.state = this.animatorOption.state
|
||||||
|
}
|
||||||
|
if(this.animatorOption.iterations != undefined) {
|
||||||
|
this.iterations = this.animatorOption.iterations
|
||||||
|
}
|
||||||
|
if(this.animatorOption.reverse != undefined) {
|
||||||
|
this.reverse = this.animatorOption.reverse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watchImageKnifeOption() {
|
||||||
|
if (this.request !== undefined) {
|
||||||
|
this.request.requestState = ImageKnifeRequestState.DESTROY
|
||||||
|
}
|
||||||
|
this.request = undefined
|
||||||
|
this.componentVersion++
|
||||||
|
ImageKnife.getInstance().execute(this.getRequest(this.currentWidth, this.currentHeight),true)
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentContext(): common.UIAbilityContext {
|
||||||
|
if (this.currentContext == undefined) {
|
||||||
|
this.currentContext = getContext(this) as common.UIAbilityContext
|
||||||
|
}
|
||||||
|
return this.currentContext
|
||||||
|
}
|
||||||
|
|
||||||
|
getRequest(width: number, height: number): ImageKnifeRequest {
|
||||||
|
if (this.request == undefined) {
|
||||||
|
this.request = new ImageKnifeRequest(
|
||||||
|
this.imageKnifeOption,
|
||||||
|
this.imageKnifeOption.context !== undefined ? this.imageKnifeOption.context : this.getCurrentContext(),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
this.componentVersion,
|
||||||
|
{
|
||||||
|
showPixelMap: async (version: number, pixelMap: PixelMap | string, requestSource: ImageKnifeRequestSource,imageAnimator?: Array<ImageFrameInfo>) => {
|
||||||
|
if (version !== this.componentVersion) {
|
||||||
|
return //针对reuse场景,不显示历史图片
|
||||||
|
}
|
||||||
|
if (imageAnimator != undefined) {
|
||||||
|
this.imageAnimator = imageAnimator
|
||||||
|
} else {
|
||||||
|
this.imageAnimator = [
|
||||||
|
{
|
||||||
|
src: pixelMap
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestSource == ImageKnifeRequestSource.SRC) {
|
||||||
|
this.objectFit =
|
||||||
|
this.imageKnifeOption.objectFit === undefined ? ImageFit.Contain : this.imageKnifeOption.objectFit
|
||||||
|
} else if (requestSource == ImageKnifeRequestSource.PLACE_HOLDER) {
|
||||||
|
this.objectFit =
|
||||||
|
this.imageKnifeOption.placeholderObjectFit === undefined ? (this.imageKnifeOption.objectFit === undefined ? ImageFit.Contain : this.imageKnifeOption.objectFit) : this.imageKnifeOption.placeholderObjectFit
|
||||||
|
} else {
|
||||||
|
this.objectFit =
|
||||||
|
this.imageKnifeOption.errorholderObjectFit === undefined ? (this.imageKnifeOption.objectFit === undefined ? ImageFit.Contain : this.imageKnifeOption.objectFit) : this.imageKnifeOption.errorholderObjectFit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.request
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,18 +12,18 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { SparkMD5 } from '../3rd_party/sparkmd5/spark-md5';
|
|
||||||
import { ImageKnifeOption } from '../ImageKnifeOption';
|
import { ImageKnifeOption } from '../ImageKnifeOption';
|
||||||
import { IEngineKey } from './IEngineKey';
|
import { IEngineKey } from './IEngineKey';
|
||||||
import { PixelMapTransformation } from '../transform/PixelMapTransformation';
|
import { PixelMapTransformation } from '../transform/PixelMapTransformation';
|
||||||
import { ImageKnifeRequestSource } from '../model/ImageKnifeData';
|
import { ImageKnifeRequestSource } from '../model/ImageKnifeData';
|
||||||
|
import { MD5Tools } from '../utils/MD5Tools';
|
||||||
|
|
||||||
@Sendable
|
@Sendable
|
||||||
export class DefaultEngineKey implements IEngineKey {
|
export class DefaultEngineKey implements IEngineKey {
|
||||||
// 生成内存缓存key
|
// 生成内存缓存key
|
||||||
generateMemoryKey(loadSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,
|
generateMemoryKey(loadSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,
|
||||||
imageKnifeOption: ImageKnifeOption, width?: number, height?: number): string {
|
imageKnifeOption: ImageKnifeOption,isAnimator?: boolean, width?: number, height?: number): string {
|
||||||
let key = "loadSrc=" + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
let key = (isAnimator == true ? "Animator=" : "loadSrc==") + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
||||||
if (requestSource === ImageKnifeRequestSource.SRC) {
|
if (requestSource === ImageKnifeRequestSource.SRC) {
|
||||||
if (imageKnifeOption.signature !== undefined && imageKnifeOption.signature !== "") {
|
if (imageKnifeOption.signature !== undefined && imageKnifeOption.signature !== "") {
|
||||||
key += "signature=" + imageKnifeOption.signature + ";"
|
key += "signature=" + imageKnifeOption.signature + ";"
|
||||||
|
@ -36,12 +36,12 @@ export class DefaultEngineKey implements IEngineKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成文件缓存key
|
// 生成文件缓存key
|
||||||
generateFileKey(loadSrc: string | PixelMap | Resource, signature?: string): string {
|
generateFileKey(loadSrc: string | PixelMap | Resource, signature?: string,isAnimator?: boolean): string {
|
||||||
let src = "loadSrc=" + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
let src = (isAnimator == true ? "Animator=" : "loadSrc==") + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
||||||
if (signature !== undefined && signature !== "") {
|
if (signature !== undefined && signature !== "") {
|
||||||
src += "signature=" + signature + ";"
|
src += "signature=" + signature + ";"
|
||||||
}
|
}
|
||||||
return SparkMD5.hashBinary(src)
|
return MD5Tools.md5Sync(src)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTransformation(transformation: PixelMapTransformation): string {
|
private getTransformation(transformation: PixelMapTransformation): string {
|
||||||
|
|
|
@ -18,10 +18,10 @@ import { ImageKnifeRequestSource } from '../model/ImageKnifeData'
|
||||||
export interface IEngineKey {
|
export interface IEngineKey {
|
||||||
// 生成内存缓存key
|
// 生成内存缓存key
|
||||||
generateMemoryKey(loadSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,
|
generateMemoryKey(loadSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,
|
||||||
imageKnifeOption: ImageKnifeOption, width?: number, height?: number): string
|
imageKnifeOption: ImageKnifeOption,isAnimator?: boolean, width?: number, height?: number): string
|
||||||
|
|
||||||
// 生成文件缓存key
|
// 生成文件缓存key
|
||||||
generateFileKey(loadSrc: string | PixelMap | Resource, signature?: string): string
|
generateFileKey(loadSrc: string | PixelMap | Resource, signature?: string,isAnimator?: boolean): string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ export interface ImageKnifeData {
|
||||||
source: PixelMap | string,
|
source: PixelMap | string,
|
||||||
imageWidth: number,
|
imageWidth: number,
|
||||||
imageHeight: number,
|
imageHeight: number,
|
||||||
type?:string
|
type?:string,
|
||||||
|
imageAnimator?: Array<ImageFrameInfo>
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* onComplete成功回调
|
* onComplete成功回调
|
||||||
|
@ -75,7 +76,9 @@ export interface RequestJobResult {
|
||||||
fileKey: string
|
fileKey: string
|
||||||
loadFail?: string,
|
loadFail?: string,
|
||||||
size?:Size,
|
size?:Size,
|
||||||
type?: string
|
type?: string,
|
||||||
|
pixelMapList?:Array<PixelMap>,
|
||||||
|
delayList?: Array<number>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,6 +100,7 @@ export interface RequestJobRequest {
|
||||||
engineKey: IEngineKey
|
engineKey: IEngineKey
|
||||||
isWatchProgress: boolean
|
isWatchProgress: boolean
|
||||||
memoryKey: string
|
memoryKey: string
|
||||||
fileCacheFolder: string
|
fileCacheFolder: string,
|
||||||
|
isAnimator?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import util from '@ohos.util';
|
||||||
import { FileUtils } from './FileUtils';
|
import { FileUtils } from './FileUtils';
|
||||||
import fs from '@ohos.file.fs';
|
import fs from '@ohos.file.fs';
|
||||||
import { LogUtil } from './LogUtil';
|
import { LogUtil } from './LogUtil';
|
||||||
import { SparkMD5 } from '../3rd_party/sparkmd5/spark-md5';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,7 +25,7 @@ export class FileTypeUtil {
|
||||||
'webp': [new Uint8Array([0x52, 0x49, 0x46, 0x46])],
|
'webp': [new Uint8Array([0x52, 0x49, 0x46, 0x46])],
|
||||||
'tiff': [new Uint8Array([0x49, 0x20, 0x49]), new Uint8Array([0x49, 0x49, 0x2A, 0x00]), new Uint8Array([0x4D, 0x4D, 0x00, 0x2A]), new Uint8Array([0x4D, 0x4D, 0x00, 0x2B])],
|
'tiff': [new Uint8Array([0x49, 0x20, 0x49]), new Uint8Array([0x49, 0x49, 0x2A, 0x00]), new Uint8Array([0x4D, 0x4D, 0x00, 0x2A]), new Uint8Array([0x4D, 0x4D, 0x00, 0x2B])],
|
||||||
// 添加更多的文件类型和特征
|
// 添加更多的文件类型和特征
|
||||||
'heic': [new Uint8Array([0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63, 0x00, 0x00, 0x00, 0x00])],
|
'heic': [new Uint8Array([0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63, 0x00, 0x00, 0x00, 0x00]),new Uint8Array([0x00, 0x00, 0x00, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63, 0x00, 0x00, 0x00, 0x00])],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { buffer } from '@kit.ArkTS';
|
||||||
|
import { cryptoFramework } from '@kit.CryptoArchitectureKit';
|
||||||
|
|
||||||
|
export class MD5Tools {
|
||||||
|
/**
|
||||||
|
* 同步返回MD5功能
|
||||||
|
* @param message
|
||||||
|
* @param key
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public static md5Sync(message: string, key?: string): string {
|
||||||
|
let text: string = message;
|
||||||
|
if (!MD5Tools.isEmpty(key)) {
|
||||||
|
text = text + key;
|
||||||
|
}
|
||||||
|
const textBuffer = buffer.from(text, 'utf-8');
|
||||||
|
const data: Uint8Array = new Uint8Array(textBuffer.buffer);
|
||||||
|
return MD5Tools.md5OfUnit8ArraySync(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static isEmpty(str: string | null | undefined | ResourceStr): boolean {
|
||||||
|
if (str === null || str === undefined) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (str === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static md5OfUnit8ArraySync(data: Uint8Array): string {
|
||||||
|
try {
|
||||||
|
const md = cryptoFramework.createMd('MD5')
|
||||||
|
md.updateSync({ data: data })
|
||||||
|
const blob = md.digestSync()
|
||||||
|
let result: string = "";
|
||||||
|
const bytes: Uint8Array = blob.data;
|
||||||
|
for (let i = 0; i < bytes.length; i++) {
|
||||||
|
if ((bytes[i] & 0xff) < 0x10) {
|
||||||
|
result += '0';
|
||||||
|
}
|
||||||
|
result += (bytes[i] & 0xff).toString(16);
|
||||||
|
}
|
||||||
|
return result.toUpperCase()
|
||||||
|
} catch (e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -104,8 +104,13 @@ export class MemoryLruCache implements IMemoryCache {
|
||||||
|
|
||||||
private removeMemorySize(value: ImageKnifeData): void {
|
private removeMemorySize(value: ImageKnifeData): void {
|
||||||
if (value.source != undefined) {
|
if (value.source != undefined) {
|
||||||
if (typeof value.source === 'string') {
|
if (typeof value.source === 'string' && value.source != "") {
|
||||||
this.currentMemory -= value.source.length
|
this.currentMemory -= value.source.length
|
||||||
|
} else if (value.source == "") {
|
||||||
|
for (let index = 0;index < value.imageAnimator!.length;index++) {
|
||||||
|
let pixelMap = value.imageAnimator![index].src as PixelMap
|
||||||
|
this.currentMemory -= pixelMap.getPixelBytesNumber()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.currentMemory -= value.source.getPixelBytesNumber();
|
this.currentMemory -= value.source.getPixelBytesNumber();
|
||||||
value.source.release()
|
value.source.release()
|
||||||
|
@ -116,8 +121,13 @@ export class MemoryLruCache implements IMemoryCache {
|
||||||
|
|
||||||
private addMemorySize(value: ImageKnifeData): void {
|
private addMemorySize(value: ImageKnifeData): void {
|
||||||
if (value.source != undefined) {
|
if (value.source != undefined) {
|
||||||
if (typeof value.source === 'string') {
|
if (typeof value.source === 'string' && value.source != "") {
|
||||||
this.currentMemory += value.source.length
|
this.currentMemory += value.source.length
|
||||||
|
} else if (value.source == "") {
|
||||||
|
for (let index = 0;index < value.imageAnimator!.length;index++) {
|
||||||
|
let pixelMap = value.imageAnimator![index].src as PixelMap
|
||||||
|
this.currentMemory += pixelMap.getPixelBytesNumber()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.currentMemory += value.source.getPixelBytesNumber();
|
this.currentMemory += value.source.getPixelBytesNumber();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { SparkMD5 } from '../3rd_party/sparkmd5/spark-md5'
|
|
||||||
import util from '@ohos.util'
|
import util from '@ohos.util'
|
||||||
|
import { MD5Tools } from '../utils/MD5Tools'
|
||||||
|
|
||||||
export class Tools {
|
export class Tools {
|
||||||
private static keyCache: util.LRUCache<string,string> = new util.LRUCache(1024)
|
private static keyCache: util.LRUCache<string,string> = new util.LRUCache(1024)
|
||||||
|
@ -27,7 +27,7 @@ export class Tools {
|
||||||
if(result != undefined) {
|
if(result != undefined) {
|
||||||
return result
|
return result
|
||||||
} else {
|
} else {
|
||||||
result = SparkMD5.hashBinary(keyCache)
|
result = MD5Tools.md5Sync(keyCache)
|
||||||
Tools.keyCache.put(keyCache,result)
|
Tools.keyCache.put(keyCache,result)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,11 @@ export { InitImageKnife } from "./src/main/ets/pages/InitImageKnife"
|
||||||
|
|
||||||
export { IndexComponent } from "./src/main/ets/pages/Index"
|
export { IndexComponent } from "./src/main/ets/pages/Index"
|
||||||
|
|
||||||
export { ImageKnifeComponent } from '@ohos/imageknife'
|
export { ImageKnifeComponent,ImageKnifeAnimatorComponent } from '@ohos/imageknife'
|
||||||
|
|
||||||
export { ImageKnife } from '@ohos/imageknife'
|
export { ImageKnife } from '@ohos/imageknife'
|
||||||
|
|
||||||
export { ImageKnifeOption } from '@ohos/imageknife'
|
export { ImageKnifeOption,AnimatorOption } from '@ohos/imageknife'
|
||||||
|
|
||||||
export { ImageKnifeRequest } from '@ohos/imageknife'
|
export { ImageKnifeRequest } from '@ohos/imageknife'
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ export { BrightnessTransformation } from '@ohos/imageknife'
|
||||||
|
|
||||||
export { BlurTransformation } from '@ohos/imageknife'
|
export { BlurTransformation } from '@ohos/imageknife'
|
||||||
|
|
||||||
export { SparkMD5 } from "@ohos/imageknife"
|
export {MD5Tools} from '@ohos/imageknife'
|
||||||
|
|
||||||
export { ImageKnifeRequestSource } from "@ohos/imageknife"
|
export { ImageKnifeRequestSource } from "@ohos/imageknife"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue