Merge branch 'hsp001'

# Conflicts:
#	entry/src/main/ets/entryability/CustomEngineKeyImpl.ets
#	entry/src/main/ets/pages/imageknifeTestCaseIndex.ets
#	entry/src/main/ets/pages/manyPhotoShowPage.ets
#	entry/src/main/ets/pages/transformPixelMapPage.ets
#	entry/src/main/resources/base/profile/main_pages.json
#	imageknife/src/main/ets/components/imageknife/ImageKnife.ets
#	imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets
#	imageknife/src/main/ets/components/imageknife/RequestOption.ets
#	imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets
#	imageknife/src/main/ets/components/imageknife/networkmanage/HttpDownloadClient.ets
#	imageknife/src/main/ets/components/imageknife/transform/MaskTransformation.ets
#	imageknife/src/main/ets/components/imageknife/utils/FileTypeUtil.ets
#	imageknife/src/main/ets/components/imageknife/utils/base/EasyLinkedHashMap.ets
This commit is contained in:
zhoulisheng 2023-11-16 15:04:48 +08:00
commit 38221f3e0b
70 changed files with 547 additions and 141 deletions

View File

@ -8,12 +8,12 @@
"compatibleSdkVersion": 9 "compatibleSdkVersion": 9
} }
], ],
"buildModeSet":[ "buildModeSet": [
{ {
"name":"debug" "name": "debug"
}, },
{ {
"name":"release" "name": "release"
} }
] ]
}, },
@ -37,6 +37,18 @@
{ {
"name": "gpu_transform", "name": "gpu_transform",
"srcPath": "./gpu_transform" "srcPath": "./gpu_transform"
},
{
"name": "library",
"srcPath": "./library",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
} }
] ]
} }

View File

@ -6,7 +6,7 @@
"repository": {}, "repository": {},
"version": "2.1.1-rc.3", "version": "2.1.1-rc.3",
"dependencies": { "dependencies": {
"@ohos/imageknife": "file:../imageknife", "@ohos/libraryimageknife": "file:../library",
"@ohos/disklrucache": "^2.0.2-rc.0" "@ohos/disklrucache": "^2.0.2-rc.0"
} }
} }

View File

