forked from floraachy/ImageKnife
修复错误图显示以及heic格式匹配
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
This commit is contained in:
parent
a792587c93
commit
4872cc64f7
|
@ -1,6 +1,8 @@
|
||||||
## 3.0.1-rc.2
|
## 3.0.1-rc.2
|
||||||
- 修复自定义下载失败无失败回调
|
- 修复自定义下载失败无失败回调
|
||||||
- 增加全局配置自定义下载接口
|
- 增加全局配置自定义下载接口
|
||||||
|
- 修复主图相同,错误图不同导致只显示一个错误图
|
||||||
|
- heic格式图片文件魔数从第五位开始匹配
|
||||||
|
|
||||||
## 3.0.1-rc.1
|
## 3.0.1-rc.1
|
||||||
- 新增ImageKnifeAnimatorComponent控制动图组件
|
- 新增ImageKnifeAnimatorComponent控制动图组件
|
||||||
|
|
|
@ -141,7 +141,12 @@ struct Index {
|
||||||
uri: 'pages/TestRemoveCache',
|
uri: 'pages/TestRemoveCache',
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
Button("测试错误图显示").margin({top:10}).onClick(()=>{
|
||||||
|
router.push({
|
||||||
|
uri: 'pages/TestErrorHolderPage',
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
Button("测试媒体url").margin({top:10}).onClick(()=>{
|
Button("测试媒体url").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/dataShareUriLoadPage',
|
uri: 'pages/dataShareUriLoadPage',
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* 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 { ImageKnifeComponent } from '@ohos/libraryimageknife'
|
||||||
|
|
||||||
|
@Entry
|
||||||
|
@Component
|
||||||
|
struct TestErrorHolderPage {
|
||||||
|
|
||||||
|
build() {
|
||||||
|
Column() {
|
||||||
|
Text("ImageKnifeComponent1").fontSize(20)
|
||||||
|
ImageKnifeComponent({
|
||||||
|
imageKnifeOption: {
|
||||||
|
loadSrc: "abc",
|
||||||
|
errorholderSrc:$r('app.media.failed')
|
||||||
|
}
|
||||||
|
}).width(200).height(200)
|
||||||
|
Text("ImageKnifeComponent2").fontSize(20)
|
||||||
|
ImageKnifeComponent({
|
||||||
|
imageKnifeOption: {
|
||||||
|
loadSrc: "abc",
|
||||||
|
errorholderSrc:$r('app.media.startIcon')
|
||||||
|
}
|
||||||
|
}).width(200).height(200)
|
||||||
|
Text("ImageKnifeComponent2").fontSize(20)
|
||||||
|
ImageKnifeComponent({
|
||||||
|
imageKnifeOption: {
|
||||||
|
loadSrc: "abc",
|
||||||
|
errorholderSrc:$r('app.media.mask_starfish')
|
||||||
|
}
|
||||||
|
}).width(200).height(200)
|
||||||
|
}
|
||||||
|
.height('100%') .width('100%')
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@
|
||||||
"pages/dataShareUriLoadPage",
|
"pages/dataShareUriLoadPage",
|
||||||
"pages/TestCommonImage",
|
"pages/TestCommonImage",
|
||||||
"pages/ImageAnimatorPage",
|
"pages/ImageAnimatorPage",
|
||||||
"pages/TestSetCustomImagePage"
|
"pages/TestSetCustomImagePage",
|
||||||
|
"pages/TestErrorHolderPage"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -255,9 +255,9 @@ export class ImageKnifeDispatcher {
|
||||||
if (requestWithSource.source === ImageKnifeRequestSource.SRC &&
|
if (requestWithSource.source === ImageKnifeRequestSource.SRC &&
|
||||||
requestWithSource.request.imageKnifeOption.errorholderSrc !== undefined) {
|
requestWithSource.request.imageKnifeOption.errorholderSrc !== undefined) {
|
||||||
|
|
||||||
if (this.showFromMemomry(currentRequest, requestWithSource.request.imageKnifeOption.errorholderSrc,
|
if (this.showFromMemomry(requestWithSource.request, requestWithSource.request.imageKnifeOption.errorholderSrc,
|
||||||
ImageKnifeRequestSource.ERROR_HOLDER) === false) {
|
ImageKnifeRequestSource.ERROR_HOLDER) === false) {
|
||||||
this.getAndShowImage(currentRequest, requestWithSource.request.imageKnifeOption.errorholderSrc,
|
this.getAndShowImage(requestWithSource.request, requestWithSource.request.imageKnifeOption.errorholderSrc,
|
||||||
ImageKnifeRequestSource.ERROR_HOLDER);
|
ImageKnifeRequestSource.ERROR_HOLDER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ export class FileTypeUtil {
|
||||||
const bufferList = this.fileSignatureMap[fileType];
|
const bufferList = this.fileSignatureMap[fileType];
|
||||||
for (let i = 0; i < bufferList.length; i++) {
|
for (let i = 0; i < bufferList.length; i++) {
|
||||||
let signature = bufferList[i];
|
let signature = bufferList[i];
|
||||||
if (this.matchesSignature(fileData, signature)) {
|
if (this.matchesSignature(fileData, signature,fileType)) {
|
||||||
hasMatched = true;
|
hasMatched = true;
|
||||||
matchedFileType = fileType;
|
matchedFileType = fileType;
|
||||||
break
|
break
|
||||||
|
@ -75,12 +75,12 @@ export class FileTypeUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
matchesSignature(fileData: Uint8Array, signature: Uint8Array): boolean {
|
matchesSignature(fileData: Uint8Array, signature: Uint8Array,fileType:string): boolean {
|
||||||
if (fileData.length < signature.length) {
|
if (fileData.length < signature.length) {
|
||||||
return false; // 文件长度不足,无法匹配魔数
|
return false; // 文件长度不足,无法匹配魔数
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < signature.length; i++) {
|
for (let i = fileType == "heic" ? 4 : 0; i < signature.length; i++) {
|
||||||
if (fileData[i] !== signature[i]) {
|
if (fileData[i] !== signature[i]) {
|
||||||
return false; // 魔数不匹配
|
return false; // 魔数不匹配
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue