1.library依赖更名为sharedlibrary

Signed-off-by: zhoulisheng <635547767@qq.com>
This commit is contained in:
zhoulisheng
2023-12-05 10:42:36 +08:00
parent 89fcb3a5d3
commit 9dd89db3e3
16 changed files with 14 additions and 14 deletions

6
sharedlibrary/.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"
}
]
}

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

View File

@@ -0,0 +1,11 @@
{
"name": "sharedlibrary",
"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,133 @@
/*
* 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'
// 自定义组件新增
// 自定义组件绘制生命周期
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('sharedlibrary') as common.UIAbilityContext
}
@State imageOption2:ImageKnifeOption = {
loadSrc: $r('app.media.icon'),
context: getContext(this).createModuleContext('sharedlibrary') as common.UIAbilityContext
}
@State imageOption3:ImageKnifeOption = {
loadSrc: $r('app.media.icon'),
context: getContext(this).createModuleContext('sharedlibrary') as common.UIAbilityContext
}
build() {
Scroll() {
Column() {
Button('点击加载Resource').onClick(()=>{
this.imageOption1 = {
loadSrc: $r('app.media.setting'),
// 只要涉及resource加载 在HSP中都要带上context属性
context: getContext(this).createModuleContext('sharedlibrary') 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('sharedlibrary') as common.UIAbilityContext
}
})
ImageKnifeComponent({imageKnifeOption:this.imageOption2}).width(300).height(300).backgroundColor(Color.Pink)
Button('点击加载本地文件').onClick(()=>{
getContext(this).createModuleContext('sharedlibrary').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('sharedlibrary') 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,22 @@
/*
* 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 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": "sharedlibrary",
"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"
]
}