@ -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 { EngineKeyFactories, EngineKeyInterface, RequestOption } from '@ohos/imageknife' import { EngineKeyFactories, EngineKeyInterface, RequestOption } from '@ohos/libraryimageknife'
import { ObjectKey } from '@ohos/imageknife'; import { ObjectKey } from '@ohos/libraryimageknife';
export class CustomEngineKeyImpl implements EngineKeyInterface { export class CustomEngineKeyImpl implements EngineKeyInterface {
redefineUrl: (loadSrc: string) => string; redefineUrl: (loadSrc: string) => string;

View File

@ -15,7 +15,7 @@
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import window from '@ohos.window'; import window from '@ohos.window';
import { ImageKnifeGlobal,ImageKnife,ImageKnifeDrawFactory,LogUtil } from '@ohos/imageknife' import {InitImageKnife, ImageKnifeGlobal,ImageKnife,ImageKnifeDrawFactory,LogUtil } from '@ohos/libraryimageknife'
import { CustomEngineKeyImpl } from './CustomEngineKeyImpl' import { CustomEngineKeyImpl } from './CustomEngineKeyImpl'
import abilityAccessCtrl,{Permissions} from '@ohos.abilityAccessCtrl'; import abilityAccessCtrl,{Permissions} from '@ohos.abilityAccessCtrl';
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
@ -38,7 +38,7 @@ export default class EntryAbility extends UIAbility {
windowStage.loadContent('pages/index', (err:BusinessError, data:void) => { windowStage.loadContent('pages/index', (err:BusinessError, data:void) => {
}); });
ImageKnife.with(this.context); InitImageKnife.init(this.context);
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife() let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife()
if(imageKnife != undefined) { if(imageKnife != undefined) {

View File

@ -17,7 +17,7 @@ import {
ImageKnifeOption, ImageKnifeOption,
RotateImageTransformation, RotateImageTransformation,
RoundedCornersTransformation RoundedCornersTransformation
} from '@ohos/imageknife' } from '@ohos/libraryimageknife'
@Entry @Entry
@Component @Component

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { ImageKnifeComponent, ImageKnifeOption,NONE,DiskStrategy } from '@ohos/imageknife' import { ImageKnifeComponent, ImageKnifeOption,NONE,DiskStrategy } from '@ohos/libraryimageknife'
@Entry @Entry
@Component @Component

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { ImageKnifeComponent, ImageKnifeOption, NONE, DiskStrategy } from '@ohos/imageknife' import { ImageKnifeComponent, ImageKnifeOption, NONE, DiskStrategy } from '@ohos/libraryimageknife'
import { ObjectKey } from '@ohos/imageknife/src/main/ets/components/imageknife/ObjectKey'; import { ObjectKey } from '@ohos/imageknife/src/main/ets/components/imageknife/ObjectKey';
@Entry @Entry

View File

@ -12,7 +12,7 @@
* 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 {ImageKnifeOption,ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeOption,ImageKnifeComponent} from '@ohos/libraryimageknife'
@Entry @Entry
@Component @Component

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { FileUtils, ImageKnifeGlobal} from '@ohos/imageknife' import { FileUtils, ImageKnifeGlobal} from '@ohos/libraryimageknife'
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';

View File

@ -13,12 +13,12 @@
* limitations under the License. * limitations under the License.
*/ */
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
import { FileUtils } from '@ohos/imageknife' import { FileUtils } from '@ohos/libraryimageknife'
import { FileTypeUtil } from '@ohos/imageknife' import { FileTypeUtil } from '@ohos/libraryimageknife'
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
import { Base64 } from '@ohos/imageknife' import { Base64 } from '@ohos/libraryimageknife'
import { ParseImageUtil } from '@ohos/imageknife' import { ParseImageUtil } from '@ohos/libraryimageknife'
import { ImageKnifeGlobal } from '@ohos/imageknife' import { ImageKnifeGlobal } from '@ohos/libraryimageknife'
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
@Entry @Entry

View File

@ -13,11 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
import {FileUtils} from '@ohos/imageknife' import {FileUtils} from '@ohos/libraryimageknife'
import {FileTypeUtil} from '@ohos/imageknife' import {FileTypeUtil} from '@ohos/libraryimageknife'
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
import {Base64} from '@ohos/imageknife' import {Base64} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
@Entry @Entry

View File

@ -12,10 +12,10 @@
* 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 {ImageKnife} from '@ohos/imageknife' import {ImageKnife} from '@ohos/libraryimageknife'
import {OnRenameListener} from '@ohos/imageknife' import {OnRenameListener} from '@ohos/libraryimageknife'
import {OnCompressListener} from '@ohos/imageknife' import {OnCompressListener} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
@Entry @Entry
@Component @Component

View File

@ -13,14 +13,14 @@
* limitations under the License. * limitations under the License.
*/ */
import { CropImage } from '@ohos/imageknife' import { CropImage } from '@ohos/libraryimageknife'
import { CropOptions } from '@ohos/imageknife' import { CropOptions } from '@ohos/libraryimageknife'
import { Crop } from '@ohos/imageknife' import { Crop } from '@ohos/libraryimageknife'
import { RecourseProvider } from '@ohos/imageknife' import { RecourseProvider } from '@ohos/libraryimageknife'
import { PixelMapCrop,Options } from '@ohos/imageknife' import { PixelMapCrop,Options } from '@ohos/libraryimageknife'
import { CropCallback } from '@ohos/imageknife' import { CropCallback } from '@ohos/libraryimageknife'
import { FileUtils } from '@ohos/imageknife' import { FileUtils } from '@ohos/libraryimageknife'
import { ImageKnifeGlobal } from '@ohos/imageknife' import { ImageKnifeGlobal } from '@ohos/libraryimageknife'
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
import common from '@ohos.app.ability.common' import common from '@ohos.app.ability.common'

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import mediaLibrary from '@ohos.multimedia.mediaLibrary'; import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import { ImageKnifeComponent, ImageKnifeOption, } from '@ohos/imageknife' import { ImageKnifeComponent, ImageKnifeOption, } from '@ohos/libraryimageknife'
@Entry @Entry

View File

@ -18,7 +18,7 @@ import {
ImageKnifeOption, ImageKnifeOption,
ImageKnifeDrawFactory, ImageKnifeDrawFactory,
ScaleType ScaleType
} from '@ohos/imageknife' } from '@ohos/libraryimageknife'
@Entry @Entry
@Component @Component

View File

@ -12,10 +12,10 @@
* 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 {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeComponent} from '@ohos/libraryimageknife'
import {ImageKnifeOption} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/libraryimageknife'
import {RotateImageTransformation} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/libraryimageknife'
import {RoundedCornersTransformation} from '@ohos/imageknife' import {RoundedCornersTransformation} from '@ohos/libraryimageknife'
@Entry @Entry
@Component @Component

View File

@ -12,9 +12,9 @@
* 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 {GIFParseImpl} from '@ohos/imageknife' import {GIFParseImpl} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
import {ImageKnife} from '@ohos/imageknife' import {ImageKnife} from '@ohos/libraryimageknife'
import worker from '@ohos.worker'; import worker from '@ohos.worker';
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2023 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, ImageKnifeOption, FileUtils } from '@ohos/libraryimageknife'
@Entry
@Component
struct Index {
@State imageOption1:ImageKnifeOption = {
loadSrc: $r('app.media.icon'),
}
@State imageOption2:ImageKnifeOption = {
loadSrc: $r('app.media.icon'),
}
@State imageOption3:ImageKnifeOption = {
loadSrc: $r('app.media.icon'),
}
build() {
Scroll() {
Column() {
Button('点击加载网络图片').onClick(()=>{
this.imageOption2 = {
loadSrc: 'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
}
})
ImageKnifeComponent({imageKnifeOption:this.imageOption2}).width(300).height(300).backgroundColor(Color.Pink)
Button('点击加载本地文件').onClick(()=>{
let path = globalThis.ImageKnife.getImageKnifeContext().filesDir+"/set.jpeg";
FileUtils.getInstance().readFilePicAsync(path).then(buffer=>{
this.imageOption3 = {
loadSrc: path
}
})
})
ImageKnifeComponent({imageKnifeOption:this.imageOption3}).width(300).height(300).backgroundColor(Color.Pink)
}.width('100%')
}
.width('100%')
.height('100%')
}
}

View File

@ -252,6 +252,26 @@ struct IndexFunctionDemo {
.onClick(() => { .onClick(() => {
router.pushUrl({ url: "pages/testGifLoadWithWorkerPage" }); router.pushUrl({ url: "pages/testGifLoadWithWorkerPage" });
}).margin({ top: 5, left: 3 }) }).margin({ top: 5, left: 3 })
}.width('100%').height(60).backgroundColor(Color.Pink)
Text("HSP相关测试").fontSize(15)
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button("进入HSP的library共享包")
.onClick(() => {
router.pushUrl({url:'@bundle:com.openharmony.imageknife/library/ets/pages/Index'})
.then(()=>{
console.log('push page suceess')
}).catch(err => {
console.log(`pushUrl failed, code is ${err.code}, message is ${err.message}`)
})
}).margin({ top: 15 })
Button("hsp加载后缓存情况,先点左侧按钮")
.onClick(() => {
console.log("pages/tempUrlTestPage 页面跳转")
router.pushUrl({ url: "pages/hspCacheTestPage" });
}).margin({ top: 15 })
}.width('100%').height(60).backgroundColor(Color.Pink) }.width('100%').height(60).backgroundColor(Color.Pink)
Text("测试图片加载稳定").fontSize(15) Text("测试图片加载稳定").fontSize(15)
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {

View File

@ -18,7 +18,7 @@ import {
ImageKnifeOption, ImageKnifeOption,
ImageKnifeGlobal, ImageKnifeGlobal,
ImageKnife ImageKnife
} from '@ohos/imageknife' } from '@ohos/libraryimageknife'
import worker from '@ohos.worker'; import worker from '@ohos.worker';
import { ObjectKey } from '@ohos/imageknife/src/main/ets/components/imageknife/ObjectKey'; import { ObjectKey } from '@ohos/imageknife/src/main/ets/components/imageknife/ObjectKey';

