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:
commit
38221f3e0b
|
@ -8,12 +8,12 @@
|
|||
"compatibleSdkVersion": 9
|
||||
}
|
||||
],
|
||||
"buildModeSet":[
|
||||
"buildModeSet": [
|
||||
{
|
||||
"name":"debug"
|
||||
"name": "debug"
|
||||
},
|
||||
{
|
||||
"name":"release"
|
||||
"name": "release"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -37,6 +37,18 @@
|
|||
{
|
||||
"name": "gpu_transform",
|
||||
"srcPath": "./gpu_transform"
|
||||
},
|
||||
{
|
||||
"name": "library",
|
||||
"srcPath": "./library",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
"repository": {},
|
||||
"version": "2.1.1-rc.3",
|
||||
"dependencies": {
|
||||
"@ohos/imageknife": "file:../imageknife",
|
||||
"@ohos/libraryimageknife": "file:../library",
|
||||
"@ohos/disklrucache": "^2.0.2-rc.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { EngineKeyFactories, EngineKeyInterface, RequestOption } from '@ohos/imageknife'
|
||||
import { ObjectKey } from '@ohos/imageknife';
|
||||
import { EngineKeyFactories, EngineKeyInterface, RequestOption } from '@ohos/libraryimageknife'
|
||||
import { ObjectKey } from '@ohos/libraryimageknife';
|
||||
|
||||
export class CustomEngineKeyImpl implements EngineKeyInterface {
|
||||
redefineUrl: (loadSrc: string) => string;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import hilog from '@ohos.hilog';
|
||||
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 abilityAccessCtrl,{Permissions} from '@ohos.abilityAccessCtrl';
|
||||
import { BusinessError } from '@ohos.base'
|
||||
|
@ -38,7 +38,7 @@ export default class EntryAbility extends UIAbility {
|
|||
windowStage.loadContent('pages/index', (err:BusinessError, data:void) => {
|
||||
});
|
||||
|
||||
ImageKnife.with(this.context);
|
||||
InitImageKnife.init(this.context);
|
||||
|
||||
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife()
|
||||
if(imageKnife != undefined) {
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
ImageKnifeOption,
|
||||
RotateImageTransformation,
|
||||
RoundedCornersTransformation
|
||||
} from '@ohos/imageknife'
|
||||
} from '@ohos/libraryimageknife'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ImageKnifeComponent, ImageKnifeOption,NONE,DiskStrategy } from '@ohos/imageknife'
|
||||
import { ImageKnifeComponent, ImageKnifeOption,NONE,DiskStrategy } from '@ohos/libraryimageknife'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* 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';
|
||||
|
||||
@Entry
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ImageKnifeOption,ImageKnifeComponent} from '@ohos/imageknife'
|
||||
import {ImageKnifeOption,ImageKnifeComponent} from '@ohos/libraryimageknife'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileUtils, ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import { FileUtils, ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import { BusinessError } from '@ohos.base'
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
import featureAbility from '@ohos.ability.featureAbility';
|
||||
import { FileUtils } from '@ohos/imageknife'
|
||||
import { FileTypeUtil } from '@ohos/imageknife'
|
||||
import { FileUtils } from '@ohos/libraryimageknife'
|
||||
import { FileTypeUtil } from '@ohos/libraryimageknife'
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import { Base64 } from '@ohos/imageknife'
|
||||
import { ParseImageUtil } from '@ohos/imageknife'
|
||||
import { ImageKnifeGlobal } from '@ohos/imageknife'
|
||||
import { Base64 } from '@ohos/libraryimageknife'
|
||||
import { ParseImageUtil } from '@ohos/libraryimageknife'
|
||||
import { ImageKnifeGlobal } from '@ohos/libraryimageknife'
|
||||
import { BusinessError } from '@ohos.base'
|
||||
import common from '@ohos.app.ability.common';
|
||||
@Entry
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
import featureAbility from '@ohos.ability.featureAbility';
|
||||
import {FileUtils} from '@ohos/imageknife'
|
||||
import {FileTypeUtil} from '@ohos/imageknife'
|
||||
import {FileUtils} from '@ohos/libraryimageknife'
|
||||
import {FileTypeUtil} from '@ohos/libraryimageknife'
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import {Base64} from '@ohos/imageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import {Base64} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
import { BusinessError } from '@ohos.base'
|
||||
import common from '@ohos.app.ability.common';
|
||||
@Entry
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ImageKnife} from '@ohos/imageknife'
|
||||
import {OnRenameListener} from '@ohos/imageknife'
|
||||
import {OnCompressListener} from '@ohos/imageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import {ImageKnife} from '@ohos/libraryimageknife'
|
||||
import {OnRenameListener} from '@ohos/libraryimageknife'
|
||||
import {OnCompressListener} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CropImage } from '@ohos/imageknife'
|
||||
import { CropOptions } from '@ohos/imageknife'
|
||||
import { Crop } from '@ohos/imageknife'
|
||||
import { RecourseProvider } from '@ohos/imageknife'
|
||||
import { PixelMapCrop,Options } from '@ohos/imageknife'
|
||||
import { CropCallback } from '@ohos/imageknife'
|
||||
import { FileUtils } from '@ohos/imageknife'
|
||||
import { ImageKnifeGlobal } from '@ohos/imageknife'
|
||||
import { CropImage } from '@ohos/libraryimageknife'
|
||||
import { CropOptions } from '@ohos/libraryimageknife'
|
||||
import { Crop } from '@ohos/libraryimageknife'
|
||||
import { RecourseProvider } from '@ohos/libraryimageknife'
|
||||
import { PixelMapCrop,Options } from '@ohos/libraryimageknife'
|
||||
import { CropCallback } from '@ohos/libraryimageknife'
|
||||
import { FileUtils } from '@ohos/libraryimageknife'
|
||||
import { ImageKnifeGlobal } from '@ohos/libraryimageknife'
|
||||
import { BusinessError } from '@ohos.base'
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import common from '@ohos.app.ability.common'
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
|
||||
import { ImageKnifeComponent, ImageKnifeOption, } from '@ohos/imageknife'
|
||||
import { ImageKnifeComponent, ImageKnifeOption, } from '@ohos/libraryimageknife'
|
||||
|
||||
|
||||
@Entry
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
ImageKnifeOption,
|
||||
ImageKnifeDrawFactory,
|
||||
ScaleType
|
||||
} from '@ohos/imageknife'
|
||||
} from '@ohos/libraryimageknife'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||
import {RoundedCornersTransformation} from '@ohos/imageknife'
|
||||
import {ImageKnifeComponent} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
||||
import {RotateImageTransformation} from '@ohos/libraryimageknife'
|
||||
import {RoundedCornersTransformation} from '@ohos/libraryimageknife'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {GIFParseImpl} from '@ohos/imageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import {ImageKnife} from '@ohos/imageknife'
|
||||
import {GIFParseImpl} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
import {ImageKnife} from '@ohos/libraryimageknife'
|
||||
import worker from '@ohos.worker';
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import { BusinessError } from '@ohos.base'
|
||||
|
|
|
@ -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%')
|
||||
}
|
||||
}
|
|
@ -252,6 +252,26 @@ struct IndexFunctionDemo {
|
|||
.onClick(() => {
|
||||
router.pushUrl({ url: "pages/testGifLoadWithWorkerPage" });
|
||||
}).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)
|
||||
Text("测试图片加载稳定").fontSize(15)
|
||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
ImageKnifeOption,
|
||||
ImageKnifeGlobal,
|
||||
ImageKnife
|
||||
} from '@ohos/imageknife'
|
||||
} from '@ohos/libraryimageknife'
|
||||
import worker from '@ohos.worker';
|
||||
import { ObjectKey } from '@ohos/imageknife/src/main/ets/components/imageknife/ObjectKey';
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ImageKnifeComponent, ScaleType} from '@ohos/imageknife'
|
||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||
import {ImageKnifeComponent, ScaleType} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
import {RotateImageTransformation} from '@ohos/libraryimageknife'
|
||||
import {Material} from './model/Material'
|
||||
import {TestDataSource} from './model/TestDataSource'
|
||||
import {DiskLruCache} from '@ohos/disklrucache'
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
import router from '@system.router';
|
||||
import { Pngj } from '@ohos/imageknife'
|
||||
import { Pngj } from '@ohos/libraryimageknife'
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import { FileUtils,ImageKnifeGlobal } from '@ohos/imageknife'
|
||||
import { FileUtils,ImageKnifeGlobal } from '@ohos/libraryimageknife'
|
||||
import featureability from '@ohos.ability.featureAbility'
|
||||
import ArkWorker from '@ohos.worker'
|
||||
import worker from '@ohos.worker';
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||
import {RoundedCornersTransformation} from '@ohos/imageknife'
|
||||
import {ImageKnifeComponent} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
||||
import {RotateImageTransformation} from '@ohos/libraryimageknife'
|
||||
import {RoundedCornersTransformation} from '@ohos/libraryimageknife'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {LruCache} from '@ohos/imageknife'
|
||||
import {LruCache} from '@ohos/libraryimageknife'
|
||||
|
||||
function getRandomInt(min:number, max:number):number {
|
||||
min = Math.ceil(min);
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {SVGParseImpl} from '@ohos/imageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import {SVGParseImpl} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import {BusinessError} from '@ohos.base'
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
ImageKnife,
|
||||
ImageKnifeDrawFactory,
|
||||
ScaleType
|
||||
} from '@ohos/imageknife'
|
||||
} from '@ohos/libraryimageknife'
|
||||
import worker from '@ohos.worker';
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {RequestOption} from '@ohos/imageknife'
|
||||
import {ImageKnifeData} from '@ohos/imageknife'
|
||||
import {AllCacheInfo,IAllCacheInfoCallback} from '@ohos/imageknife'
|
||||
import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||
import {TransformType} from '@ohos/imageknife'
|
||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||
import {RequestOption} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeData} from '@ohos/libraryimageknife'
|
||||
import {AllCacheInfo,IAllCacheInfoCallback} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeComponent} from '@ohos/libraryimageknife'
|
||||
import {TransformType} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
import {RotateImageTransformation} from '@ohos/libraryimageknife'
|
||||
import {BusinessError} from '@ohos.base'
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import {ImageKnife} from '@ohos/imageknife'
|
||||
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||
import {ImageKnifeComponent} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
import {ImageKnife} from '@ohos/libraryimageknife'
|
||||
import {RotateImageTransformation} from '@ohos/libraryimageknife'
|
||||
import worker from '@ohos.worker'
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* 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 Prompt from '@system.prompt'
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import {ImageKnife} from '@ohos/imageknife'
|
||||
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||
import {ImageKnifeComponent} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
import {ImageKnife} from '@ohos/libraryimageknife'
|
||||
import {RotateImageTransformation} from '@ohos/libraryimageknife'
|
||||
import ArkWorker from '@ohos.worker'
|
||||
import worker from '@ohos.worker'
|
||||
@Entry
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||
import {BaseTransform} from '@ohos/imageknife'
|
||||
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||
import {GrayscaleTransformation} from '@ohos/imageknife'
|
||||
import {SketchFilterTransformation} from '@ohos/imageknife'
|
||||
import {ImageKnifeComponent} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
||||
import {BaseTransform} from '@ohos/libraryimageknife'
|
||||
import {RotateImageTransformation} from '@ohos/libraryimageknife'
|
||||
import {GrayscaleTransformation} from '@ohos/libraryimageknife'
|
||||
import {SketchFilterTransformation} from '@ohos/libraryimageknife'
|
||||
import image from '@ohos.multimedia.image'
|
||||
|
||||
@Entry
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import {ImageKnife} from '@ohos/imageknife'
|
||||
import {ScaleType} from '@ohos/imageknife'
|
||||
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||
import {GrayscaleTransformation} from '@ohos/imageknife'
|
||||
import {SketchFilterTransformation} from '@ohos/imageknife'
|
||||
import {ImageKnifeComponent} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
import {ImageKnife} from '@ohos/libraryimageknife'
|
||||
import {ScaleType} from '@ohos/libraryimageknife'
|
||||
import {RotateImageTransformation} from '@ohos/libraryimageknife'
|
||||
import {GrayscaleTransformation} from '@ohos/libraryimageknife'
|
||||
import {SketchFilterTransformation} from '@ohos/libraryimageknife'
|
||||
import ArkWorker from '@ohos.worker'
|
||||
import worker from '@ohos.worker'
|
||||
import {BaseTransform} from '@ohos/imageknife'
|
||||
import {BaseTransform} from '@ohos/libraryimageknife'
|
||||
import image from '@ohos.multimedia.image'
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -24,7 +24,7 @@ import {
|
|||
ScaleType,
|
||||
ImageKnifeGlobal,
|
||||
BaseTransform
|
||||
} from '@ohos/imageknife'
|
||||
} from '@ohos/libraryimageknife'
|
||||
import ArkWorker from '@ohos.worker'
|
||||
import worker from '@ohos.worker';
|
||||
import image from '@ohos.multimedia.image';
|
||||
|
|
|
@ -25,7 +25,7 @@ import {
|
|||
IDrawLifeCycle,
|
||||
ScaleType,
|
||||
ImageKnifeDrawFactory
|
||||
} from '@ohos/imageknife'
|
||||
} from '@ohos/libraryimageknife'
|
||||
import worker from '@ohos.worker';
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ImageKnifeComponent} from '@ohos/imageknife'
|
||||
import {ImageKnifeData} from '@ohos/imageknife'
|
||||
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||
import {RequestOption} from '@ohos/imageknife'
|
||||
import {ImageKnifeGlobal } from '@ohos/imageknife'
|
||||
import {ImageKnifeComponent} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeData} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
||||
import {RequestOption} from '@ohos/libraryimageknife'
|
||||
import {ImageKnifeGlobal } from '@ohos/libraryimageknife'
|
||||
import worker from '@ohos.worker'
|
||||
import { BusinessError } from '@ohos.base'
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ImageKnifeComponent } from '@ohos/imageknife'
|
||||
import { ImageKnifeOption } from '@ohos/imageknife'
|
||||
import { ImageKnifeComponent } from '@ohos/libraryimageknife'
|
||||
import { ImageKnifeOption } from '@ohos/libraryimageknife'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
|
|
|
@ -12,28 +12,28 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { RequestOption,ImageKnifeGlobal} from '@ohos/imageknife'
|
||||
import { CropCircleTransformation } from '@ohos/imageknife'
|
||||
import { RoundedCornersTransformation } from '@ohos/imageknife'
|
||||
import { RequestOption,ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||
import { CropCircleTransformation } from '@ohos/libraryimageknife'
|
||||
import { RoundedCornersTransformation } from '@ohos/libraryimageknife'
|
||||
import {
|
||||
CropCircleWithBorderTransformation
|
||||
} from '@ohos/imageknife'
|
||||
import { RotateImageTransformation } from '@ohos/imageknife'
|
||||
import { CropSquareTransformation } from '@ohos/imageknife'
|
||||
import { CropTransformation } from '@ohos/imageknife'
|
||||
import { CropType } from '@ohos/imageknife'
|
||||
import { GrayscaleTransformation } from '@ohos/imageknife'
|
||||
import { BrightnessFilterTransformation } from '@ohos/imageknife'
|
||||
import { ContrastFilterTransformation } from '@ohos/imageknife'
|
||||
import { InvertFilterTransformation } from '@ohos/imageknife'
|
||||
import { SepiaFilterTransformation } from '@ohos/imageknife'
|
||||
import { SketchFilterTransformation } from '@ohos/imageknife'
|
||||
import { BlurTransformation } from '@ohos/imageknife'
|
||||
import { PixelationFilterTransformation } from '@ohos/imageknife'
|
||||
import { MaskTransformation } from '@ohos/imageknife'
|
||||
import { SwirlFilterTransformation } from '@ohos/imageknife'
|
||||
} from '@ohos/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation'
|
||||
import { RotateImageTransformation } from '@ohos/libraryimageknife'
|
||||
import { CropSquareTransformation } from '@ohos/libraryimageknife'
|
||||
import { CropTransformation } from '@ohos/libraryimageknife'
|
||||
import { CropType } from '@ohos/libraryimageknife'
|
||||
import { GrayscaleTransformation } from '@ohos/libraryimageknife'
|
||||
import { BrightnessFilterTransformation } from '@ohos/libraryimageknife'
|
||||
import { ContrastFilterTransformation } from '@ohos/libraryimageknife'
|
||||
import { InvertFilterTransformation } from '@ohos/libraryimageknife'
|
||||
import { SepiaFilterTransformation } from '@ohos/libraryimageknife'
|
||||
import { SketchFilterTransformation } from '@ohos/libraryimageknife'
|
||||
import { BlurTransformation } from '@ohos/libraryimageknife'
|
||||
import { PixelationFilterTransformation } from '@ohos/libraryimageknife'
|
||||
import { MaskTransformation } from '@ohos/libraryimageknife'
|
||||
import { SwirlFilterTransformation } from '@ohos/libraryimageknife'
|
||||
import { BusinessError } from '@ohos.base'
|
||||
import {ImageKnifeData} from '@ohos/imageknife'
|
||||
import {ImageKnifeData} from '@ohos/libraryimageknife'
|
||||
/**
|
||||
* PixelMap transform 示例
|
||||
*/
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
"pages/testGifLoadWithWorkerPage",
|
||||
"pages/OptionTestPage",
|
||||
"pages/SignatureTestPage",
|
||||
"pages/hspCacheTestPage",
|
||||
"pages/testManyNetImageLoadWithPage",
|
||||
"pages/testManyGifLoadWithPage"
|
||||
]
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
import hilog from '@ohos.hilog';
|
||||
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() {
|
||||
describe('ImageKnifeTest', ()=> {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
import hilog from '@ohos.hilog';
|
||||
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() {
|
||||
describe('LogUtilTest', ()=> {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
import hilog from '@ohos.hilog';
|
||||
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() {
|
||||
describe('lruCacheTest', ()=> {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
import hilog from '@ohos.hilog';
|
||||
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() {
|
||||
describe('RequestOptionTest', ()=> {
|
||||
|
|
|
@ -36,7 +36,7 @@ import {
|
|||
ToonFilterTransform,
|
||||
VignetteFilterTransform,
|
||||
|
||||
} from '@ohos/imageknife'
|
||||
} from '@ohos/libraryimageknife'
|
||||
|
||||
export default function Transform() {
|
||||
describe('Transform', ()=>{
|
||||
|
|
|
@ -18,7 +18,7 @@ import hilog from '@ohos.hilog';
|
|||
import { Hypium } from '@ohos/hypium';
|
||||
import testsuite from '../test/List.test';
|
||||
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 Want from '@ohos.app.ability.Want';
|
||||
import { BusinessError } from '@ohos.base'
|
||||
|
|
|
@ -97,6 +97,7 @@ export { ImageKnife } from './src/main/ets/components/imageknife/ImageKnife'
|
|||
export { ImageKnifeGlobal } from './src/main/ets/components/imageknife/ImageKnifeGlobal'
|
||||
export { ObjectKey } from './src/main/ets/components/imageknife/ObjectKey'
|
||||
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 { ImageKnifeDrawFactory } from './src/main/ets/components/imageknife/ImageKnifeDrawFactory'
|
||||
export {ImageKnifeOption,CropCircleWithBorder,Crop,GifOptions,TransformOptions} from './src/main/ets/components/imageknife/ImageKnifeOption'
|
||||
|
|
|
@ -22,6 +22,7 @@ import { GIFFrame } from '../imageknife/utils/gif/GIFFrame'
|
|||
import { IDrawLifeCycle } from '../imageknife/interface/IDrawLifeCycle'
|
||||
import { LogUtil } from '../imageknife/utils/LogUtil'
|
||||
import { BusinessError } from '@ohos.base'
|
||||
import common from '@ohos.app.ability.common'
|
||||
|
||||
@Component
|
||||
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) {
|
||||
if (this.imageKnifeOption.enableGpu) {
|
||||
request.enableGPU()
|
||||
|
@ -285,6 +294,7 @@ export struct ImageKnifeComponent {
|
|||
this.configNecessary(request);
|
||||
this.configCacheStrategy(request);
|
||||
this.configDisplay(request);
|
||||
this.configHspContext(request)
|
||||
this.configRenderGpu(request);
|
||||
if(ImageKnifeGlobal.getInstance().getImageKnife()!=undefined) {
|
||||
ImageKnifeGlobal.getInstance().getImageKnife()?.call(request);
|
||||
|
|
|
@ -25,6 +25,7 @@ import { ScaleType } from '../imageknife/ImageKnifeComponent'
|
|||
import { rgbColor } from './transform/CropCircleWithBorderTransformation'
|
||||
import { RoundCorner } from './transform/RoundedCornersTransformation'
|
||||
import { ObjectKey } from './ObjectKey'
|
||||
import common from '@ohos.app.ability.common'
|
||||
|
||||
export interface CropCircleWithBorder{
|
||||
border: number,
|
||||
|
@ -125,7 +126,7 @@ export class ImageKnifeOption {
|
|||
allCacheInfoCallback?: IAllCacheInfoCallback;
|
||||
|
||||
|
||||
|
||||
context?: common.UIAbilityContext;
|
||||
// sizeAnimate?: AnimateParam 由业务自定义不再支持
|
||||
|
||||
constructor() {
|
||||
|
|
|
@ -49,6 +49,7 @@ import { LogUtil } from '../imageknife/utils/LogUtil'
|
|||
import { ImageKnifeGlobal } from './ImageKnifeGlobal'
|
||||
import { BusinessError } from '@ohos.base'
|
||||
import { ObjectKey } from './ObjectKey'
|
||||
import common from '@ohos.app.ability.common'
|
||||
|
||||
export interface Size {
|
||||
width: number,
|
||||
|
@ -130,7 +131,8 @@ export class RequestOption {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// module资源的需要当前的module context
|
||||
moduleContext:common.UIAbilityContext;
|
||||
constructor() {
|
||||
// 初始化全局监听
|
||||
this.requestListeners = new Array();
|
||||
|
@ -147,7 +149,13 @@ export class RequestOption {
|
|||
});
|
||||
return uuid;
|
||||
}
|
||||
setModuleContext(moduleCtx:common.UIAbilityContext){
|
||||
this.moduleContext = moduleCtx;
|
||||
}
|
||||
|
||||
getModuleContext():common.UIAbilityContext{
|
||||
return this.moduleContext;
|
||||
}
|
||||
/**
|
||||
* set image Component size
|
||||
*/
|
||||
|
|
|
@ -77,7 +77,7 @@ export class ErrorHolderManager<T> {
|
|||
onError("ErrorHolderManager 文件类型为null,请检查数据源arraybuffer")
|
||||
}
|
||||
}
|
||||
resourceFetch.loadResource(res, suc, onError)
|
||||
resourceFetch.loadResource(this.options.getModuleContext(),res, suc, onError)
|
||||
} else {
|
||||
onError("ErrorHolderManager 输入参数有问题!")
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ export class PlaceHolderManager<T> {
|
|||
break;
|
||||
}
|
||||
}
|
||||
resourceFetch.loadResource(res, suc, onError)
|
||||
resourceFetch.loadResource(this.options.getModuleContext(),res, suc, onError)
|
||||
} else {
|
||||
onError("PlaceHolderManager 输入参数有问题!")
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ export class RetryHolderManager<T> {
|
|||
break;
|
||||
}
|
||||
}
|
||||
resourceFetch.loadResource(res, suc, onError)
|
||||
resourceFetch.loadResource(this.options.getModuleContext(), res, suc, onError)
|
||||
} else {
|
||||
onError("PlaceHolderManager 输入参数有问题!")
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ export class NetworkDownloadClient implements IDataFetch {
|
|||
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) {
|
||||
let loadTask:loadRequest.DownloadTask | null = downloadTask;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
@ -323,6 +323,7 @@ export class RequestManager {
|
|||
width: Math.round(this.options.thumbSizeMultiplier * this.options.size.width),
|
||||
height: Math.round(this.options.thumbSizeMultiplier * this.options.size.height)
|
||||
})
|
||||
thumbOption.setModuleContext(this.options.getModuleContext())
|
||||
let thumbCallback = this.options.thumbholderOnComplete;
|
||||
let thumbError = this.options.thumbholderOnError;
|
||||
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){
|
||||
let thumbOption = new RequestOption();
|
||||
thumbOption.setModuleContext(this.options.getModuleContext())
|
||||
thumbOption.setImageViewSize({
|
||||
width: Math.round(this.options.thumbSizeMultiplier * this.options.size.width),
|
||||
height: Math.round(this.options.thumbSizeMultiplier * this.options.size.height)
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
*/
|
||||
|
||||
import { BusinessError } from '@ohos.base'
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
// 本地资源解析抽象接口
|
||||
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;
|
||||
}
|
|
@ -20,11 +20,11 @@ import { ImageKnifeGlobal } from '../ImageKnifeGlobal';
|
|||
import { BusinessError } from '@ohos.base'
|
||||
import common from '@ohos.app.ability.common';
|
||||
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 resType = res.type;
|
||||
if (resType == ResourceTypeEts.MEDIA) {
|
||||
((ImageKnifeGlobal.getInstance().getHapContext() as common.UIAbilityContext).resourceManager as resourceManager.ResourceManager)
|
||||
(context.resourceManager as resourceManager.ResourceManager)
|
||||
.getMediaContent(resId)
|
||||
.then(data => {
|
||||
let arrayBuffer = this.typedArrayToBuffer(data);
|
||||
|
|
|
@ -19,14 +19,14 @@ import { Base64 } from '../../cache/Base64'
|
|||
import { BusinessError } from '@ohos.base'
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import { ImageKnifeGlobal } from '../ImageKnifeGlobal';
|
||||
import common from '@ohos.app.ability.common'
|
||||
|
||||
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 resType = res.type;
|
||||
if (resType == ResourceTypeEts.MEDIA) {
|
||||
((ImageKnifeGlobal.getInstance()
|
||||
.getHapContext() as Record<string, Object>).resourceManager as resourceManager.ResourceManager)
|
||||
(context.resourceManager as resourceManager.ResourceManager)
|
||||
.getMediaContentBase64(resId)
|
||||
.then(data => {
|
||||
let matchReg = ';base64,';
|
||||
|
|
|
@ -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(func != undefined){
|
||||
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){
|
||||
let resourceManager = context.resourceManager as resourceManager.ResourceManager
|
||||
if(resourceManager != undefined && this._mResourceData != undefined)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
/node_modules
|
||||
/oh_modules
|
||||
/.preview
|
||||
/build
|
||||
/.cxx
|
||||
/.test
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"apiType": 'stageMode',
|
||||
"buildOption": {
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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'
|
|
@ -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%')
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"module": {
|
||||
"name": "library",
|
||||
"type": "shared",
|
||||
"description": "$string:shared_desc",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"pages": "$profile:main_pages"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "white",
|
||||
"value": "#FFFFFF"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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 |
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"src": [
|
||||
"pages/Index"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue