mirror of
https://gitee.com/openharmony-tpc/ImageKnife.git
synced 2026-05-24 17:25:44 +08:00
1.library依赖更名为sharedlibrary
Signed-off-by: zhoulisheng <635547767@qq.com>
This commit is contained in:
6
sharedlibrary/.gitignore
vendored
Normal file
6
sharedlibrary/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/node_modules
|
||||
/oh_modules
|
||||
/.preview
|
||||
/build
|
||||
/.cxx
|
||||
/.test
|
||||
10
sharedlibrary/build-profile.json5
Normal file
10
sharedlibrary/build-profile.json5
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"apiType": 'stageMode',
|
||||
"buildOption": {
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
2
sharedlibrary/hvigorfile.ts
Normal file
2
sharedlibrary/hvigorfile.ts
Normal 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
sharedlibrary/oh-package.json5
Normal file
11
sharedlibrary/oh-package.json5
Normal 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"
|
||||
}
|
||||
}
|
||||
133
sharedlibrary/src/main/ets/Index.ets
Normal file
133
sharedlibrary/src/main/ets/Index.ets
Normal 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'
|
||||
79
sharedlibrary/src/main/ets/pages/Index.ets
Normal file
79
sharedlibrary/src/main/ets/pages/Index.ets
Normal 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%')
|
||||
}
|
||||
}
|
||||
22
sharedlibrary/src/main/ets/pages/InitImageKnife.ets
Normal file
22
sharedlibrary/src/main/ets/pages/InitImageKnife.ets
Normal 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);
|
||||
}
|
||||
}
|
||||
13
sharedlibrary/src/main/module.json5
Normal file
13
sharedlibrary/src/main/module.json5
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"module": {
|
||||
"name": "sharedlibrary",
|
||||
"type": "shared",
|
||||
"description": "$string:shared_desc",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"pages": "$profile:main_pages"
|
||||
}
|
||||
}
|
||||
8
sharedlibrary/src/main/resources/base/element/color.json
Normal file
8
sharedlibrary/src/main/resources/base/element/color.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "white",
|
||||
"value": "#FFFFFF"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "description"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
sharedlibrary/src/main/resources/base/media/icon.png
Normal file
BIN
sharedlibrary/src/main/resources/base/media/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
BIN
sharedlibrary/src/main/resources/base/media/setting.jpeg
Normal file
BIN
sharedlibrary/src/main/resources/base/media/setting.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/Index"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user