View File

@ -12,10 +12,10 @@
* 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 {ImageKnifeComponent, ScaleType} from '@ohos/imageknife' import {ImageKnifeComponent, ScaleType} from '@ohos/libraryimageknife'
import {ImageKnifeOption} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
import {RotateImageTransformation} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/libraryimageknife'
import {Material} from './model/Material' import {Material} from './model/Material'
import {TestDataSource} from './model/TestDataSource' import {TestDataSource} from './model/TestDataSource'
import {DiskLruCache} from '@ohos/disklrucache' import {DiskLruCache} from '@ohos/disklrucache'

View File

@ -13,9 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
import router from '@system.router'; import router from '@system.router';
import { Pngj } from '@ohos/imageknife' import { Pngj } from '@ohos/libraryimageknife'
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
import { FileUtils,ImageKnifeGlobal } from '@ohos/imageknife' import { FileUtils,ImageKnifeGlobal } from '@ohos/libraryimageknife'
import featureability from '@ohos.ability.featureAbility' import featureability from '@ohos.ability.featureAbility'
import ArkWorker from '@ohos.worker' import ArkWorker from '@ohos.worker'
import worker from '@ohos.worker'; import worker from '@ohos.worker';

View File

@ -12,10 +12,10 @@
* 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 {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeComponent} from '@ohos/libraryimageknife'
import {ImageKnifeOption} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/libraryimageknife'
import {RotateImageTransformation} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/libraryimageknife'
import {RoundedCornersTransformation} from '@ohos/imageknife' import {RoundedCornersTransformation} from '@ohos/libraryimageknife'
@Entry @Entry
@Component @Component

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import {LruCache} from '@ohos/imageknife' import {LruCache} from '@ohos/libraryimageknife'
function getRandomInt(min:number, max:number):number { function getRandomInt(min:number, max:number):number {
min = Math.ceil(min); min = Math.ceil(min);

View File

@ -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 {SVGParseImpl} from '@ohos/imageknife' import {SVGParseImpl} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
import {BusinessError} from '@ohos.base' import {BusinessError} from '@ohos.base'
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';

View File

@ -20,7 +20,7 @@ import {
ImageKnife, ImageKnife,
ImageKnifeDrawFactory, ImageKnifeDrawFactory,
ScaleType ScaleType
} from '@ohos/imageknife' } from '@ohos/libraryimageknife'
import worker from '@ohos.worker'; import worker from '@ohos.worker';
@Entry @Entry
@Component @Component

View File

@ -12,14 +12,14 @@
* 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 {RequestOption} from '@ohos/imageknife' import {RequestOption} from '@ohos/libraryimageknife'
import {ImageKnifeData} from '@ohos/imageknife' import {ImageKnifeData} from '@ohos/libraryimageknife'
import {AllCacheInfo,IAllCacheInfoCallback} from '@ohos/imageknife' import {AllCacheInfo,IAllCacheInfoCallback} from '@ohos/libraryimageknife'
import {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeComponent} from '@ohos/libraryimageknife'
import {TransformType} from '@ohos/imageknife' import {TransformType} from '@ohos/libraryimageknife'
import {ImageKnifeOption} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
import {RotateImageTransformation} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/libraryimageknife'
import {BusinessError} from '@ohos.base' import {BusinessError} from '@ohos.base'
@Entry @Entry
@Component @Component

View File

@ -12,11 +12,11 @@
* 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 {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeComponent} from '@ohos/libraryimageknife'
import {ImageKnifeOption} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
import {ImageKnife} from '@ohos/imageknife' import {ImageKnife} from '@ohos/libraryimageknife'
import {RotateImageTransformation} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/libraryimageknife'
import worker from '@ohos.worker' import worker from '@ohos.worker'
@Entry @Entry
@Component @Component

View File

@ -12,7 +12,7 @@
* 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 { ImageKnife,ImageKnifeGlobal, ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife' import { ImageKnife,ImageKnifeGlobal, ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife'
import worker, { MessageEvents } from '@ohos.worker' import worker, { MessageEvents } from '@ohos.worker'
import Prompt from '@system.prompt' import Prompt from '@system.prompt'

View File

@ -12,11 +12,11 @@
* 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 {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeComponent} from '@ohos/libraryimageknife'
import {ImageKnifeOption} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
import {ImageKnife} from '@ohos/imageknife' import {ImageKnife} from '@ohos/libraryimageknife'
import {RotateImageTransformation} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/libraryimageknife'
import ArkWorker from '@ohos.worker' import ArkWorker from '@ohos.worker'
import worker from '@ohos.worker' import worker from '@ohos.worker'
@Entry @Entry

View File

@ -12,12 +12,12 @@
* 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 {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeComponent} from '@ohos/libraryimageknife'
import {ImageKnifeOption} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/libraryimageknife'
import {BaseTransform} from '@ohos/imageknife' import {BaseTransform} from '@ohos/libraryimageknife'
import {RotateImageTransformation} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/libraryimageknife'
import {GrayscaleTransformation} from '@ohos/imageknife' import {GrayscaleTransformation} from '@ohos/libraryimageknife'
import {SketchFilterTransformation} from '@ohos/imageknife' import {SketchFilterTransformation} from '@ohos/libraryimageknife'
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
@Entry @Entry

View File

@ -12,17 +12,17 @@
* 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 {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeComponent} from '@ohos/libraryimageknife'
import {ImageKnifeOption} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
import {ImageKnife} from '@ohos/imageknife' import {ImageKnife} from '@ohos/libraryimageknife'
import {ScaleType} from '@ohos/imageknife' import {ScaleType} from '@ohos/libraryimageknife'
import {RotateImageTransformation} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/libraryimageknife'
import {GrayscaleTransformation} from '@ohos/imageknife' import {GrayscaleTransformation} from '@ohos/libraryimageknife'
import {SketchFilterTransformation} from '@ohos/imageknife' import {SketchFilterTransformation} from '@ohos/libraryimageknife'
import ArkWorker from '@ohos.worker' import ArkWorker from '@ohos.worker'
import worker from '@ohos.worker' import worker from '@ohos.worker'
import {BaseTransform} from '@ohos/imageknife' import {BaseTransform} from '@ohos/libraryimageknife'
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
@Entry @Entry
@Component @Component

View File

@ -24,7 +24,7 @@ import {
ScaleType, ScaleType,
ImageKnifeGlobal, ImageKnifeGlobal,
BaseTransform BaseTransform
} from '@ohos/imageknife' } from '@ohos/libraryimageknife'
import ArkWorker from '@ohos.worker' import ArkWorker from '@ohos.worker'
import worker from '@ohos.worker'; import worker from '@ohos.worker';
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';

View File

@ -25,7 +25,7 @@ import {
IDrawLifeCycle, IDrawLifeCycle,
ScaleType, ScaleType,
ImageKnifeDrawFactory ImageKnifeDrawFactory
} from '@ohos/imageknife' } from '@ohos/libraryimageknife'
import worker from '@ohos.worker'; import worker from '@ohos.worker';
@Entry @Entry
@Component @Component

