diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e0384c..0a162b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,15 @@ +## 1.0.7 + +- 新增开发者可对图片缓存进行全局配置能力 +- 新增对OpenHarmony图库的Uri数据加载的能力(需要申请图库访问权限和文件读取权限,动态申请图库访问权限) +- 修复若干问题: + +​ 1.ImageKnifeOption的loadSrc为undefined,导致的crash问题 + +​ 2.ImageKnifeComponent直接绘制GIF图片格式第几帧的时候,无法绘制问题。 + ## 1.0.6 + - 适配DevEco Studio 3.1Beta1及以上版本。 - 适配OpenHarmony SDK API version 9及以上版本。 diff --git a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage4.ets b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage4.ets index 2b97fd5..3583282 100644 --- a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage4.ets +++ b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage4.ets @@ -142,6 +142,7 @@ struct TestImageKnifeOptionChangedPage4 { if(index<30){ index++ let nextFunc = this.drawMainAnimate.bind(this,index, context, scaleType, imagePixelMap, widthPixel, heightPixel, compWidth, compHeight) + // @ts-ignore this.mTimerId = setTimeout(nextFunc, 1000/30.0) }else{ // 不做处理 @@ -225,6 +226,7 @@ struct TestImageKnifeOptionChangedPage4 { console.log('imageinfo width =' + imageInfo.size.width + ' height=' + imageInfo.size.height + 'scaleType=' + scaleType) let func = this.drawMainAnimate.bind(this,0, context, scaleType, data.drawPixelMap.imagePixelMap, imageInfo.size.width, imageInfo.size.height, compWidth, compHeight) + // @ts-ignore this.mTimerId = setTimeout(func, 1000/30.0) console.log('TestImageKnifeOptionChangedPage4 drawMainSource end!') diff --git a/gpu_transform/src/main/ets/gpu/filter/GPUImageFilter.ts b/gpu_transform/src/main/ets/gpu/filter/GPUImageFilter.ts index 3dbccff..0cbdb48 100644 --- a/gpu_transform/src/main/ets/gpu/filter/GPUImageFilter.ts +++ b/gpu_transform/src/main/ets/gpu/filter/GPUImageFilter.ts @@ -15,7 +15,7 @@ import { NativeEglRender } from '../gl/NativeEglRender' import { GPUFilterType } from '../gl/GPUFilterType' -import { Runnable } from '../interface/Runnable' +import type { Runnable } from '../interface/Runnable' import LinkedList from '@ohos.util.LinkedList'; import ArrayList from '@ohos.util.ArrayList'; diff --git a/imageknife/index.ets b/imageknife/index.ets index c4e36ac..5f0dd67 100644 --- a/imageknife/index.ets +++ b/imageknife/index.ets @@ -27,16 +27,16 @@ export * from './src/main/ets/components/cache/diskstrategy/enum/AUTOMATIC' export * from './src/main/ets/components/cache/diskstrategy/enum/DATA' export * from './src/main/ets/components/cache/diskstrategy/enum/NONE' export * from './src/main/ets/components/cache/diskstrategy/enum/RESOURCE' -export * from './src/main/ets/components/cache/key/EngineKeyInterface' +export type {EngineKeyInterface} from './src/main/ets/components/cache/key/EngineKeyInterface' export * from './src/main/ets/components/cache/key/EngineKeyFactories' /** * compress */ export * from './src/main/ets/components/imageknife/compress/CompressBuilder' -export * from './src/main/ets/components/imageknife/compress/listener/OnCompressListener' -export * from './src/main/ets/components/imageknife/compress/listener/OnRenameListener' -export * from './src/main/ets/components/imageknife/compress/listener/CompressDataListener' +export type {OnCompressListener} from './src/main/ets/components/imageknife/compress/listener/OnCompressListener' +export type {OnRenameListener} from './src/main/ets/components/imageknife/compress/listener/OnRenameListener' +export type {CompressDataListener} from './src/main/ets/components/imageknife/compress/listener/CompressDataListener' export * from './src/main/ets/components/imageknife/compress/listener/CompressionPredicate' export * from './src/main/ets/components/imageknife/compress/provider/CompressAdapter' export * from './src/main/ets/components/imageknife/compress/provider/CompressProvider' @@ -55,7 +55,7 @@ export * from './src/main/ets/components/imageknife/crop/CropCallback' /** * transform */ -export * from './src/main/ets/components/imageknife/transform/BaseTransform' +export type {BaseTransform} from './src/main/ets/components/imageknife/transform/BaseTransform' export * from './src/main/ets/components/imageknife/transform/BlurTransformation' export * from './src/main/ets/components/imageknife/transform/BrightnessFilterTransformation' export * from './src/main/ets/components/imageknife/transform/ContrastFilterTransformation' @@ -99,10 +99,11 @@ export * from './src/main/ets/components/imageknife/ImageKnifeComponent' export * from './src/main/ets/components/imageknife/ImageKnifeDrawFactory' export * from './src/main/ets/components/imageknife/ImageKnifeOption' export * from './src/main/ets/components/imageknife/ImageKnifeData' -export * from './src/main/ets/components/imageknife/interface/IAllCacheInfoCallback' -export * from './src/main/ets/components/imageknife/interface/IParseImage' -export * from './src/main/ets/components/imageknife/networkmanage/IDataFetch' -export * from './src/main/ets/components/imageknife/requestmanage/ICache' +export type {IAllCacheInfoCallback} from './src/main/ets/components/imageknife/interface/IAllCacheInfoCallback' +export type {AllCacheInfo} from './src/main/ets/components/imageknife/interface/IAllCacheInfoCallback' +export type {IParseImage} from './src/main/ets/components/imageknife/interface/IParseImage' +export type {IDataFetch} from './src/main/ets/components/imageknife/networkmanage/IDataFetch' +export type {ICache} from './src/main/ets/components/imageknife/requestmanage/ICache' export * from './src/main/ets/components/imageknife/utils/FileTypeUtil' export * from './src/main/ets/components/imageknife/utils/ParseImageUtil' @@ -121,7 +122,7 @@ export {gifHandler} from './GifWorker' // 自定义组件新增 // 自定义组件绘制生命周期 -export * from './src/main/ets/components/imageknife/interface/IDrawLifeCycle' +export type {IDrawLifeCycle} from './src/main/ets/components/imageknife/interface/IDrawLifeCycle' // 日志管理 export * from './src/main/ets/components/imageknife/utils/LogUtil' \ No newline at end of file diff --git a/imageknife/package.json b/imageknife/package.json index 9d7b9fd..4ebfeaa 100644 --- a/imageknife/package.json +++ b/imageknife/package.json @@ -16,12 +16,8 @@ "type": "module", "version": "1.0.6", "dependencies": { - "pako": "^1.0.5", - "js-binary-schema-parser": "^2.0.3", "@ohos/disklrucache": "^1.0.0", "@ohos/svg": "1.1.0", - "crc-32": "^1.2.0", - "spark-md5": "^3.0.2", "@ohos/gpu_transform": "^0.1.0" }, "tags": [ diff --git a/imageknife/src/main/ets/components/imageknife/ImageKnife.ets b/imageknife/src/main/ets/components/imageknife/ImageKnife.ets index 862666d..313dc16 100644 --- a/imageknife/src/main/ets/components/imageknife/ImageKnife.ets +++ b/imageknife/src/main/ets/components/imageknife/ImageKnife.ets @@ -26,9 +26,9 @@ import {RequestManager} from "../imageknife/requestmanage/RequestManager" import {NONE} from "../cache/diskstrategy/enum/NONE" import {FileTypeUtil} from '../imageknife/utils/FileTypeUtil' import {DownloadClient} from '../imageknife/networkmanage/DownloadClient' -import {IDataFetch} from '../imageknife/networkmanage/IDataFetch' +import type {IDataFetch} from '../imageknife/networkmanage/IDataFetch' import {ParseResClient} from '../imageknife/resourcemanage/ParseResClient' -import {IResourceFetch} from '../imageknife/resourcemanage/IResourceFetch' +import type {IResourceFetch} from '../imageknife/resourcemanage/IResourceFetch' import {ImageKnifeData,ImageKnifeType} from '../imageknife/ImageKnifeData' import {FileUtils} from '../cache/FileUtils' import {FileReader} from '../cache/FileReader' diff --git a/imageknife/src/main/ets/components/imageknife/RequestOption.ets b/imageknife/src/main/ets/components/imageknife/RequestOption.ets index 14c27f1..eddaf7b 100644 --- a/imageknife/src/main/ets/components/imageknife/RequestOption.ets +++ b/imageknife/src/main/ets/components/imageknife/RequestOption.ets @@ -14,9 +14,9 @@ */ import { DiskStrategy } from "../cache/diskstrategy/DiskStrategy" -import { AsyncCallback } from "../imageknife/interface/asynccallback" -import { AsyncSuccess } from "../imageknife/interface/AsyncSuccess" -import { IAllCacheInfoCallback } from "../imageknife/interface/IAllCacheInfoCallback" +import type { AsyncCallback } from "../imageknife/interface/asynccallback" +import type { AsyncSuccess } from "../imageknife/interface/AsyncSuccess" +import type { IAllCacheInfoCallback } from "../imageknife/interface/IAllCacheInfoCallback" import { AUTOMATIC } from "../cache/diskstrategy/enum/AUTOMATIC" import { BaseTransform } from "../imageknife/transform/BaseTransform" import { RotateImageTransformation } from "../imageknife/transform/RotateImageTransformation" diff --git a/imageknife/src/main/ets/components/imageknife/interface/IDrawExtension.ets b/imageknife/src/main/ets/components/imageknife/interface/IDrawExtension.ets deleted file mode 100644 index 5532021..0000000 --- a/imageknife/src/main/ets/components/imageknife/interface/IDrawExtension.ets +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) 2022 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 {ImageKnifeData} from '../ImageKnifeData' -export interface IDrawExtension{ - (context: CanvasRenderingContext2D,data: ImageKnifeData, imageKnifeOption:T, compWidth:number,compHeight:number, setGifTimeId?:(timeId:number)=>void) -} \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets index 57e106c..22ac8be 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { IDataFetch } from '../networkmanage/IDataFetch' +import type { IDataFetch } from '../networkmanage/IDataFetch' import { RequestOption } from '../RequestOption' import { Md5 } from '../../cache/Md5' import { FileUtils } from '../../cache/FileUtils' diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/LoadDataShareFileClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/LoadDataShareFileClient.ets index 01db35e..686de8d 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/LoadDataShareFileClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/LoadDataShareFileClient.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { IDataFetch } from '../networkmanage/IDataFetch' +import type { IDataFetch } from '../networkmanage/IDataFetch' import { RequestOption } from '../RequestOption' import fs from '@ohos.file.fs'; diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets index 53ad857..b48937c 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { IDataFetch } from '../networkmanage/IDataFetch' +import type { IDataFetch } from '../networkmanage/IDataFetch' import { RequestOption } from '../RequestOption' import { Md5 } from '../../cache/Md5' import { FileUtils } from '../../cache/FileUtils' diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets index 0b2ecda..156e152 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets @@ -13,14 +13,14 @@ * limitations under the License. */ -import { IDataFetch } from '../networkmanage/IDataFetch' +import type { IDataFetch } from '../networkmanage/IDataFetch' import { RequestOption } from '../RequestOption' import { Md5 } from '../../cache/Md5' import { FileUtils } from '../../cache/FileUtils' import loadRequest from '@ohos.request'; // 数据加载器 -export class NetworkDownloadClient { +export class NetworkDownloadClient implements IDataFetch { loadData(request: RequestOption, onComplete: (img: ArrayBuffer) => void, onError: (err: string) => void) { let filename = Md5.hashStr(request.generateDataKey); let downloadFolder = request.getFilesPath() + "/" + request.networkCacheFolder; diff --git a/imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets index 38ba6ea..51087e6 100644 --- a/imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets +++ b/imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { ICache } from "../requestmanage/ICache" +import type { ICache } from "../requestmanage/ICache" import { DiskLruCache } from "@ohos/disklrucache" export class DiskCacheProxy implements ICache { diff --git a/imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets index 7752c2e..13bab96 100644 --- a/imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets +++ b/imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import {ICache} from "../requestmanage/ICache" +import type {ICache} from "../requestmanage/ICache" import {LruCache} from "../../cache/LruCache" export class MemoryCacheProxy implements ICache { diff --git a/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets index 5ffb29d..bf4d341 100644 --- a/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets +++ b/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets @@ -21,12 +21,12 @@ import {Md5} from "../../cache/Md5" import{MemoryCacheProxy} from "../requestmanage/MemoryCacheProxy" import{DiskCacheProxy} from "../requestmanage/DiskCacheProxy" import{FileTypeUtil} from "../utils/FileTypeUtil" -import{IDataFetch} from "../../imageknife/networkmanage/IDataFetch" -import{IResourceFetch} from "../../imageknife/resourcemanage/IResourceFetch" +import type {IDataFetch} from "../../imageknife/networkmanage/IDataFetch" +import type {IResourceFetch} from "../../imageknife/resourcemanage/IResourceFetch" import{ImageKnifeData,ImageKnifeType} from "../ImageKnifeData" -import {AllCacheInfo, IAllCacheInfoCallback} from "../../imageknife/interface/IAllCacheInfoCallback" +import {AllCacheInfo} from "../../imageknife/interface/IAllCacheInfoCallback" import{ParseImageUtil} from '../utils/ParseImageUtil' -import{IParseImage} from '../interface/IParseImage' +import type {IParseImage} from '../interface/IParseImage' import image from "@ohos.multimedia.image" import { SVGParseImpl } from '../utils/svg/SVGParseImpl' import { GIFParseImpl } from '../utils/gif/GIFParseImpl' diff --git a/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets index ddcd37c..b622d83 100644 --- a/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets +++ b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import {IResourceFetch} from '../resourcemanage/IResourceFetch' +import type {IResourceFetch} from '../resourcemanage/IResourceFetch' import {ResourceTypeEts} from '../../imageknife/constants/ResourceTypeEts' import resourceManager from '@ohos.resourceManager'; diff --git a/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets index fb75c14..a9590ad 100644 --- a/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets +++ b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import {IResourceFetch} from '../resourcemanage/IResourceFetch' +import type {IResourceFetch} from '../resourcemanage/IResourceFetch' import {ResourceTypeEts} from '../../imageknife/constants/ResourceTypeEts' import {Base64} from '../../cache/Base64' diff --git a/imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets b/imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets index 472d342..62de0b1 100644 --- a/imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets +++ b/imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {DataCallBack} from "../interface/DataCallBack" +import type {DataCallBack} from "../interface/DataCallBack" export namespace ColorUtils { diff --git a/imageknife/src/main/ets/components/imageknife/utils/ParseImageUtil.ets b/imageknife/src/main/ets/components/imageknife/utils/ParseImageUtil.ets index d4dbd5f..02d6f52 100644 --- a/imageknife/src/main/ets/components/imageknife/utils/ParseImageUtil.ets +++ b/imageknife/src/main/ets/components/imageknife/utils/ParseImageUtil.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import{IParseImage} from '../interface/IParseImage' +import type {IParseImage} from '../interface/IParseImage' import image from '@ohos.multimedia.image'; export class ParseImageUtil implements IParseImage { diff --git a/imageknife/src/main/ets/components/imageknife/utils/svg/SVGParseImpl.ets b/imageknife/src/main/ets/components/imageknife/utils/svg/SVGParseImpl.ets index d304533..391177c 100644 --- a/imageknife/src/main/ets/components/imageknife/utils/svg/SVGParseImpl.ets +++ b/imageknife/src/main/ets/components/imageknife/utils/svg/SVGParseImpl.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {IParseSvg} from'./IParseSvg' +import type {IParseSvg} from'./IParseSvg' import {SVGImageView} from '@ohos/svg' export class SVGParseImpl implements IParseSvg{ parseSvg(imageinfo: ArrayBuffer,size?:{width:number,height:number}): Promise{