forked from floraachy/ImageKnife
!74 library依赖更名为sharedlibrary
Merge pull request !74 from zhoulisheng2/master
This commit is contained in:
commit
70a1c0911e
2
NOTICE
2
NOTICE
|
@ -148,7 +148,7 @@ http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html
|
||||||
|
|
||||||
Java Author: Mario Klingemann <mario at quasimondo.com>
|
Java Author: Mario Klingemann <mario at quasimondo.com>
|
||||||
http://incubator.quasimondo.com
|
http://incubator.quasimondo.com
|
||||||
created Feburary 29, 2004
|
created February 29, 2004
|
||||||
port : Yahel Bouaziz <yahel at kayenko.com>
|
port : Yahel Bouaziz <yahel at kayenko.com>
|
||||||
http://www.kayenko.com
|
http://www.kayenko.com
|
||||||
ported april 5th, 2012
|
ported april 5th, 2012
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
"srcPath": "./gpu_transform"
|
"srcPath": "./gpu_transform"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "library",
|
"name": "sharedlibrary",
|
||||||
"srcPath": "./library",
|
"srcPath": "./sharedlibrary",
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"name": "default",
|
"name": "default",
|
||||||
|
|
|
@ -6,8 +6,11 @@
|
||||||
"repository": {},
|
"repository": {},
|
||||||
"version": "2.1.1-rc.4",
|
"version": "2.1.1-rc.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ohos/libraryimageknife": "file:../library",
|
// 如果测试entry的demo需要开启以下2个依赖, 然后点击entry勾选 Edit Configurations->点击Deploy Multi Hap->勾选Deploy Multi Hap Packages
|
||||||
|
// 然后点击module栏目 把library也勾选上,这样就可以在HSP场景下测试Entry里面的HSP场景
|
||||||
|
"@ohos/libraryimageknife": "file:../sharedlibrary",
|
||||||
"@ohos/disklrucache": "^2.0.2-rc.0",
|
"@ohos/disklrucache": "^2.0.2-rc.0",
|
||||||
|
// 下面这个依赖是为了跑XTS用例的,需要跑XTS时,需要注释上面2个依赖单独使用imageknife依赖
|
||||||
"@ohos/imageknife": "file:../imageknife"
|
"@ohos/imageknife": "file:../imageknife"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -262,7 +262,7 @@ struct IndexFunctionDemo {
|
||||||
|
|
||||||
Button("进入HSP的library共享包")
|
Button("进入HSP的library共享包")
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
router.pushUrl({url:'@bundle:com.openharmony.imageknife/library/ets/pages/Index'})
|
router.pushUrl({url:'@bundle:com.openharmony.imageknife/sharedlibrary/ets/pages/Index'})
|
||||||
.then(()=>{
|
.then(()=>{
|
||||||
console.log('push page suceess')
|
console.log('push page suceess')
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,6 +23,7 @@ import worker from '@ohos.worker'
|
||||||
@Component
|
@Component
|
||||||
struct TestImageKnifeOptionChangedPage {
|
struct TestImageKnifeOptionChangedPage {
|
||||||
|
|
||||||
|
svgUrl:string = ''
|
||||||
@State imageKnifeOption1: ImageKnifeOption =
|
@State imageKnifeOption1: ImageKnifeOption =
|
||||||
{
|
{
|
||||||
loadSrc: $r('app.media.jpgSample'),
|
loadSrc: $r('app.media.jpgSample'),
|
||||||
|
@ -139,10 +140,28 @@ struct TestImageKnifeOptionChangedPage {
|
||||||
errorholderSrc: $r('app.media.icon_failed')
|
errorholderSrc: $r('app.media.icon_failed')
|
||||||
};
|
};
|
||||||
}).margin({left:5}).backgroundColor(Color.Blue)
|
}).margin({left:5}).backgroundColor(Color.Blue)
|
||||||
Button('svg')
|
|
||||||
|
Text("请先设置SVG图片的url地址")
|
||||||
|
TextArea({ placeholder: '请输入SVG图片的url地址' })
|
||||||
|
.placeholderColor("rgb(0,0,35)")
|
||||||
|
.placeholderFont({ size: 20, weight: 100, family: 'cursive', style: FontStyle.Italic })
|
||||||
|
.textAlign(TextAlign.Center)
|
||||||
|
.caretColor(Color.Blue)
|
||||||
|
.height(40)
|
||||||
|
.width(400)
|
||||||
|
.fontSize(20)
|
||||||
|
.fontWeight(FontWeight.Bold)
|
||||||
|
.fontFamily("sans-serif")
|
||||||
|
.fontStyle(FontStyle.Normal)
|
||||||
|
.fontColor(Color.Red)
|
||||||
|
.onChange((value: string) => {
|
||||||
|
this.svgUrl = value
|
||||||
|
})
|
||||||
|
|
||||||
|
Button('svg')
|
||||||
.onClick(()=>{
|
.onClick(()=>{
|
||||||
this.imageKnifeOption1 = {
|
this.imageKnifeOption1 = {
|
||||||
loadSrc: 'http://124.222.187.78/download/test.svg',
|
loadSrc: this.svgUrl,
|
||||||
|
|
||||||
placeholderSrc: $r('app.media.icon_loading'),
|
placeholderSrc: $r('app.media.icon_loading'),
|
||||||
errorholderSrc: $r('app.media.icon_failed')
|
errorholderSrc: $r('app.media.icon_failed')
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { BusinessError } from '@ohos.base'
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct TestPreloadPage {
|
struct TestPreloadPage {
|
||||||
|
svgUrl:string = ''
|
||||||
@State imageKnifeOption1: ImageKnifeOption =
|
@State imageKnifeOption1: ImageKnifeOption =
|
||||||
{
|
{
|
||||||
loadSrc: $r('app.media.jpgSample'),
|
loadSrc: $r('app.media.jpgSample'),
|
||||||
|
@ -255,13 +255,28 @@ struct TestPreloadPage {
|
||||||
|
|
||||||
}
|
}
|
||||||
.margin({ top: 15 })
|
.margin({ top: 15 })
|
||||||
|
Text("请先设置SVG图片的url地址")
|
||||||
|
TextArea({ placeholder: '请输入SVG图片的url地址' })
|
||||||
|
.placeholderColor("rgb(0,0,35)")
|
||||||
|
.placeholderFont({ size: 20, weight: 100, family: 'cursive', style: FontStyle.Italic })
|
||||||
|
.textAlign(TextAlign.Center)
|
||||||
|
.caretColor(Color.Blue)
|
||||||
|
.height(40)
|
||||||
|
.width(400)
|
||||||
|
.fontSize(20)
|
||||||
|
.fontWeight(FontWeight.Bold)
|
||||||
|
.fontFamily("sans-serif")
|
||||||
|
.fontStyle(FontStyle.Normal)
|
||||||
|
.fontColor(Color.Red)
|
||||||
|
.onChange((value: string) => {
|
||||||
|
this.svgUrl = value
|
||||||
|
})
|
||||||
Flex({ direction: FlexDirection.Row }) {
|
Flex({ direction: FlexDirection.Row }) {
|
||||||
|
|
||||||
Button('预加载网络资源svg')
|
Button('预加载网络资源svg')
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
let request = new RequestOption();
|
let request = new RequestOption();
|
||||||
request.load('http://124.222.187.78/download/test.svg')
|
request.load(this.svgUrl)
|
||||||
.setImageViewSize({ width: 300, height: 300 })
|
.setImageViewSize({ width: 300, height: 300 })
|
||||||
.addListener({callback:(err:BusinessError|string, data:ImageKnifeData) => {
|
.addListener({callback:(err:BusinessError|string, data:ImageKnifeData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -279,7 +294,7 @@ struct TestPreloadPage {
|
||||||
Button('网络资源svg')
|
Button('网络资源svg')
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.imageKnifeOption = {
|
this.imageKnifeOption = {
|
||||||
loadSrc: 'http://124.222.187.78/download/test.svg',
|
loadSrc: this.svgUrl,
|
||||||
|
|
||||||
placeholderSrc: $r('app.media.icon_loading'),
|
placeholderSrc: $r('app.media.icon_loading'),
|
||||||
errorholderSrc: $r('app.media.icon_failed'),
|
errorholderSrc: $r('app.media.icon_failed'),
|
||||||
|
|
|
@ -445,7 +445,7 @@ export struct ImageKnifeComponent {
|
||||||
LogUtil.log('ImageKnifeComponent default drawPlaceholder start!')
|
LogUtil.log('ImageKnifeComponent default drawPlaceholder start!')
|
||||||
|
|
||||||
data.drawPixelMap?.imagePixelMap?.getImageInfo().then((imageInfo) => {
|
data.drawPixelMap?.imagePixelMap?.getImageInfo().then((imageInfo) => {
|
||||||
LogUtil.log('ImageKnifeComponent imageinfo widht =' + imageInfo.size.width + ' height=' + imageInfo.size.height)
|
LogUtil.log('ImageKnifeComponent imageinfo width =' + imageInfo.size.width + ' height=' + imageInfo.size.height)
|
||||||
let scaleType = (typeof imageKnifeOption.placeholderScaleType == 'number') ? imageKnifeOption.placeholderScaleType : ScaleType.FIT_CENTER
|
let scaleType = (typeof imageKnifeOption.placeholderScaleType == 'number') ? imageKnifeOption.placeholderScaleType : ScaleType.FIT_CENTER
|
||||||
context.save();
|
context.save();
|
||||||
context.clearRect(0, 0, compWidth, compHeight)
|
context.clearRect(0, 0, compWidth, compHeight)
|
||||||
|
@ -500,7 +500,7 @@ export struct ImageKnifeComponent {
|
||||||
LogUtil.log('ImageKnifeComponent default drawThumbSizeMultiplier start!')
|
LogUtil.log('ImageKnifeComponent default drawThumbSizeMultiplier start!')
|
||||||
|
|
||||||
data.drawPixelMap?.imagePixelMap?.getImageInfo().then((imageInfo) => {
|
data.drawPixelMap?.imagePixelMap?.getImageInfo().then((imageInfo) => {
|
||||||
LogUtil.log('ImageKnifeComponent imageinfo widht =' + imageInfo.size.width + ' height=' + imageInfo.size.height)
|
LogUtil.log('ImageKnifeComponent imageinfo width =' + imageInfo.size.width + ' height=' + imageInfo.size.height)
|
||||||
let scaleType = (typeof imageKnifeOption.thumbSizeMultiplierScaleType == 'number') ? imageKnifeOption.thumbSizeMultiplierScaleType : ScaleType.FIT_CENTER
|
let scaleType = (typeof imageKnifeOption.thumbSizeMultiplierScaleType == 'number') ? imageKnifeOption.thumbSizeMultiplierScaleType : ScaleType.FIT_CENTER
|
||||||
context.save();
|
context.save();
|
||||||
context.clearRect(0, 0, compWidth, compHeight)
|
context.clearRect(0, 0, compWidth, compHeight)
|
||||||
|
@ -553,7 +553,7 @@ export struct ImageKnifeComponent {
|
||||||
LogUtil.log('ImageKnifeComponent default drawErrorholder start!')
|
LogUtil.log('ImageKnifeComponent default drawErrorholder start!')
|
||||||
|
|
||||||
data.drawPixelMap?.imagePixelMap?.getImageInfo().then((imageInfo) => {
|
data.drawPixelMap?.imagePixelMap?.getImageInfo().then((imageInfo) => {
|
||||||
LogUtil.log('ImageKnifeComponent imageinfo widht =' + imageInfo.size.width + ' height=' + imageInfo.size.height)
|
LogUtil.log('ImageKnifeComponent imageinfo width =' + imageInfo.size.width + ' height=' + imageInfo.size.height)
|
||||||
let scaleType = (typeof imageKnifeOption.errorholderSrcScaleType == 'number') ? imageKnifeOption.errorholderSrcScaleType : ScaleType.FIT_CENTER
|
let scaleType = (typeof imageKnifeOption.errorholderSrcScaleType == 'number') ? imageKnifeOption.errorholderSrcScaleType : ScaleType.FIT_CENTER
|
||||||
context.save();
|
context.save();
|
||||||
context.clearRect(0, 0, compWidth, compHeight)
|
context.clearRect(0, 0, compWidth, compHeight)
|
||||||
|
|
|
@ -27,13 +27,13 @@ export class LoadDataShareFileClient implements IDataFetch {
|
||||||
onComplete(buf);
|
onComplete(buf);
|
||||||
fs.close(file.fd);
|
fs.close(file.fd);
|
||||||
}).catch((err:BusinessError) => {
|
}).catch((err:BusinessError) => {
|
||||||
onError('LoadDataShareFileClient fs.read err happend uri=' + request.loadSrc + " err.msg=" + err?.message + " err.code=" + err?.code)
|
onError('LoadDataShareFileClient fs.read err happened uri=' + request.loadSrc + " err.msg=" + err?.message + " err.code=" + err?.code)
|
||||||
})
|
})
|
||||||
}).catch((err:BusinessError) => {
|
}).catch((err:BusinessError) => {
|
||||||
onError('LoadDataShareFileClient fs.stat err happend uri=' + request.loadSrc + " err.msg=" + err?.message + " err.code=" + err?.code)
|
onError('LoadDataShareFileClient fs.stat err happened uri=' + request.loadSrc + " err.msg=" + err?.message + " err.code=" + err?.code)
|
||||||
})
|
})
|
||||||
}).catch((err:BusinessError) => {
|
}).catch((err:BusinessError) => {
|
||||||
onError('LoadDataShareFileClient fs.open err happend uri=' + request.loadSrc + " err.msg=" + err?.message + " err.code=" + err?.code)
|
onError('LoadDataShareFileClient fs.open err happened uri=' + request.loadSrc + " err.msg=" + err?.message + " err.code=" + err?.code)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ export namespace fastBlur {
|
||||||
//
|
//
|
||||||
// Java Author: Mario Klingemann <mario at quasimondo.com>
|
// Java Author: Mario Klingemann <mario at quasimondo.com>
|
||||||
// http://incubator.quasimondo.com
|
// http://incubator.quasimondo.com
|
||||||
// created Feburary 29, 2004
|
// created February 29, 2004
|
||||||
// port : Yahel Bouaziz <yahel at kayenko.com>
|
// port : Yahel Bouaziz <yahel at kayenko.com>
|
||||||
// http://www.kayenko.com
|
// http://www.kayenko.com
|
||||||
// ported april 5th, 2012
|
// ported april 5th, 2012
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "library",
|
"name": "sharedlibrary",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Please describe the basic information.",
|
"description": "Please describe the basic information.",
|
||||||
"main": "./src/main/ets/Index.ets",
|
"main": "./src/main/ets/Index.ets",
|
|
@ -22,15 +22,15 @@ struct Index {
|
||||||
|
|
||||||
@State imageOption1:ImageKnifeOption = {
|
@State imageOption1:ImageKnifeOption = {
|
||||||
loadSrc: $r('app.media.icon'),
|
loadSrc: $r('app.media.icon'),
|
||||||
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
|
context: getContext(this).createModuleContext('sharedlibrary') as common.UIAbilityContext
|
||||||
}
|
}
|
||||||
@State imageOption2:ImageKnifeOption = {
|
@State imageOption2:ImageKnifeOption = {
|
||||||
loadSrc: $r('app.media.icon'),
|
loadSrc: $r('app.media.icon'),
|
||||||
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
|
context: getContext(this).createModuleContext('sharedlibrary') as common.UIAbilityContext
|
||||||
}
|
}
|
||||||
@State imageOption3:ImageKnifeOption = {
|
@State imageOption3:ImageKnifeOption = {
|
||||||
loadSrc: $r('app.media.icon'),
|
loadSrc: $r('app.media.icon'),
|
||||||
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
|
context: getContext(this).createModuleContext('sharedlibrary') as common.UIAbilityContext
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
|
@ -40,27 +40,27 @@ struct Index {
|
||||||
this.imageOption1 = {
|
this.imageOption1 = {
|
||||||
loadSrc: $r('app.media.setting'),
|
loadSrc: $r('app.media.setting'),
|
||||||
// 只要涉及resource加载 在HSP中都要带上context属性
|
// 只要涉及resource加载 在HSP中都要带上context属性
|
||||||
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
|
context: getContext(this).createModuleContext('sharedlibrary') as common.UIAbilityContext
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ImageKnifeComponent({imageKnifeOption:this.imageOption1}).width(300).height(300).backgroundColor(Color.Pink)
|
ImageKnifeComponent({imageKnifeOption:this.imageOption1}).width(300).height(300).backgroundColor(Color.Pink)
|
||||||
Button('点击加载网络图片').onClick(()=>{
|
Button('点击加载网络图片').onClick(()=>{
|
||||||
this.imageOption2 = {
|
this.imageOption2 = {
|
||||||
loadSrc: 'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
|
loadSrc: 'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
|
||||||
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
|
context: getContext(this).createModuleContext('sharedlibrary') as common.UIAbilityContext
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ImageKnifeComponent({imageKnifeOption:this.imageOption2}).width(300).height(300).backgroundColor(Color.Pink)
|
ImageKnifeComponent({imageKnifeOption:this.imageOption2}).width(300).height(300).backgroundColor(Color.Pink)
|
||||||
|
|
||||||
Button('点击加载本地文件').onClick(()=>{
|
Button('点击加载本地文件').onClick(()=>{
|
||||||
getContext(this).createModuleContext('library').resourceManager.getMediaContent($r('app.media.setting').id).then((data:Uint8Array)=>{
|
getContext(this).createModuleContext('sharedlibrary').resourceManager.getMediaContent($r('app.media.setting').id).then((data:Uint8Array)=>{
|
||||||
let ctx = ImageKnifeGlobal.getInstance().getHapContext() as common.UIAbilityContext;
|
let ctx = ImageKnifeGlobal.getInstance().getHapContext() as common.UIAbilityContext;
|
||||||
let path = ctx.filesDir+"/set.jpeg";
|
let path = ctx.filesDir+"/set.jpeg";
|
||||||
FileUtils.getInstance().writeFile(path,data.buffer)
|
FileUtils.getInstance().writeFile(path,data.buffer)
|
||||||
FileUtils.getInstance().readFilePicAsync(path).then(buffer=>{
|
FileUtils.getInstance().readFilePicAsync(path).then(buffer=>{
|
||||||
this.imageOption3 = {
|
this.imageOption3 = {
|
||||||
loadSrc: path,
|
loadSrc: path,
|
||||||
context: getContext(this).createModuleContext('library') as common.UIAbilityContext
|
context: getContext(this).createModuleContext('sharedlibrary') as common.UIAbilityContext
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"module": {
|
"module": {
|
||||||
"name": "library",
|
"name": "sharedlibrary",
|
||||||
"type": "shared",
|
"type": "shared",
|
||||||
"description": "$string:shared_desc",
|
"description": "$string:shared_desc",
|
||||||
"deviceTypes": [
|
"deviceTypes": [
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Loading…
Reference in New Issue