View File

@ -12,11 +12,11 @@
* 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 {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeComponent} from '@ohos/libraryimageknife'
import {ImageKnifeData} from '@ohos/imageknife' import {ImageKnifeData} from '@ohos/libraryimageknife'
import {ImageKnifeOption} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/libraryimageknife'
import {RequestOption} from '@ohos/imageknife' import {RequestOption} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal } from '@ohos/imageknife' import {ImageKnifeGlobal } from '@ohos/libraryimageknife'
import worker from '@ohos.worker' import worker from '@ohos.worker'
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'

View File

@ -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 { ImageKnifeComponent } from '@ohos/imageknife' import { ImageKnifeComponent } from '@ohos/libraryimageknife'
import { ImageKnifeOption } from '@ohos/imageknife' import { ImageKnifeOption } from '@ohos/libraryimageknife'
@Entry @Entry
@Component @Component

View File

@ -12,28 +12,28 @@
* 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 { RequestOption,ImageKnifeGlobal} from '@ohos/imageknife' import { RequestOption,ImageKnifeGlobal} from '@ohos/libraryimageknife'
import { CropCircleTransformation } from '@ohos/imageknife' import { CropCircleTransformation } from '@ohos/libraryimageknife'
import { RoundedCornersTransformation } from '@ohos/imageknife' import { RoundedCornersTransformation } from '@ohos/libraryimageknife'
import { import {
CropCircleWithBorderTransformation CropCircleWithBorderTransformation
} from '@ohos/imageknife' } from '@ohos/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation'
import { RotateImageTransformation } from '@ohos/imageknife' import { RotateImageTransformation } from '@ohos/libraryimageknife'
import { CropSquareTransformation } from '@ohos/imageknife' import { CropSquareTransformation } from '@ohos/libraryimageknife'
import { CropTransformation } from '@ohos/imageknife' import { CropTransformation } from '@ohos/libraryimageknife'
import { CropType } from '@ohos/imageknife' import { CropType } from '@ohos/libraryimageknife'
import { GrayscaleTransformation } from '@ohos/imageknife' import { GrayscaleTransformation } from '@ohos/libraryimageknife'
import { BrightnessFilterTransformation } from '@ohos/imageknife' import { BrightnessFilterTransformation } from '@ohos/libraryimageknife'
import { ContrastFilterTransformation } from '@ohos/imageknife' import { ContrastFilterTransformation } from '@ohos/libraryimageknife'
import { InvertFilterTransformation } from '@ohos/imageknife' import { InvertFilterTransformation } from '@ohos/libraryimageknife'
import { SepiaFilterTransformation } from '@ohos/imageknife' import { SepiaFilterTransformation } from '@ohos/libraryimageknife'
import { SketchFilterTransformation } from '@ohos/imageknife' import { SketchFilterTransformation } from '@ohos/libraryimageknife'
import { BlurTransformation } from '@ohos/imageknife' import { BlurTransformation } from '@ohos/libraryimageknife'
import { PixelationFilterTransformation } from '@ohos/imageknife' import { PixelationFilterTransformation } from '@ohos/libraryimageknife'
import { MaskTransformation } from '@ohos/imageknife' import { MaskTransformation } from '@ohos/libraryimageknife'
import { SwirlFilterTransformation } from '@ohos/imageknife' import { SwirlFilterTransformation } from '@ohos/libraryimageknife'
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
import {ImageKnifeData} from '@ohos/imageknife' import {ImageKnifeData} from '@ohos/libraryimageknife'
/** /**
* PixelMap transform 示例 * PixelMap transform 示例
*/ */

View File

@ -33,6 +33,7 @@
"pages/testGifLoadWithWorkerPage", "pages/testGifLoadWithWorkerPage",
"pages/OptionTestPage", "pages/OptionTestPage",
"pages/SignatureTestPage", "pages/SignatureTestPage",
"pages/hspCacheTestPage",
"pages/testManyNetImageLoadWithPage", "pages/testManyNetImageLoadWithPage",
"pages/testManyGifLoadWithPage" "pages/testManyGifLoadWithPage"
] ]

View File

@ -14,7 +14,7 @@
*/ */
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import {ImageKnife,ImageKnifeDrawFactory,ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnife,ImageKnifeDrawFactory,ImageKnifeGlobal} from '@ohos/libraryimageknife'
export default function ImageKnifeTest() { export default function ImageKnifeTest() {
describe('ImageKnifeTest', ()=> { describe('ImageKnifeTest', ()=> {

View File

@ -14,7 +14,7 @@
*/ */
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import {LogUtil} from '@ohos/imageknife' import {LogUtil} from '@ohos/libraryimageknife'
export default function LogUtilTest() { export default function LogUtilTest() {
describe('LogUtilTest', ()=> { describe('LogUtilTest', ()=> {

View File

@ -14,7 +14,7 @@
*/ */
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import {LruCache} from '@ohos/imageknife' // DiskLruCache用例由DiskLruCache三方库提供 import {LruCache} from '@ohos/libraryimageknife' // DiskLruCache用例由DiskLruCache三方库提供
export default function lruCacheTest() { export default function lruCacheTest() {
describe('lruCacheTest', ()=> { describe('lruCacheTest', ()=> {

View File

@ -15,7 +15,7 @@
*/ */
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import {RequestOption,Size} from '@ohos/imageknife' import {RequestOption,Size} from '@ohos/libraryimageknife'
export default function RequestOptionTest() { export default function RequestOptionTest() {
describe('RequestOptionTest', ()=> { describe('RequestOptionTest', ()=> {

View File

@ -36,7 +36,7 @@ import {
ToonFilterTransform, ToonFilterTransform,
VignetteFilterTransform, VignetteFilterTransform,
} from '@ohos/imageknife' } from '@ohos/libraryimageknife'
export default function Transform() { export default function Transform() {
describe('Transform', ()=>{ describe('Transform', ()=>{

View File

@ -18,7 +18,7 @@ import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium'; import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test'; import testsuite from '../test/List.test';
import window from '@ohos.window'; import window from '@ohos.window';
import {ImageKnife,ImageKnifeDrawFactory,ImageKnifeGlobal} from '@ohos/imageknife' import {ImageKnife,ImageKnifeDrawFactory,ImageKnifeGlobal} from '@ohos/libraryimageknife'
import AbilityConstant from '@ohos.app.ability.AbilityConstant'; import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import Want from '@ohos.app.ability.Want'; import Want from '@ohos.app.ability.Want';
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'

View File

@ -97,6 +97,7 @@ export { ImageKnife } from './src/main/ets/components/imageknife/ImageKnife'
export { ImageKnifeGlobal } from './src/main/ets/components/imageknife/ImageKnifeGlobal' export { ImageKnifeGlobal } from './src/main/ets/components/imageknife/ImageKnifeGlobal'
export { ObjectKey } from './src/main/ets/components/imageknife/ObjectKey' export { ObjectKey } from './src/main/ets/components/imageknife/ObjectKey'
export {RequestOption,Size} from './src/main/ets/components/imageknife/RequestOption' export {RequestOption,Size} from './src/main/ets/components/imageknife/RequestOption'
export {ObjectKey} from './src/main/ets/components/imageknife/ObjectKey'
export { ImageKnifeComponent, ScaleType, ScaleTypeHelper } from './src/main/ets/components/imageknife/ImageKnifeComponent' export { ImageKnifeComponent, ScaleType, ScaleTypeHelper } from './src/main/ets/components/imageknife/ImageKnifeComponent'
export { ImageKnifeDrawFactory } from './src/main/ets/components/imageknife/ImageKnifeDrawFactory' export { ImageKnifeDrawFactory } from './src/main/ets/components/imageknife/ImageKnifeDrawFactory'
export {ImageKnifeOption,CropCircleWithBorder,Crop,GifOptions,TransformOptions} from './src/main/ets/components/imageknife/ImageKnifeOption' export {ImageKnifeOption,CropCircleWithBorder,Crop,GifOptions,TransformOptions} from './src/main/ets/components/imageknife/ImageKnifeOption'

View File

@ -22,6 +22,7 @@ import { GIFFrame } from '../imageknife/utils/gif/GIFFrame'
import { IDrawLifeCycle } from '../imageknife/interface/IDrawLifeCycle' import { IDrawLifeCycle } from '../imageknife/interface/IDrawLifeCycle'
import { LogUtil } from '../imageknife/utils/LogUtil' import { LogUtil } from '../imageknife/utils/LogUtil'
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
import common from '@ohos.app.ability.common'
@Component @Component
export struct ImageKnifeComponent { export struct ImageKnifeComponent {
@ -260,6 +261,14 @@ export struct ImageKnifeComponent {
} }
} }
configHspContext(request: RequestOption){
if(this.imageKnifeOption.context != undefined){
request.setModuleContext(this.imageKnifeOption.context)
}else{
request.setModuleContext(getContext(this) as common.UIAbilityContext)
}
}
configRenderGpu(request: RequestOption) { configRenderGpu(request: RequestOption) {
if (this.imageKnifeOption.enableGpu) { if (this.imageKnifeOption.enableGpu) {
request.enableGPU() request.enableGPU()
@ -285,6 +294,7 @@ export struct ImageKnifeComponent {
this.configNecessary(request); this.configNecessary(request);
this.configCacheStrategy(request); this.configCacheStrategy(request);
this.configDisplay(request); this.configDisplay(request);
this.configHspContext(request)
this.configRenderGpu(request); this.configRenderGpu(request);
if(ImageKnifeGlobal.getInstance().getImageKnife()!=undefined) { if(ImageKnifeGlobal.getInstance().getImageKnife()!=undefined) {
ImageKnifeGlobal.getInstance().getImageKnife()?.call(request); ImageKnifeGlobal.getInstance().getImageKnife()?.call(request);

View File

@ -25,6 +25,7 @@ import { ScaleType } from '../imageknife/ImageKnifeComponent'
import { rgbColor } from './transform/CropCircleWithBorderTransformation' import { rgbColor } from './transform/CropCircleWithBorderTransformation'
import { RoundCorner } from './transform/RoundedCornersTransformation' import { RoundCorner } from './transform/RoundedCornersTransformation'
import { ObjectKey } from './ObjectKey' import { ObjectKey } from './ObjectKey'
import common from '@ohos.app.ability.common'
export interface CropCircleWithBorder{ export interface CropCircleWithBorder{
border: number, border: number,
@ -125,7 +126,7 @@ export class ImageKnifeOption {
allCacheInfoCallback?: IAllCacheInfoCallback; allCacheInfoCallback?: IAllCacheInfoCallback;
context?: common.UIAbilityContext;
// sizeAnimate?: AnimateParam 由业务自定义不再支持 // sizeAnimate?: AnimateParam 由业务自定义不再支持
constructor() { constructor() {

View File

@ -49,6 +49,7 @@ import { LogUtil } from '../imageknife/utils/LogUtil'
import { ImageKnifeGlobal } from './ImageKnifeGlobal' import { ImageKnifeGlobal } from './ImageKnifeGlobal'
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
import { ObjectKey } from './ObjectKey' import { ObjectKey } from './ObjectKey'
import common from '@ohos.app.ability.common'
export interface Size { export interface Size {
width: number, width: number,
@ -130,7 +131,8 @@ export class RequestOption {
} }
} }
} }
// module资源的需要当前的module context
moduleContext:common.UIAbilityContext;
constructor() { constructor() {
// 初始化全局监听 // 初始化全局监听
this.requestListeners = new Array(); this.requestListeners = new Array();
@ -147,7 +149,13 @@ export class RequestOption {
}); });
return uuid; return uuid;
} }
setModuleContext(moduleCtx:common.UIAbilityContext){
this.moduleContext = moduleCtx;
}
getModuleContext():common.UIAbilityContext{
return this.moduleContext;
}
/** /**
* set image Component size * set image Component size
*/ */

View File

@ -77,7 +77,7 @@ export class ErrorHolderManager<T> {
onError("ErrorHolderManager 文件类型为null,请检查数据源arraybuffer") onError("ErrorHolderManager 文件类型为null,请检查数据源arraybuffer")
} }
} }
resourceFetch.loadResource(res, suc, onError) resourceFetch.loadResource(this.options.getModuleContext(),res, suc, onError)
} else { } else {
onError("ErrorHolderManager 输入参数有问题!") onError("ErrorHolderManager 输入参数有问题!")
} }

View File

@ -73,7 +73,7 @@ export class PlaceHolderManager<T> {
break; break;
} }
} }
resourceFetch.loadResource(res, suc, onError) resourceFetch.loadResource(this.options.getModuleContext(),res, suc, onError)
} else { } else {
onError("PlaceHolderManager 输入参数有问题!") onError("PlaceHolderManager 输入参数有问题!")
} }

View File

@ -73,7 +73,7 @@ export class RetryHolderManager<T> {
break; break;
} }
} }
resourceFetch.loadResource(res, suc, onError) resourceFetch.loadResource(this.options.getModuleContext(), res, suc, onError)
} else { } else {
onError("PlaceHolderManager 输入参数有问题!") onError("PlaceHolderManager 输入参数有问题!")
} }

View File

@ -43,7 +43,7 @@ export class NetworkDownloadClient implements IDataFetch {
enableMetered: true, enableMetered: true,
}; };
loadRequest.downloadFile( (ImageKnifeGlobal.getInstance().getHapContext() as common.BaseContext ), downloadConfig).then((downloadTask:loadRequest.DownloadTask) => { loadRequest.downloadFile( (request.getModuleContext() as common.BaseContext ), downloadConfig).then((downloadTask:loadRequest.DownloadTask) => {
if (downloadTask) { if (downloadTask) {
let loadTask:loadRequest.DownloadTask | null = downloadTask; let loadTask:loadRequest.DownloadTask | null = downloadTask;

View File

@ -241,7 +241,7 @@ export class RequestManager {
} }
} }
} }
this.mIResourceFetch.loadResource(request.loadSrc as Resource, success, onError); this.mIResourceFetch.loadResource(request.getModuleContext(),request.loadSrc as Resource, success, onError);
} }
// 加载磁盘缓存 原图 // 加载磁盘缓存 原图
private loadDiskFromSource(request: RequestOption, onComplete:(value:ImageKnifeData)=>void|PromiseLike<ImageKnifeData>, onError:(reason?:BusinessError|string)=>void) { private loadDiskFromSource(request: RequestOption, onComplete:(value:ImageKnifeData)=>void|PromiseLike<ImageKnifeData>, onError:(reason?:BusinessError|string)=>void) {
@ -323,6 +323,7 @@ export class RequestManager {
width: Math.round(this.options.thumbSizeMultiplier * this.options.size.width), width: Math.round(this.options.thumbSizeMultiplier * this.options.size.width),
height: Math.round(this.options.thumbSizeMultiplier * this.options.size.height) height: Math.round(this.options.thumbSizeMultiplier * this.options.size.height)
}) })
thumbOption.setModuleContext(this.options.getModuleContext())
let thumbCallback = this.options.thumbholderOnComplete; let thumbCallback = this.options.thumbholderOnComplete;
let thumbError = this.options.thumbholderOnError; let thumbError = this.options.thumbholderOnError;
this.options.transformations[0].transform(source, thumbOption,{asyncTransform: (error:BusinessError|string, pixelMap: PixelMap|null) => { this.options.transformations[0].transform(source, thumbOption,{asyncTransform: (error:BusinessError|string, pixelMap: PixelMap|null) => {
@ -552,6 +553,7 @@ export class RequestManager {
thumbnailProcess(source:ArrayBuffer, filetype:string, onComplete:(value:ImageKnifeData)=>void|PromiseLike<ImageKnifeData>, onError:(reason?:BusinessError|string)=>void){ thumbnailProcess(source:ArrayBuffer, filetype:string, onComplete:(value:ImageKnifeData)=>void|PromiseLike<ImageKnifeData>, onError:(reason?:BusinessError|string)=>void){
let thumbOption = new RequestOption(); let thumbOption = new RequestOption();
thumbOption.setModuleContext(this.options.getModuleContext())
thumbOption.setImageViewSize({ thumbOption.setImageViewSize({
width: Math.round(this.options.thumbSizeMultiplier * this.options.size.width), width: Math.round(this.options.thumbSizeMultiplier * this.options.size.width),
height: Math.round(this.options.thumbSizeMultiplier * this.options.size.height) height: Math.round(this.options.thumbSizeMultiplier * this.options.size.height)

View File

@ -14,7 +14,9 @@
*/ */
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
import common from '@ohos.app.ability.common';
// 本地资源解析抽象接口 // 本地资源解析抽象接口
export interface IResourceFetch<T> { export interface IResourceFetch<T> {
loadResource:(res: Resource, onCompleteFunction:(value:T)=>void | PromiseLike<T>, onErrorFunction:(reason?:BusinessError|string)=>void)=>void; loadResource:(context:common.UIAbilityContext ,res: Resource, onCompleteFunction:(value:T)=>void | PromiseLike<T>, onErrorFunction:(reason?:BusinessError|string)=>void)=>void;
} }

View File

@ -20,11 +20,11 @@ import { ImageKnifeGlobal } from '../ImageKnifeGlobal';
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
export class ParseResClient implements IResourceFetch<ArrayBuffer> { export class ParseResClient implements IResourceFetch<ArrayBuffer> {
loadResource(res: Resource, onCompleteFunction:(value:ArrayBuffer)=>void | PromiseLike<ArrayBuffer>, onErrorFunction:(reason?:BusinessError|string)=>void) { loadResource(context:common.UIAbilityContext,res: Resource, onCompleteFunction:(value:ArrayBuffer)=>void | PromiseLike<ArrayBuffer>, onErrorFunction:(reason?:BusinessError|string)=>void) {
let resId = res.id; let resId = res.id;
let resType = res.type; let resType = res.type;
if (resType == ResourceTypeEts.MEDIA) { if (resType == ResourceTypeEts.MEDIA) {
((ImageKnifeGlobal.getInstance().getHapContext() as common.UIAbilityContext).resourceManager as resourceManager.ResourceManager) (context.resourceManager as resourceManager.ResourceManager)
.getMediaContent(resId) .getMediaContent(resId)
.then(data => { .then(data => {
let arrayBuffer = this.typedArrayToBuffer(data); let arrayBuffer = this.typedArrayToBuffer(data);

View File

@ -19,14 +19,14 @@ import { Base64 } from '../../cache/Base64'
import { BusinessError } from '@ohos.base' import { BusinessError } from '@ohos.base'
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
import { ImageKnifeGlobal } from '../ImageKnifeGlobal'; import { ImageKnifeGlobal } from '../ImageKnifeGlobal';
import common from '@ohos.app.ability.common'
export class ParseResClientBase64 implements IResourceFetch<ArrayBuffer> { export class ParseResClientBase64 implements IResourceFetch<ArrayBuffer> {
loadResource(res: Resource, onCompleteFunction: (value: ArrayBuffer) => void | PromiseLike<ArrayBuffer>, onErrorFunction: (reason?: BusinessError | string) => void) { loadResource(context:common.UIAbilityContext,res: Resource, onCompleteFunction: (value: ArrayBuffer) => void | PromiseLike<ArrayBuffer>, onErrorFunction: (reason?: BusinessError | string) => void) {
let resId = res.id; let resId = res.id;
let resType = res.type; let resType = res.type;
if (resType == ResourceTypeEts.MEDIA) { if (resType == ResourceTypeEts.MEDIA) {
((ImageKnifeGlobal.getInstance() (context.resourceManager as resourceManager.ResourceManager)
.getHapContext() as Record<string, Object>).resourceManager as resourceManager.ResourceManager)
.getMediaContentBase64(resId) .getMediaContentBase64(resId)
.then(data => { .then(data => {
let matchReg = ';base64,'; let matchReg = ';base64,';

View File

@ -87,13 +87,13 @@ export class MaskTransformation implements BaseTransform<PixelMap> {
}) })
} }
private openInternal(bitmap: PixelMap, width: number, height: number, func?: AsyncTransform<PixelMap>) { private openInternal(request: RequestOption,bitmap: PixelMap, width: number, height: number, func?: AsyncTransform<PixelMap>) {
if (!this._mResourceData) { if (!this._mResourceData) {
if(func != undefined){ if(func != undefined){
func.asyncTransform("MaskTransformation resource is empty", null) func.asyncTransform("MaskTransformation resource is empty", null)
} }
} }
let context = (ImageKnifeGlobal.getInstance().getHapContext() as common.UIAbilityContext) let context = (request.getModuleContext() as common.UIAbilityContext)
if(context != undefined){ if(context != undefined){
let resourceManager = context.resourceManager as resourceManager.ResourceManager let resourceManager = context.resourceManager as resourceManager.ResourceManager
if(resourceManager != undefined && this._mResourceData != undefined) if(resourceManager != undefined && this._mResourceData != undefined)

6
library/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test

View File

@ -0,0 +1,10 @@
{
"apiType": 'stageMode',
"buildOption": {
},
"targets": [
{
"name": "default"
}
]
}

2
library/hvigorfile.ts Normal file
View File

@ -0,0 +1,2 @@
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
module.exports = require('@ohos/hvigor-ohos-plugin').hspTasks

11
library/oh-package.json5 Normal file
View File

@ -0,0 +1,11 @@
{
"name": "library",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "./src/main/ets/Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@ohos/imageknife": "file:../imageknife"
}
}

View File

@ -0,0 +1,134 @@
/*
* Copyright (C) 2023 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.
*/
// ImageKnife 对外暴露的接口由library提供
/**
* cache
*/
export { FileUtils } from '@ohos/imageknife'
export { Base64 } from '@ohos/imageknife'
export { LruCache } from '@ohos/imageknife'
export { DiskStrategy } from '@ohos/imageknife'
export { ALL } from '@ohos/imageknife'
export { AUTOMATIC } from '@ohos/imageknife'
export { DATA } from '@ohos/imageknife'
export { NONE } from '@ohos/imageknife'
export { RESOURCE } from '@ohos/imageknife'
export { EngineKeyInterface } from '@ohos/imageknife'
export { EngineKeyFactories } from '@ohos/imageknife'
/**
* compress
*/
export { CompressBuilder } from '@ohos/imageknife'
export { OnCompressListener } from '@ohos/imageknife'
export { OnRenameListener } from '@ohos/imageknife'
export { CompressDataListener } from '@ohos/imageknife'
export { CompressionPredicate } from '@ohos/imageknife'
export { CompressAdapter } from '@ohos/imageknife'
export { CompressProvider } from '@ohos/imageknife'
export { DataStringPathProvider } from '@ohos/imageknife'
export { RecourseProvider } from '@ohos/imageknife'
/**
* crop
*/
export { CropImage } from '@ohos/imageknife'
export { CropOptions } from '@ohos/imageknife'
export { PixelMapCrop,Options } from '@ohos/imageknife'
export { CropCallback } from '@ohos/imageknife'
/**
* transform
*/
export { BaseTransform } from '@ohos/imageknife'
export { BlurTransformation } from '@ohos/imageknife'
export { BrightnessFilterTransformation } from '@ohos/imageknife'
export { ContrastFilterTransformation } from '@ohos/imageknife'
export { CropCircleTransformation } from '@ohos/imageknife'
export { CropCircleWithBorderTransformation,rgbColor } from '@ohos/imageknife'
export { CropSquareTransformation } from '@ohos/imageknife'
export { CropTransformation,CropType } from '@ohos/imageknife'
export { GrayscaleTransformation } from '@ohos/imageknife'
export { InvertFilterTransformation } from '@ohos/imageknife'
export { PixelationFilterTransformation } from '@ohos/imageknife'
export { RotateImageTransformation } from '@ohos/imageknife'
export { RoundedCornersTransformation,RoundCorner } from '@ohos/imageknife'
export { SepiaFilterTransformation } from '@ohos/imageknife'
export { SketchFilterTransformation } from '@ohos/imageknife'
export { MaskTransformation } from '@ohos/imageknife'
export { SwirlFilterTransformation } from '@ohos/imageknife'
export { KuwaharaFilterTransform } from '@ohos/imageknife'
export { ToonFilterTransform } from '@ohos/imageknife'
export { VignetteFilterTransform } from '@ohos/imageknife'
export { TransformUtils } from '@ohos/imageknife'
export { TransformType } from '@ohos/imageknife'
export { CenterCrop } from '@ohos/imageknife'
export { CenterInside } from '@ohos/imageknife'
export { FitCenter } from '@ohos/imageknife'
/**
* pngj
*/
export { Pngj } from '@ohos/imageknife'
export {handler} from '@ohos/imageknife'
export { UPNG } from '@ohos/imageknife'
/**
* ImageKnife
*/
export { ImageKnife } from '@ohos/imageknife'
export { ImageKnifeGlobal } from '@ohos/imageknife'
export {RequestOption,Size} from '@ohos/imageknife'
export {ObjectKey} from '@ohos/imageknife'
export { ImageKnifeComponent, ScaleType, ScaleTypeHelper } from '@ohos/imageknife'
export { ImageKnifeDrawFactory } from '@ohos/imageknife'
export {ImageKnifeOption,CropCircleWithBorder,Crop,GifOptions,TransformOptions} from '@ohos/imageknife'
export { ImageKnifeData } from '@ohos/imageknife'
export {IAllCacheInfoCallback,AllCacheInfo,ResourceCacheInfo,MemoryCacheInfo,DataCacheInfo} from '@ohos/imageknife'
export {IParseImage} from '@ohos/imageknife'
export {IDataFetch} from '@ohos/imageknife'
export {ICache} from '@ohos/imageknife'
export { FileTypeUtil } from '@ohos/imageknife'
export { ParseImageUtil } from '@ohos/imageknife'
/**
* svg parse
*/
export { SVGParseImpl } from '@ohos/imageknife'
/**
* gif parse
*/
export { GIFParseImpl } from '@ohos/imageknife'
export { GIFFrame } from '@ohos/imageknife'
// 能力增强worker 解析GIF数据
export { gifHandler } from '@ohos/imageknife'
// 自定义组件新增
// 自定义组件绘制生命周期
export { IDrawLifeCycle } from '@ohos/imageknife'
// 日志管理
export { LogUtil } from '@ohos/imageknife'
// 额外开放初始化ImageKnife的方法
export {InitImageKnife} from '../ets/pages/InitImageKnife'

View File

@ -0,0 +1,79 @@
/*
* Copyright (C) 2023 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 {ImageKnifeGlobal, ImageKnifeComponent, ImageKnifeOption, FileUtils } from '@ohos/imageknife'
import common from '@ohos.app.ability.common'
@Entry
@Component
struct Index {
@State imageOption1:ImageKnifeOption = {
loadSrc: $r('app.media.icon'),
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
}
@State imageOption2:ImageKnifeOption = {
loadSrc: $r('app.media.icon'),
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
}
@State imageOption3:ImageKnifeOption = {
loadSrc: $r('app.media.icon'),
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
}
build() {
Scroll() {
Column() {
Button('点击加载Resource').onClick(()=>{
this.imageOption1 = {
loadSrc: $r('app.media.setting'),
// 只要涉及resource加载 在HSP中都要带上context属性
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
}
})
ImageKnifeComponent({imageKnifeOption:this.imageOption1}).width(300).height(300).backgroundColor(Color.Pink)
Button('点击加载网络图片').onClick(()=>{
this.imageOption2 = {
loadSrc: 'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
}
})
ImageKnifeComponent({imageKnifeOption:this.imageOption2}).width(300).height(300).backgroundColor(Color.Pink)
Button('点击加载本地文件').onClick(()=>{
getContext(this).createModuleContext('library').resourceManager.getMediaContent($r('app.media.setting').id).then((data:Uint8Array)=>{
let ctx = ImageKnifeGlobal.getInstance().getHapContext() as common.UIAbilityContext;
let path = ctx.filesDir+"/set.jpeg";
FileUtils.getInstance().writeFile(path,data.buffer)
FileUtils.getInstance().readFilePicAsync(path).then(buffer=>{
this.imageOption3 = {
loadSrc: path,
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
}
})
})
})
ImageKnifeComponent({imageKnifeOption:this.imageOption3}).width(300).height(300).backgroundColor(Color.Pink)
}.width('100%')
}
.width('100%')
.height('100%')
}
}

View File

@ -0,0 +1,8 @@
import common from '@ohos.app.ability.common'
import { ImageKnifeComponent, ImageKnifeOption, FileUtils } from '@ohos/imageknife'
import { ImageKnifeGlobal,ImageKnife,ImageKnifeDrawFactory,LogUtil } from '@ohos/imageknife'
export class InitImageKnife{
static init(entryContext:common.UIAbilityContext){
ImageKnife.with(entryContext);
}
}

View File

@ -0,0 +1,13 @@
{
"module": {
"name": "library",
"type": "shared",
"description": "$string:shared_desc",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"pages": "$profile:main_pages"
}
}

View File

@ -0,0 +1,8 @@
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}

View File

@ -0,0 +1,8 @@
{
"string": [
{
"name": "shared_desc",
"value": "description"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,5 @@
{
"src": [
"pages/Index"
]
}