From 2a81312ed5f31c1c2ea0b3b5c22a3487168a08b8 Mon Sep 17 00:00:00 2001 From: tyBrave Date: Sat, 12 Oct 2024 09:57:11 +0800 Subject: [PATCH 1/7] add get cache data Signed-off-by: tyBrave --- entry/src/main/ets/pages/Index.ets | 5 + .../src/main/ets/pages/TestCacheDataPage.ets | 100 ++++++++++++++++++ .../resources/base/profile/main_pages.json | 3 +- library/src/main/ets/ImageKnife.ets | 61 +++++++++++ 4 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 entry/src/main/ets/pages/TestCacheDataPage.ets diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 75fa2f2..6cbb7a6 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -159,6 +159,11 @@ struct Index { uri: 'pages/TestTaskResourcePage', }); }) + Button("测试缓存数据").margin({top:10}).onClick(()=>{ + router.push({ + uri: 'pages/TestCacheDataPage', + }); + }) } } .width('100%') .height('100%') diff --git a/entry/src/main/ets/pages/TestCacheDataPage.ets b/entry/src/main/ets/pages/TestCacheDataPage.ets new file mode 100644 index 0000000..3cdb530 --- /dev/null +++ b/entry/src/main/ets/pages/TestCacheDataPage.ets @@ -0,0 +1,100 @@ +import { ImageKnife, CacheStrategy, ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife'; + +@Entry +@ComponentV2 +struct TestCacheDataPage { + @Local cacheUpLimit: string = '当前缓存上限: 0M'; + @Local currentNum: string = '当前缓存图片数量: 0'; + @Local currentSize: string = '当前缓存的大小: 0M'; + @Local currentWidth: number = 200 + @Local currentHeight: number = 200 + @Local ImageKnifeOption: ImageKnifeOption = new ImageKnifeOption({ + loadSrc: "", + objectFit: ImageFit.Contain, + onLoadListener: { + onLoadFailed: (err) => { + console.error("Load Failed Reason: " + err); + }, + onLoadSuccess: (data) => { + return data; + }, + }, + border: { radius: 50 } + }) + + aboutToAppear(): void { + ImageKnife.getInstance().initFileCache(getContext(this), 256, 256 * 1024 * 1024,"ImageKnifeCache1") + } + + build() { + Column() { + + ImageKnifeComponent( + { imageKnifeOption: this.ImageKnifeOption }) + .height(this.currentHeight) + .width(this.currentWidth) + .margin({ top: 10 }) + + Button('内存加载图片') + .onClick(() => { + this.ImageKnifeOption = new ImageKnifeOption({ + loadSrc: "https://img0.baidu.com/it/u=1530797181,174436037&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800", + objectFit: ImageFit.Contain, + writeCacheStrategy:CacheStrategy.Memory, + border: { radius: 50 }, + }) + }) + Button('磁盘缓存加载图片') + .onClick(() => { + this.ImageKnifeOption = new ImageKnifeOption({ + loadSrc: "https://q7.itc.cn/images01/20240223/ce80229bf9934dff97cdf2ad7be1dcb8.jpeg", + objectFit: ImageFit.Contain, + writeCacheStrategy:CacheStrategy.File, + border: { radius: 50 }, + }) + }) + Text(this.cacheUpLimit).fontSize(20).margin({bottom:8}); + Text(this.currentNum).fontSize(20).margin({bottom:8}); + Text(this.currentSize).fontSize(20).margin({bottom:20}); + + Button("获取当前内存缓存上限").onClick(() => { + let result = ImageKnife.getInstance().getCacheUpperLimit(CacheStrategy.Memory); + if (result) { + this.cacheUpLimit = "当前缓存上限:" + (result/(1024*1024))+"M"; + } + }).margin({bottom:8}); + Button("获取当前内存缓存图片数量").onClick(() => { + let result = ImageKnife.getInstance().getCurrentPicturesNum(CacheStrategy.Memory); + if (result) { + this.currentNum = "当前缓存图片数量:" + result; + } + }).margin({bottom:8}); + Button("获取当前缓存的大小").onClick(() => { + let result = ImageKnife.getInstance().getCurrentCacheSize(CacheStrategy.Memory); + if (result) { + this.currentSize = "当前缓存的大小:" + (result/(1024*1024))+"M"; + } + }).margin({bottom:8}); + + Button("获取当前磁盘缓存上限").onClick(() => { + let result = ImageKnife.getInstance().getCacheUpperLimit(CacheStrategy.File); + if (result) { + this.cacheUpLimit = "当前缓存上限:" + (result/(1024*1024))+"M"; + } + }).margin({bottom:8}); + Button("获取当前磁盘缓存图片数量").onClick(() => { + let result = ImageKnife.getInstance().getCurrentPicturesNum(CacheStrategy.File); + if (result) { + this.currentNum = "当前缓存图片数量:" + result; + } + }).margin({bottom:8}); + Button("获取当前磁盘的大小").onClick(() => { + let result = ImageKnife.getInstance().getCurrentCacheSize(CacheStrategy.File); + if (result) { + this.currentSize = "当前缓存的大小:" + (result/(1024*1024))+"M"; + } + }).margin({bottom:8}); + } + .height('100%').width('100%').margin({top:50}) + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index d42cd2d..7b16f4e 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -22,6 +22,7 @@ "pages/ImageAnimatorPage", "pages/TestSetCustomImagePage", "pages/TestErrorHolderPage", - "pages/TestTaskResourcePage" + "pages/TestTaskResourcePage", + "pages/TestCacheDataPage" ] } \ No newline at end of file diff --git a/library/src/main/ets/ImageKnife.ets b/library/src/main/ets/ImageKnife.ets index 41eeb64..e91344a 100644 --- a/library/src/main/ets/ImageKnife.ets +++ b/library/src/main/ets/ImageKnife.ets @@ -302,6 +302,67 @@ export class ImageKnife { return this.fileCache as FileCache } + /** + * get cache upper limit + * @param cacheType + * @returns + */ + getCacheUpperLimit(cacheType?: CacheStrategy): number | undefined { + if (cacheType == undefined || cacheType == CacheStrategy.Default) { + cacheType = CacheStrategy.Memory; + } + if (cacheType == CacheStrategy.Memory) { + return (this.memoryCache as MemoryLruCache).maxMemory; + } else { + console.log("sss---->isFileCacheInit:"+this.fileCache) + if (this.isFileCacheInit()) { + return this.fileCache?.maxMemory; + } else { + throw new Error("the disk cache not init"); + } + } + } + + /** + * gets the number of images currently cached + * @param cacheType + * @returns + */ + getCurrentPicturesNum(cacheType: CacheStrategy): number | undefined { + if (cacheType == undefined || cacheType == CacheStrategy.Default) { + cacheType = CacheStrategy.Memory; + } + if (cacheType == CacheStrategy.Memory) { + return (this.memoryCache as MemoryLruCache).size(); + } else { + if (this.isFileCacheInit()) { + return this.fileCache?.size(); + } else { + throw new Error("the disk cache not init"); + } + } + } + + /** + * gets the current cache size + * @param cacheType + * @returns + */ + getCurrentCacheSize(cacheType: CacheStrategy): number | undefined { + if (cacheType == undefined || cacheType == CacheStrategy.Default) { + cacheType = CacheStrategy.Memory; + } + if (cacheType == CacheStrategy.Memory) { + return (this.memoryCache as MemoryLruCache).currentMemory; + } else { + if (this.isFileCacheInit()) { + return this.fileCache?.currentMemory; + } else { + throw new Error("the disk cache not init"); + } + } + } + private pixelMapToArrayBuffer(pixelMap: PixelMap): ArrayBuffer { let imageInfo = pixelMap.getImageInfoSync(); From 7b9da8d9fa756f0d78cf559ee249b6d959b88b3d Mon Sep 17 00:00:00 2001 From: tyBrave Date: Wed, 16 Oct 2024 10:40:22 +0800 Subject: [PATCH 2/7] add change color of image in lib Signed-off-by: tyBrave --- entry/src/main/ets/pages/Index.ets | 6 ++ .../main/ets/pages/TestChangeColorPage.ets | 97 ++++++++++++++++++ entry/src/main/resources/base/media/test.png | Bin 0 -> 9714 bytes .../main/resources/base/media/test_svg.svg | 9 ++ .../resources/base/profile/main_pages.json | 3 +- 5 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 entry/src/main/ets/pages/TestChangeColorPage.ets create mode 100644 entry/src/main/resources/base/media/test.png create mode 100644 entry/src/main/resources/base/media/test_svg.svg diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 6cbb7a6..aa6c080 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -164,6 +164,12 @@ struct Index { uri: 'pages/TestCacheDataPage', }); }) + Button("测试颜色变换").margin({top:10}).onClick(()=>{ + router.push({ + uri: 'pages/TestChangeColorPage', + }); + }) + } } .width('100%') .height('100%') diff --git a/entry/src/main/ets/pages/TestChangeColorPage.ets b/entry/src/main/ets/pages/TestChangeColorPage.ets new file mode 100644 index 0000000..87349bb --- /dev/null +++ b/entry/src/main/ets/pages/TestChangeColorPage.ets @@ -0,0 +1,97 @@ +import { drawing, common2D } from '@kit.ArkGraphics2D'; +import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife'; + +@Entry +@Component +struct TestChangeColorPage { + private imageOne: Resource = $r('app.media.test'); + private imageTwo: Resource = $r('app.media.test'); + @State src: Resource = this.imageOne + @State src2: Resource = this.imageTwo + @State color: common2D.Color = { + alpha: 255, + red: 255, + green: 1, + blue: 1 + }; + @State DrawingColorFilterFirst: ColorFilter | undefined = undefined + + build() { + Column() { + Text("点击选择要更改的颜色").margin({ top: 20 }) + Row() { + Button("红色").backgroundColor(Color.Red).margin(5).onClick(() => { + this.color = { + alpha: 255, + red: 255, + green: 1, + blue: 1 + }; + }) + Button("黄色").backgroundColor(Color.Yellow).margin(5).onClick(() => { + this.color = { + alpha: 255, + red: 255, + green: 255, + blue: 1 + }; + }) + Button("绿色").backgroundColor(Color.Green).margin(5).onClick(() => { + this.color = { + alpha: 255, + red: 1, + green: 255, + blue: 1 + }; + }) + Button("蓝色").backgroundColor(Color.Blue).margin(5).onClick(() => { + this.color = { + alpha: 255, + red: 1, + green: 1, + blue: 255 + }; + }) + } + .width('100%') + .height(50) + .justifyContent(FlexAlign.Center) + + Text("原图:").margin({ top: 20 }) + ImageKnifeComponent({ + imageKnifeOption: new ImageKnifeOption({ + loadSrc: this.src + }) + }).width(110).height(110) + + Text("点击图片更改图片颜色:").margin({ top: 30 }) + ImageKnifeComponent({ + imageKnifeOption: new ImageKnifeOption({ + loadSrc: this.src, + drawingColorFilter: this.DrawingColorFilterFirst + }) + }) + .onClick(() => { + this.DrawingColorFilterFirst = + drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN); + }).width(110).height(110) + + Text("测试非svg图片变色").margin({ top: 30 }) + ImageKnifeComponent({ + imageKnifeOption: new ImageKnifeOption({ + loadSrc: $r('app.media.test'), + drawingColorFilter: drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN) + }) + }).width(110).height(110) + + Text("测试svg图片变色").margin({ top: 30 }) + ImageKnifeComponent({ + imageKnifeOption: new ImageKnifeOption({ + loadSrc: $r("app.media.test_svg"), + drawingColorFilter: drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN) + }) + }).width(110).height(110) + + }.width('100%').height('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/test.png b/entry/src/main/resources/base/media/test.png new file mode 100644 index 0000000000000000000000000000000000000000..b0d65d0fa431513655312e60e316a49675bdba52 GIT binary patch literal 9714 zcmX|{byyVN8}?_H6?X-sOKORwTRN8zSe6h_O2GvMq`M?s5J99{I$TA%OKKGrGXGWEdBRByOPMC?!+mYG>wdXPq~OJkkQ%Owz;%%;B|D|T z9}R^nfOFi%Z!Tw%^^EI_Z3lGRveZ{!6`M~>$Z(bL$XqQs#D$*TOZ`7)K94P7U=<*R z^xIq8$L{tXu31|_Jas0n>`^he%9GjI!(xf=EOFQA{YcBubIxteIK|;O=@)%nZ|Bzz z&f>X@$*fY~6p;JD@N!{$dQ^iBbnVed_Woi(lc z+orHCvTpL53w=3GMTvwm>xMIOQa~`IpKy~Rx`C-@R*RH#HJB=XznznXg0LIcGm;tr z&mKfIT*OM<)8Na5yM3i%thA$$0$(p269TT8htHWPQzw z$49`qFOhRuE+iZbP^VJh6hu$m&Su$Eahqc;(vJcujkjL#?I=nu35CkVs#D+{@~+!~ z@%*iVZ!kac5RemNUN+*Q6(?_UiqWh&W#8394Wt}I1~=$lZNRaA&++5e0SmQrW1a|U6WZbTXDI9wr7C^L< z$wcGH2}m6=tX=RZ3@WD_JVdoj_s4tLo(f&I?up!g{CEf<^{@HFwKVZkXQ-aKYdikH z8q?uMC&dG9jKr-Xn#%Y{g|+3Lppvp-?I%IAO`eko4lF5MyKdL*q~pVGbKvkAP9$fr6S7^@?j>Jr?*kZic`}5IbS!|YRp4Uf z1@J66 z!5?!a<=WWjY8;H0Aga=72y7rJS2o_rwI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$Mnq{X3CEmki8&+~S|*(S?z}TIr~R4z?f;-3Jj0;wTeT~fbkhGz!Sp2syU0b3 zYYIZ)@=Kqqxo{Qq?VC%kst+ZD`A{D?)B1NNAJ(}n#K6G3%J|V_uae|LVnZzaqmzys zx7>J=67TvFpKtw9+YQi&v}zW|R)QADnm2p@g`g_V(5~RGyarYC$^Yn`US#QW;;$Jv zg-7S6VuF_z=x-beKDfSxZl<6;*GrD)cZ~V|gM@DDblX}8C43R*du&d{LlGt=a`gvI zr{mx=1IxC!JWCSNIWm&3mliG|y{2rw6Mw6ceZ-?Wrgi&4lY8Rb`2lw)G>ygoXd`tA zP72--Bn1*S^1dILM|I5z@iV@8t^vRQAD~0^Ni#bHiMU?R2jUdJqLF!!>+Fd8adJc< n+SiZw(=&JhV+axkxg>wF{9UIvDgVti#08-4>8Y2iVnY89#rp+g literal 0 HcmV?d00001 diff --git a/entry/src/main/resources/base/media/test_svg.svg b/entry/src/main/resources/base/media/test_svg.svg new file mode 100644 index 0000000..9910b1d --- /dev/null +++ b/entry/src/main/resources/base/media/test_svg.svg @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 7b16f4e..e553510 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -23,6 +23,7 @@ "pages/TestSetCustomImagePage", "pages/TestErrorHolderPage", "pages/TestTaskResourcePage", - "pages/TestCacheDataPage" + "pages/TestCacheDataPage", + "pages/TestChangeColorPage" ] } \ No newline at end of file From ec651e91dfb91beb37e48d6f6b81e0c71102e44a Mon Sep 17 00:00:00 2001 From: tyBrave Date: Wed, 16 Oct 2024 10:56:06 +0800 Subject: [PATCH 3/7] add test cancel callback demo Signed-off-by: tyBrave --- entry/src/main/ets/pages/Index.ets | 6 ++ .../ets/pages/TestLoadCancelListenerPage.ets | 93 +++++++++++++++++++ .../resources/base/profile/main_pages.json | 3 +- 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 entry/src/main/ets/pages/TestLoadCancelListenerPage.ets diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index aa6c080..697f387 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -167,9 +167,15 @@ struct Index { Button("测试颜色变换").margin({top:10}).onClick(()=>{ router.push({ uri: 'pages/TestChangeColorPage', + }); }) + Button("测试加载取消回调接口").margin({top:10}).onClick(()=>{ + router.push({ + uri: 'pages/TestLoadCancelListenerPage', + }); + }) } } .width('100%') .height('100%') diff --git a/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets b/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets new file mode 100644 index 0000000..cc071b3 --- /dev/null +++ b/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2024 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 } from '@ohos/imageknife'; + +@Entry +@ComponentV2 +struct TestLoadCancelListenerPage { + @Local currentWidth: number = 200 + @Local currentHeight: number = 200 + @Local showChild: boolean = true; + @Local text: string = "onLoadCancel回调原因:"; + @Local ImageKnifeOption: ImageKnifeOption = new ImageKnifeOption({ + loadSrc: "", + objectFit: ImageFit.Contain, + border: { radius: 50 } + }) + + build() { + Column() { + Text(this.text).margin(20).fontSize(15) + Button('移除组件-网络加载图片') + .margin(20) + .onClick(() => { + this.ImageKnifeOption = new ImageKnifeOption({ + loadSrc: "https://q7.itc.cn/images01/20240223/ce80229bf9934dff97cdf2ad7be1dcb8.jpeg", + objectFit: ImageFit.Contain, + onLoadListener: { + onLoadStart: (data) => { + this.showChild = false; + }, + onLoadCancel: (res, data) => { + this.text = "onLoadCancel回调成功,网络nLoadCancel回调原因:" + res + console.log("TestLoadCancelListenerPage----onLoadCancel> url:" + res) + } + }, + border: { radius: 50 } + }) + }) + + Button('恢复组件显示') + .margin(20).onClick(() => { + this.showChild = true; + this.ImageKnifeOption = new ImageKnifeOption({ + loadSrc: "", + objectFit: ImageFit.Contain, + border: { radius: 50 } + }) + }) + Button('移除组件-本地资源图片') + .margin(20) + .onClick(() => { + this.ImageKnifeOption = new ImageKnifeOption({ + loadSrc: $r('app.media.loading'), + objectFit: ImageFit.Contain, + onLoadListener: { + onLoadStart: (data) => { + this.showChild = false; + }, + onLoadCancel: (res, data) => { + this.text = "onLoadCancel回调成功,本地onLoadCancel回调原因:" + res + console.log("TestLoadCancelListenerPage----onLoadCancel> url:" + res) + } + }, + border: { radius: 50 } + }) + }) + + if (this.showChild) { + ImageKnifeComponent( + { imageKnifeOption: this.ImageKnifeOption }) + .height(150) + .width(150) + .backgroundColor(Color.Orange) + .margin({ top: 20 }) + } + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index e553510..35d7d51 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -24,6 +24,7 @@ "pages/TestErrorHolderPage", "pages/TestTaskResourcePage", "pages/TestCacheDataPage", - "pages/TestChangeColorPage" + "pages/TestChangeColorPage", + "pages/TestLoadCancelListenerPage" ] } \ No newline at end of file From 1027fc0304bf11a915334b8cc8edf23bc86aa89e Mon Sep 17 00:00:00 2001 From: tyBrave Date: Wed, 16 Oct 2024 10:57:36 +0800 Subject: [PATCH 4/7] add xts test get size and format in image of callback Signed-off-by: tyBrave --- .../ets/test/imageFormatAndSize.test.ets | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets diff --git a/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets b/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets new file mode 100644 index 0000000..0f00344 --- /dev/null +++ b/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2024 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { + ImageKnifeOption, + ImageKnife, + ImageKnifeRequest, + ImageKnifeRequestSource +} from "@ohos/imageknife" +import { common } from '@kit.AbilityKit'; + +export default function ImageKnifeOptionTest() { + describe('imageFormatAndSize', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('getImageSizeInCache', 0, () => { + let width = 0; + let height = 0; + let imageFormat: string = ""; + + let imageKnifeOption: ImageKnifeOption = new ImageKnifeOption({ + loadSrc: "https://q7.itc.cn/images01/20240223/ce80229bf9934dff97cdf2ad7be1dcb8.jpeg", + onLoadListener: { + onLoadSuccess: (data, imageknifeData) => { + width = imageknifeData.imageWidth! + height = imageknifeData.imageHeight! + imageFormat = imageknifeData.type! + return data; + }, + }, + }) + + let request = new ImageKnifeRequest( + imageKnifeOption, + getContext() as common.UIAbilityContext, + 100, + 100, + 0, + { + showPixelMap: async (version: number, pixelMap: PixelMap | string, + requestSource: ImageKnifeRequestSource) => { + } + }) + ImageKnife.getInstance().execute(request); + expect(width != 0).assertTrue(); + expect(height != 0).assertTrue(); + expect(imageFormat != "").assertTrue(); + }); + }); + + +} + From e31c592ee4d7388007c1ef38ec53fb8347c1629b Mon Sep 17 00:00:00 2001 From: tyBrave Date: Wed, 16 Oct 2024 15:56:42 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9onLoadCancel=E5=9B=9E?= =?UTF-8?q?=E8=B0=83demo=E5=8F=8A=E5=85=B6=E7=BC=93=E5=AD=98=E4=B8=AD?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=9B=BE=E7=89=87=E7=9A=84=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tyBrave --- entry/src/main/ets/pages/LoadStatePage.ets | 4 +++- entry/src/main/ets/pages/TestLoadCancelListenerPage.ets | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/entry/src/main/ets/pages/LoadStatePage.ets b/entry/src/main/ets/pages/LoadStatePage.ets index 2c0c4d8..a697c75 100644 --- a/entry/src/main/ets/pages/LoadStatePage.ets +++ b/entry/src/main/ets/pages/LoadStatePage.ets @@ -79,7 +79,9 @@ struct LoadStatePage { }) } .margin({ top: 20 }) - Text(this.typeValue) + Text("格式:"+this.typeValue) + Text("宽度:"+this.currentWidth) + Text("高度:"+this.currentHeight) ImageKnifeComponent({ imageKnifeOption: this.ImageKnifeOption }).height(this.currentHeight).width(this.currentWidth) .margin({ top: 20 }) Button($r('app.string.Custom_download_failed')).onClick(()=>{ diff --git a/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets b/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets index cc071b3..d6d1685 100644 --- a/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets +++ b/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets @@ -38,10 +38,10 @@ struct TestLoadCancelListenerPage { loadSrc: "https://q7.itc.cn/images01/20240223/ce80229bf9934dff97cdf2ad7be1dcb8.jpeg", objectFit: ImageFit.Contain, onLoadListener: { - onLoadStart: (data) => { + onLoadStart: () => { this.showChild = false; }, - onLoadCancel: (res, data) => { + onLoadCancel: (res) => { this.text = "onLoadCancel回调成功,网络nLoadCancel回调原因:" + res console.log("TestLoadCancelListenerPage----onLoadCancel> url:" + res) } @@ -66,10 +66,10 @@ struct TestLoadCancelListenerPage { loadSrc: $r('app.media.loading'), objectFit: ImageFit.Contain, onLoadListener: { - onLoadStart: (data) => { + onLoadStart: () => { this.showChild = false; }, - onLoadCancel: (res, data) => { + onLoadCancel: (res) => { this.text = "onLoadCancel回调成功,本地onLoadCancel回调原因:" + res console.log("TestLoadCancelListenerPage----onLoadCancel> url:" + res) } From 8e55d336f99b8610a648f7e059904c859f7652bc Mon Sep 17 00:00:00 2001 From: tyBrave Date: Wed, 16 Oct 2024 17:17:02 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E4=B8=AD=E7=9A=84=E5=9B=BE=E7=89=87=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=A4=A7=E5=B0=8F=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tyBrave --- .../main/ets/pages/TestChangeColorPage.ets | 15 +++++ entry/src/ohosTest/ets/test/List.test.ets | 2 + .../ets/test/imageFormatAndSize.test.ets | 60 +++++++++---------- 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/entry/src/main/ets/pages/TestChangeColorPage.ets b/entry/src/main/ets/pages/TestChangeColorPage.ets index 87349bb..665386d 100644 --- a/entry/src/main/ets/pages/TestChangeColorPage.ets +++ b/entry/src/main/ets/pages/TestChangeColorPage.ets @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2024 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 { drawing, common2D } from '@kit.ArkGraphics2D'; import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife'; diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets index 8c04309..1b17e5f 100644 --- a/entry/src/ohosTest/ets/test/List.test.ets +++ b/entry/src/ohosTest/ets/test/List.test.ets @@ -18,6 +18,7 @@ import ImageKnifeOptionTest from './ImageKnifeOption.test'; import MemoryLruCacheTest from './MemoryLruCache.test'; import ImageKnifeTest from './ImageKnife.test'; import Transform from './transform.test'; +import imageFormatAndSize from './imageFormatAndSize.test' export default function testsuite() { MemoryLruCacheTest(); @@ -26,4 +27,5 @@ export default function testsuite() { ImageKnifeOptionTest(); ImageKnifeTest(); Transform(); + imageFormatAndSize(); } \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets b/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets index 0f00344..3faa0a6 100644 --- a/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets +++ b/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets @@ -13,15 +13,10 @@ * limitations under the License. */ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; -import { - ImageKnifeOption, - ImageKnife, - ImageKnifeRequest, - ImageKnifeRequestSource -} from "@ohos/imageknife" +import { ImageKnifeOption, ImageKnife, ImageKnifeRequest, ImageKnifeRequestSource } from "@ohos/imageknife" import { common } from '@kit.AbilityKit'; -export default function ImageKnifeOptionTest() { +export default function imageFormatAndSize() { describe('imageFormatAndSize', () => { // Defines a test suite. Two parameters are supported: test suite name and test suite function. beforeAll(() => { @@ -42,41 +37,42 @@ export default function ImageKnifeOptionTest() { // Presets a clear action, which is performed after all test cases of the test suite end. // This API supports only one parameter: clear action function. }); - it('getImageSizeInCache', 0, () => { + it('getImageSizeInCache', 0, async () => { let width = 0; let height = 0; let imageFormat: string = ""; let imageKnifeOption: ImageKnifeOption = new ImageKnifeOption({ - loadSrc: "https://q7.itc.cn/images01/20240223/ce80229bf9934dff97cdf2ad7be1dcb8.jpeg", - onLoadListener: { - onLoadSuccess: (data, imageknifeData) => { - width = imageknifeData.imageWidth! - height = imageknifeData.imageHeight! - imageFormat = imageknifeData.type! - return data; - }, - }, + loadSrc: $r('app.media.icon'), }) - - let request = new ImageKnifeRequest( - imageKnifeOption, - getContext() as common.UIAbilityContext, - 100, - 100, - 0, - { - showPixelMap: async (version: number, pixelMap: PixelMap | string, - requestSource: ImageKnifeRequestSource) => { + await new Promise((resolve, reject) => { + imageKnifeOption.onLoadListener = { + onLoadSuccess: (data, imageknifeData) => { + width = imageknifeData.imageWidth + height = imageknifeData.imageHeight + imageFormat = imageknifeData.type! + resolve("") + }, + onLoadFailed(err) { + reject(err) } - }) - ImageKnife.getInstance().execute(request); + } + let request = new ImageKnifeRequest( + imageKnifeOption, + imageKnifeOption.context !== undefined ? imageKnifeOption.context : getContext() as common.UIAbilityContext, + 0, + 0, + 0, + { + showPixelMap(version: number, pixelMap: PixelMap | string) { + } + } + ) + ImageKnife.getInstance().execute(request); + }) expect(width != 0).assertTrue(); expect(height != 0).assertTrue(); expect(imageFormat != "").assertTrue(); }); }); - - } - From d82d85ea199a591811b7317ed13c2e5f02bfebfb Mon Sep 17 00:00:00 2001 From: tyBrave Date: Wed, 16 Oct 2024 17:31:56 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E6=97=A5=E5=BF=97=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tyBrave TestCacheDataPage 文件添加版权头 Signed-off-by: tyBrave 资源国际化 Signed-off-by: tyBrave add TIPS text dec Signed-off-by: tyBrave update code because of checkcode Signed-off-by: tyBrave update code because of use image url Signed-off-by: tyBrave --- entry/src/main/ets/pages/Index.ets | 68 +++++----- entry/src/main/ets/pages/LoadStatePage.ets | 6 +- .../src/main/ets/pages/TestCacheDataPage.ets | 104 +++++++++----- .../main/ets/pages/TestChangeColorPage.ets | 26 ++-- .../ets/pages/TestLoadCancelListenerPage.ets | 17 +-- .../main/resources/base/element/string.json | 128 ++++++++++++++++++ .../base/media/ic_test_change_color_png.png | Bin 0 -> 3440 bytes .../base/media/ic_test_change_color_svg.svg | 14 ++ entry/src/main/resources/base/media/test.png | Bin 9714 -> 0 bytes .../main/resources/base/media/test_svg.svg | 9 -- .../main/resources/zh_CN/element/string.json | 128 ++++++++++++++++++ .../ets/test/imageFormatAndSize.test.ets | 25 +++- library/src/main/ets/ImageKnife.ets | 1 - 13 files changed, 418 insertions(+), 108 deletions(-) create mode 100644 entry/src/main/resources/base/media/ic_test_change_color_png.png create mode 100644 entry/src/main/resources/base/media/ic_test_change_color_svg.svg delete mode 100644 entry/src/main/resources/base/media/test.png delete mode 100644 entry/src/main/resources/base/media/test_svg.svg diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 697f387..45db76e 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -17,125 +17,125 @@ import router from '@system.router'; @Entry @ComponentV2 struct Index { - - getResourceString(res:Resource){ + getResourceString(res: Resource) { return getContext().resourceManager.getStringSync(res.id) } - aboutToAppear(): void { } build() { - Scroll(){ + Scroll() { Column() { - Button($r('app.string.Test_ImageAnimator')).onClick(()=>{ + Button($r('app.string.Test_ImageAnimator')).onClick(() => { router.push({ uri: 'pages/ImageAnimatorPage', }); }) - Button($r('app.string.Test_multiple_images')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Test_multiple_images')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestCommonImage', }); }) - Button(this.getResourceString($r('app.string.Multiple_images')) + " + reuse + LazyForeach").margin({top:10}).onClick(()=>{ - router.push({ - uri: 'pages/UserPage', + Button(this.getResourceString($r('app.string.Multiple_images')) + " + reuse + LazyForeach") + .margin({ top: 10 }) + .onClick(() => { + router.push({ + uri: 'pages/UserPage', - }); - }) - Button($r('app.string.Test_SingleImage')).margin({top:10}).onClick(()=>{ + }); + }) + Button($r('app.string.Test_SingleImage')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/SingleImage', }); }) - Button($r('app.string.Display_long_image')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Display_long_image')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/LongImagePage', }); }) - Button($r('app.string.Image_Transformation')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Image_Transformation')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/ImageTransformation', }); }) - Button($r('app.string.Test_media_URL')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Test_media_URL')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/dataShareUriLoadPage', }); }) - Button($r('app.string.Different_ObjectFit')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Different_ObjectFit')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/ObjectFitPage', }); }) - Button($r('app.string.Custom_cache_key')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Custom_cache_key')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/SignatureTestPage', }); }) - Button($r('app.string.Test_image_loading_success_or_failure_events')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Test_image_loading_success_or_failure_events')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/LoadStatePage', }) }) - Button($r('app.string.Image_scaling')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Image_scaling')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TransformPage', }); }) - Button($r('app.string.Test_HSP')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Test_HSP')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestHspPreLoadImage', }); }) - Button($r('app.string.Test_custom_download')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Test_custom_download')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestSetCustomImagePage', }); }) - Button(this.getResourceString($r('app.string.Message_list')) + " + List").margin({top:10}).onClick(()=>{ + Button(this.getResourceString($r('app.string.Message_list')) + " + List").margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestImageFlash', }); }) - Button($r('app.string.Preloading_images_to_cache')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Preloading_images_to_cache')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestPrefetchToFileCache', }); }) - Button($r('app.string.Retrieve_image_display_from_cache')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Retrieve_image_display_from_cache')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestIsUrlExist', }); }) - Button($r('app.string.Test_single_request_header')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Test_single_request_header')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestHeader', }); }) - Button($r('app.string.Test_write_cache_strategy')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Test_write_cache_strategy')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestWriteCacheStage', @@ -143,41 +143,39 @@ struct Index { }) - Button($r('app.string.Test_removing_image_cache_interface')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Test_removing_image_cache_interface')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestRemoveCache', }); }) - Button($r('app.string.Test_error_image_display')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Test_error_image_display')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestErrorHolderPage', }); }) - Button($r('app.string.Test_Task_error')).margin({top:10}).onClick(()=>{ + Button($r('app.string.Test_Task_error')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestTaskResourcePage', }); }) - Button("测试缓存数据").margin({top:10}).onClick(()=>{ + Button($r('app.string.test_cache_btn')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestCacheDataPage', }); }) - Button("测试颜色变换").margin({top:10}).onClick(()=>{ + Button($r('app.string.test_change_color_btn')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestChangeColorPage', - }); }) - Button("测试加载取消回调接口").margin({top:10}).onClick(()=>{ + Button($r('app.string.test_cancel_callback_btn')).margin({ top: 10 }).onClick(() => { router.push({ uri: 'pages/TestLoadCancelListenerPage', - }); }) } - } .width('100%') + }.width('100%') .height('100%') } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/LoadStatePage.ets b/entry/src/main/ets/pages/LoadStatePage.ets index a697c75..876a74e 100644 --- a/entry/src/main/ets/pages/LoadStatePage.ets +++ b/entry/src/main/ets/pages/LoadStatePage.ets @@ -79,9 +79,9 @@ struct LoadStatePage { }) } .margin({ top: 20 }) - Text("格式:"+this.typeValue) - Text("宽度:"+this.currentWidth) - Text("高度:"+this.currentHeight) + Text($r('app.string.image_format',this.typeValue)) + Text($r('app.string.image_width',this.currentWidth)) + Text($r('app.string.image_height',this.currentHeight)) ImageKnifeComponent({ imageKnifeOption: this.ImageKnifeOption }).height(this.currentHeight).width(this.currentWidth) .margin({ top: 20 }) Button($r('app.string.Custom_download_failed')).onClick(()=>{ diff --git a/entry/src/main/ets/pages/TestCacheDataPage.ets b/entry/src/main/ets/pages/TestCacheDataPage.ets index 3cdb530..e8da530 100644 --- a/entry/src/main/ets/pages/TestCacheDataPage.ets +++ b/entry/src/main/ets/pages/TestCacheDataPage.ets @@ -1,13 +1,31 @@ +/* + * Copyright (C) 2024 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 { ImageKnife, CacheStrategy, ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife'; @Entry @ComponentV2 struct TestCacheDataPage { - @Local cacheUpLimit: string = '当前缓存上限: 0M'; - @Local currentNum: string = '当前缓存图片数量: 0'; - @Local currentSize: string = '当前缓存的大小: 0M'; + @Local cacheUpLimit: number = 0; + @Local currentNum: number = 0; + @Local currentSize: number = 0; @Local currentWidth: number = 200 @Local currentHeight: number = 200 + @Local markersLimitText: string = getContext(this).resourceManager.getStringSync($r('app.string.memory')) + @Local markersNumText: string = getContext(this).resourceManager.getStringSync($r('app.string.memory')) + @Local markersSizeText: string = getContext(this).resourceManager.getStringSync($r('app.string.memory')) @Local ImageKnifeOption: ImageKnifeOption = new ImageKnifeOption({ loadSrc: "", objectFit: ImageFit.Contain, @@ -23,7 +41,7 @@ struct TestCacheDataPage { }) aboutToAppear(): void { - ImageKnife.getInstance().initFileCache(getContext(this), 256, 256 * 1024 * 1024,"ImageKnifeCache1") + ImageKnife.getInstance().initFileCache(getContext(this), 256, 256 * 1024 * 1024, "ImageKnifeCache1") } build() { @@ -35,66 +53,88 @@ struct TestCacheDataPage { .width(this.currentWidth) .margin({ top: 10 }) - Button('内存加载图片') + Button($r('app.string.load_memory')) .onClick(() => { this.ImageKnifeOption = new ImageKnifeOption({ - loadSrc: "https://img0.baidu.com/it/u=1530797181,174436037&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800", + loadSrc: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg", objectFit: ImageFit.Contain, - writeCacheStrategy:CacheStrategy.Memory, + writeCacheStrategy: CacheStrategy.Memory, border: { radius: 50 }, }) }) - Button('磁盘缓存加载图片') + Button($r('app.string.load_disk')) .onClick(() => { this.ImageKnifeOption = new ImageKnifeOption({ - loadSrc: "https://q7.itc.cn/images01/20240223/ce80229bf9934dff97cdf2ad7be1dcb8.jpeg", + loadSrc: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg", objectFit: ImageFit.Contain, - writeCacheStrategy:CacheStrategy.File, + writeCacheStrategy: CacheStrategy.File, border: { radius: 50 }, }) }) - Text(this.cacheUpLimit).fontSize(20).margin({bottom:8}); - Text(this.currentNum).fontSize(20).margin({bottom:8}); - Text(this.currentSize).fontSize(20).margin({bottom:20}); + Text($r('app.string.cur_cache_limit', this.markersLimitText, this.cacheUpLimit)) + .fontSize(20) + .margin({ bottom: 8 }); + Text($r('app.string.cur_cache_image_num', this.markersNumText, this.currentNum)) + .fontSize(20) + .margin({ bottom: 8 }); + Text($r('app.string.cur_cache_size', this.markersSizeText, this.currentSize)).fontSize(20).margin({ bottom: 20 }); - Button("获取当前内存缓存上限").onClick(() => { + Button($r('app.string.get_cur_memory_limit')).onClick(() => { let result = ImageKnife.getInstance().getCacheUpperLimit(CacheStrategy.Memory); + this.markersLimitText = getContext(this).resourceManager.getStringSync($r('app.string.memory')) if (result) { - this.cacheUpLimit = "当前缓存上限:" + (result/(1024*1024))+"M"; + this.cacheUpLimit = result / (1024 * 1024); + } else { + this.cacheUpLimit = 0; } - }).margin({bottom:8}); - Button("获取当前内存缓存图片数量").onClick(() => { + }).margin({ bottom: 8 }); + Button($r('app.string.get_img_number_of_cache')).onClick(() => { let result = ImageKnife.getInstance().getCurrentPicturesNum(CacheStrategy.Memory); + this.markersNumText = getContext(this).resourceManager.getStringSync($r('app.string.memory')) if (result) { - this.currentNum = "当前缓存图片数量:" + result; + this.currentNum = result; + } else { + this.currentNum = 0; } - }).margin({bottom:8}); - Button("获取当前缓存的大小").onClick(() => { + }).margin({ bottom: 8 }); + Button($r('app.string.get_cur_memory_size')).onClick(() => { let result = ImageKnife.getInstance().getCurrentCacheSize(CacheStrategy.Memory); + this.markersSizeText = getContext(this).resourceManager.getStringSync($r('app.string.memory')) if (result) { - this.currentSize = "当前缓存的大小:" + (result/(1024*1024))+"M"; + this.currentSize = result / (1024 * 1024); + } else { + this.currentSize = 0; } - }).margin({bottom:8}); + }).margin({ bottom: 8 }); - Button("获取当前磁盘缓存上限").onClick(() => { + Button($r('app.string.get_cur_disk_limit')).onClick(() => { let result = ImageKnife.getInstance().getCacheUpperLimit(CacheStrategy.File); + this.markersLimitText = getContext(this).resourceManager.getStringSync($r('app.string.disk')) if (result) { - this.cacheUpLimit = "当前缓存上限:" + (result/(1024*1024))+"M"; + this.cacheUpLimit = result / (1024 * 1024); + } else { + this.cacheUpLimit = 0; } - }).margin({bottom:8}); - Button("获取当前磁盘缓存图片数量").onClick(() => { + }).margin({ bottom: 8 }); + Button($r('app.string.get_img_number_of_disk')).onClick(() => { let result = ImageKnife.getInstance().getCurrentPicturesNum(CacheStrategy.File); + this.markersNumText = getContext(this).resourceManager.getStringSync($r('app.string.disk')) if (result) { - this.currentNum = "当前缓存图片数量:" + result; + this.currentNum = result; + } else { + this.currentNum = 0; } - }).margin({bottom:8}); - Button("获取当前磁盘的大小").onClick(() => { + }).margin({ bottom: 8 }); + Button($r('app.string.get_cur_disk_size')).onClick(() => { let result = ImageKnife.getInstance().getCurrentCacheSize(CacheStrategy.File); + this.markersSizeText = getContext(this).resourceManager.getStringSync($r('app.string.disk')) if (result) { - this.currentSize = "当前缓存的大小:" + (result/(1024*1024))+"M"; + this.currentSize = result / (1024 * 1024); + } else { + this.currentSize = 0; } - }).margin({bottom:8}); + }).margin({ bottom: 8 }); } - .height('100%').width('100%').margin({top:50}) + .height('100%').width('100%').margin({ top: 50 }) } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/TestChangeColorPage.ets b/entry/src/main/ets/pages/TestChangeColorPage.ets index 665386d..2a282ae 100644 --- a/entry/src/main/ets/pages/TestChangeColorPage.ets +++ b/entry/src/main/ets/pages/TestChangeColorPage.ets @@ -19,8 +19,8 @@ import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife'; @Entry @Component struct TestChangeColorPage { - private imageOne: Resource = $r('app.media.test'); - private imageTwo: Resource = $r('app.media.test'); + private imageOne: Resource = $r('app.media.ic_test_change_color_png'); + private imageTwo: Resource = $r('app.media.ic_test_change_color_png'); @State src: Resource = this.imageOne @State src2: Resource = this.imageTwo @State color: common2D.Color = { @@ -33,9 +33,9 @@ struct TestChangeColorPage { build() { Column() { - Text("点击选择要更改的颜色").margin({ top: 20 }) + Text($r('app.string.select_color_btn')).margin({ top: 20 }) Row() { - Button("红色").backgroundColor(Color.Red).margin(5).onClick(() => { + Button($r('app.string.red')).backgroundColor(Color.Red).margin(5).onClick(() => { this.color = { alpha: 255, red: 255, @@ -43,7 +43,7 @@ struct TestChangeColorPage { blue: 1 }; }) - Button("黄色").backgroundColor(Color.Yellow).margin(5).onClick(() => { + Button($r('app.string.yellow')).backgroundColor(Color.Yellow).margin(5).onClick(() => { this.color = { alpha: 255, red: 255, @@ -51,7 +51,7 @@ struct TestChangeColorPage { blue: 1 }; }) - Button("绿色").backgroundColor(Color.Green).margin(5).onClick(() => { + Button($r('app.string.green')).backgroundColor(Color.Green).margin(5).onClick(() => { this.color = { alpha: 255, red: 1, @@ -59,7 +59,7 @@ struct TestChangeColorPage { blue: 1 }; }) - Button("蓝色").backgroundColor(Color.Blue).margin(5).onClick(() => { + Button($r('app.string.blue')).backgroundColor(Color.Blue).margin(5).onClick(() => { this.color = { alpha: 255, red: 1, @@ -72,14 +72,14 @@ struct TestChangeColorPage { .height(50) .justifyContent(FlexAlign.Center) - Text("原图:").margin({ top: 20 }) + Text($r('app.string.master_image')).margin({ top: 20 }) ImageKnifeComponent({ imageKnifeOption: new ImageKnifeOption({ loadSrc: this.src }) }).width(110).height(110) - Text("点击图片更改图片颜色:").margin({ top: 30 }) + Text($r('app.string.click_img_to_change_color')).margin({ top: 30 }) ImageKnifeComponent({ imageKnifeOption: new ImageKnifeOption({ loadSrc: this.src, @@ -91,18 +91,18 @@ struct TestChangeColorPage { drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN); }).width(110).height(110) - Text("测试非svg图片变色").margin({ top: 30 }) + Text($r('app.string.test_non_svg_color')).margin({ top: 30 }) ImageKnifeComponent({ imageKnifeOption: new ImageKnifeOption({ - loadSrc: $r('app.media.test'), + loadSrc: $r('app.media.ic_test_change_color_png'), drawingColorFilter: drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN) }) }).width(110).height(110) - Text("测试svg图片变色").margin({ top: 30 }) + Text($r('app.string.test_svg_color')).margin({ top: 30 }) ImageKnifeComponent({ imageKnifeOption: new ImageKnifeOption({ - loadSrc: $r("app.media.test_svg"), + loadSrc: $r("app.media.ic_test_change_color_svg"), drawingColorFilter: drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN) }) }).width(110).height(110) diff --git a/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets b/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets index d6d1685..5e97810 100644 --- a/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets +++ b/entry/src/main/ets/pages/TestLoadCancelListenerPage.ets @@ -21,7 +21,7 @@ struct TestLoadCancelListenerPage { @Local currentWidth: number = 200 @Local currentHeight: number = 200 @Local showChild: boolean = true; - @Local text: string = "onLoadCancel回调原因:"; + @Local text: string = ""; @Local ImageKnifeOption: ImageKnifeOption = new ImageKnifeOption({ loadSrc: "", objectFit: ImageFit.Contain, @@ -30,19 +30,19 @@ struct TestLoadCancelListenerPage { build() { Column() { - Text(this.text).margin(20).fontSize(15) - Button('移除组件-网络加载图片') + Text($r('app.string.onLoadCancel_reason', this.text)).margin(20).fontSize(15) + Button($r('app.string.rm_component_of_net')) .margin(20) .onClick(() => { this.ImageKnifeOption = new ImageKnifeOption({ - loadSrc: "https://q7.itc.cn/images01/20240223/ce80229bf9934dff97cdf2ad7be1dcb8.jpeg", + loadSrc: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg", objectFit: ImageFit.Contain, onLoadListener: { onLoadStart: () => { this.showChild = false; }, onLoadCancel: (res) => { - this.text = "onLoadCancel回调成功,网络nLoadCancel回调原因:" + res + this.text = res console.log("TestLoadCancelListenerPage----onLoadCancel> url:" + res) } }, @@ -50,8 +50,9 @@ struct TestLoadCancelListenerPage { }) }) - Button('恢复组件显示') + Button($r('app.string.component_display')) .margin(20).onClick(() => { + this.text = ""; this.showChild = true; this.ImageKnifeOption = new ImageKnifeOption({ loadSrc: "", @@ -59,7 +60,7 @@ struct TestLoadCancelListenerPage { border: { radius: 50 } }) }) - Button('移除组件-本地资源图片') + Button($r('app.string.rm_component_of_local')) .margin(20) .onClick(() => { this.ImageKnifeOption = new ImageKnifeOption({ @@ -70,7 +71,7 @@ struct TestLoadCancelListenerPage { this.showChild = false; }, onLoadCancel: (res) => { - this.text = "onLoadCancel回调成功,本地onLoadCancel回调原因:" + res + this.text = res console.log("TestLoadCancelListenerPage----onLoadCancel> url:" + res) } }, diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index f982e81..fc1da84 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -367,6 +367,134 @@ { "name": "TIPS", "value": "Please shut down the network first and ensure that there is no cache of images from this network in the test failure scenario locally" + }, + { + "name": "image_format", + "value": "picture format:%s" + }, + { + "name": "image_width", + "value": "image width:%d" + }, + { + "name": "image_height", + "value": "image height:%d" + }, + { + "name": "cur_cache_limit", + "value": "%s:current cache limit:%fM" + }, + { + "name": "cur_cache_image_num", + "value": "%s:current cache image number:%d" + }, + { + "name": "cur_cache_size", + "value": "%s:current cache size:%fM" + }, + { + "name": "load_memory", + "value": "memory loaded picture" + }, + { + "name": "load_disk", + "value": "disk cache loads images" + }, + { + "name": "get_cur_memory_limit", + "value": "gets the current memory cache upper limit" + }, + { + "name": "get_img_number_of_cache", + "value": "gets the number of images cached in memory" + }, + { + "name": "get_cur_memory_size", + "value": "gets the size of the current cache" + }, + { + "name": "get_cur_disk_limit", + "value": "Gets the current disk cache upper limit" + }, + { + "name": "get_img_number_of_disk", + "value": "gets the number of images cached on disk" + }, + { + "name": "get_cur_disk_size", + "value": "gets the size of the current disk" + }, + { + "name": "select_color_btn", + "value": "click to select the color you want to change" + }, + { + "name": "click_img_to_change_color", + "value": "click on the image to change the image color" + }, + { + "name": "test_non_svg_color", + "value": "test non-SVG images for color change" + }, + { + "name": "test_svg_color", + "value": "Test svg picture color change" + }, + { + "name": "red", + "value": "red" + }, + { + "name": "yellow", + "value": "yellow" + }, + { + "name": "green", + "value": "green" + }, + { + "name": "blue", + "value": "blue" + }, + { + "name": "master_image", + "value": "master image:" + }, + { + "name": "rm_component_of_net", + "value": "remove Component - Network load picture" + }, + { + "name": "rm_component_of_local", + "value": "remove Component - Local resource picture" + }, + { + "name": "component_display", + "value": "recovery component display" + }, + { + "name": "onLoadCancel_reason", + "value": "onLoadCancel callback reason:%s" + }, + { + "name": "test_cache_btn", + "value": "test data for in cache" + }, + { + "name": "test_change_color_btn", + "value": "test change color for image" + }, + { + "name": "test_cancel_callback_btn", + "value": "test callback of cancel" + }, + { + "name": "memory", + "value": "Memory" + }, + { + "name": "disk", + "value": "Disk" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_test_change_color_png.png b/entry/src/main/resources/base/media/ic_test_change_color_png.png new file mode 100644 index 0000000000000000000000000000000000000000..75f0a56c3999613f19b0e1fe30b73236835f0f35 GIT binary patch literal 3440 zcmZu!c|6mP|9@|@G3E-*P35Mj9CK|FMzL5!2Tl4Eqz9syXL6A`serk=ljR=^?bdauh$>1KVFZ=>+wu?#9@U6Wd#8M5Vo_m!te2g zzYu`!#o7EA)Eudup!&hCa3XO*O+9J7tmiG2Dgf#RC^ zv$lmvKEyyt#Ms^8LC5zfP5(_Tk?3BLGSB5G8+h2?F~iK&kG zpIuG=R)>{5?_u8kd4yuH9`|!=c!pL!B3qdNWq>gaRl*+F3N^8z6ryYTm-YO5F(JLNQEMLWJ<+ zKX%|pDl13fn04aq4;?8!evIZb?iN*+ ze5o!F*jUeZNaOARJ;VrPmJhmDoTCP7)ec4yGmhBy+q2Kr>2(f#sG;tpW4*JqXnjx% zIg9VxXDk~;V?nk$r4qf!;^o!YKi4uR&(?QWpx_xm6J%o_^Ornth+SmqZ9%4hx}4(S z;lardPR+u1$5o=Ra^@gNBObBnxq<{O3nVHkL)PcUlq}{~AEPm;Ga46a=z2gxQmGIv4yOZ& zC_$F7I^)~lEzo!Mv)4bq;AJ@l`VRm5z&xz_=PiwtphHODN3KhZ#os0X03c;NT{FrjZ|R}Qob>!G0>AA+ye>`wE? zwCX~Jw`Z-;of9>{s4XEM!Vg|_HV*{MZ^ib>s2_f5O-;h1V@MyADKZC;e2qOHVk8r?|Tv6;-6#QlDhx&}%RKQ;OQ z4(#mLGIg9WD#OdI7zs@Hj2VH1FRThXZS_ne;ScZ9dhFO2(T6zPJAGuv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X6?c$5^qH3bSxbMuB*R~y>*!!tq9|F zM4Wzm6Y)#Hs4aqztHfrNnOp`3KGzFAw`qo8^%dplRnf|+b=BLNtng!sNOBm(47;1THF0sOF7%)#A= z%*El>pSREB>k^F@^^Y!IMRpm+u8XSI`Ek!*at4g>dshUx?`IC9j2aW&&5Ie$j2JIH(;lI#&xynZ!k z$z{}@QSDp^4)erhUcH9dnDY(MF+hqQw;`2|L$fkMOGV~<{i8@zctAb4NM}?-#;BK(NBpm4lnengN_5lr&@$q z-V_vpl$zpCqV+y0Eh_6*JJTLt`kH^5bbt`M?k23qw3$CF_KV1LvgQ^fufPMcjQj5W zP!4O5grh_@_NS-PdTH2EI^=z?+L`fA+-+E zLUxqc5FD9n*YQ*5{`u=m0}R}WcBn5?Q?z}P8OLHtJ^M@k8$*t&D1F;i#avw`rV9f$ypsFn~@z5~ZzNRK6p_cex zBwy;d+Xy5*BIzAp__Z2H8hChSLMB0i*g$*a7TP-9qy~E@EzIvFu?;ry2cL^GWfz#2 zh^B3TI=*kIpLFF)iV`M+ZLY)C{5U*M?SE2nfI(NpwLF&`W?lV#$ z%Iq_*^P)iSue|<%&l8W)-ZtqRn7Y&J38Axg;}~kOPAkLJyDYhGqJyhX$MHFxQf=h+ z#V7)Ep_-f(6cjMle6FED%sT=8T9#KqZ-ZSQ83k{_e2Dd8`<=K$*pVL#|Dq_R~nlw9+{S8<*?>P5wOtfb7{ + + svg细图标 + + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/test.png b/entry/src/main/resources/base/media/test.png deleted file mode 100644 index b0d65d0fa431513655312e60e316a49675bdba52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9714 zcmX|{byyVN8}?_H6?X-sOKORwTRN8zSe6h_O2GvMq`M?s5J99{I$TA%OKKGrGXGWEdBRByOPMC?!+mYG>wdXPq~OJkkQ%Owz;%%;B|D|T z9}R^nfOFi%Z!Tw%^^EI_Z3lGRveZ{!6`M~>$Z(bL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/src/main/resources/base/media/test_svg.svg b/entry/src/main/resources/base/media/test_svg.svg deleted file mode 100644 index 9910b1d..0000000 --- a/entry/src/main/resources/base/media/test_svg.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index 74fedfe..f727a27 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -363,6 +363,134 @@ { "name": "TIPS", "value": "测试失败场景请先关闭网络,并保证本地没有此网络图片的缓存" + }, + { + "name": "image_format", + "value": "图片格式:%s" + }, + { + "name": "image_width", + "value": "图片宽度:%d" + }, + { + "name": "image_height", + "value": "图片高度:%d" + }, + { + "name": "cur_cache_limit", + "value": "%s:当前缓存上限:%fM" + }, + { + "name": "cur_cache_image_num", + "value": "%s:当前缓存图片数量:%d" + }, + { + "name": "cur_cache_size", + "value": "%s:当前缓存的大小:%fM" + }, + { + "name": "load_memory", + "value": "内存加载图片" + }, + { + "name": "load_disk", + "value": "磁盘缓存加载图片" + }, + { + "name": "get_cur_memory_limit", + "value": "获取当前内存缓存上限" + }, + { + "name": "get_img_number_of_cache", + "value": "获取当前内存缓存图片数量" + }, + { + "name": "get_cur_memory_size", + "value": "获取当前缓存的大小" + }, + { + "name": "get_cur_disk_limit", + "value": "获取当前磁盘缓存上限" + }, + { + "name": "get_img_number_of_disk", + "value": "获取当前磁盘缓存图片数量" + }, + { + "name": "get_cur_disk_size", + "value": "获取当前磁盘的大小" + }, + { + "name": "select_color_btn", + "value": "点击选择要更改的颜色" + }, + { + "name": "click_img_to_change_color", + "value": "点击图片更改图片颜色" + }, + { + "name": "test_non_svg_color", + "value": "测试非svg图片变色" + }, + { + "name": "test_svg_color", + "value": "测试svg图片变色" + }, + { + "name": "red", + "value": "红色" + }, + { + "name": "yellow", + "value": "黄色" + }, + { + "name": "green", + "value": "绿色" + }, + { + "name": "blue", + "value": "蓝色" + }, + { + "name": "master_image", + "value": "原图:" + }, + { + "name": "rm_component_of_net", + "value": "移除组件-网络加载图片" + }, + { + "name": "rm_component_of_local", + "value": "移除组件-本地资源图片" + }, + { + "name": "component_display", + "value": "恢复组件显示" + }, + { + "name": "onLoadCancel_reason", + "value": "onLoadCancel回调原因:%s" + }, + { + "name": "test_cache_btn", + "value": "测试缓存数据" + }, + { + "name": "test_change_color_btn", + "value": "测试颜色变换" + }, + { + "name": "test_cancel_callback_btn", + "value": "测试加载取消回调接口" + }, + { + "name": "memory", + "value": "内存" + }, + { + "name": "disk", + "value": "磁盘" } ] } \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets b/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets index 3faa0a6..fea2a53 100644 --- a/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets +++ b/entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets @@ -13,7 +13,13 @@ * limitations under the License. */ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; -import { ImageKnifeOption, ImageKnife, ImageKnifeRequest, ImageKnifeRequestSource } from "@ohos/imageknife" +import { + ImageKnifeOption, + ImageKnife, + ImageKnifeRequest, + ImageKnifeRequestSource, + CacheStrategy +} from "@ohos/imageknife" import { common } from '@kit.AbilityKit'; export default function imageFormatAndSize() { @@ -41,16 +47,14 @@ export default function imageFormatAndSize() { let width = 0; let height = 0; let imageFormat: string = ""; - + let url: string = + "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/ed/v3/KMO4D6D2QGuVOCLX4AhOFA/ef51xAaLQuK7BsnuD9abog.jpg" let imageKnifeOption: ImageKnifeOption = new ImageKnifeOption({ - loadSrc: $r('app.media.icon'), + loadSrc: url, }) await new Promise((resolve, reject) => { imageKnifeOption.onLoadListener = { onLoadSuccess: (data, imageknifeData) => { - width = imageknifeData.imageWidth - height = imageknifeData.imageHeight - imageFormat = imageknifeData.type! resolve("") }, onLoadFailed(err) { @@ -70,9 +74,16 @@ export default function imageFormatAndSize() { ) ImageKnife.getInstance().execute(request); }) + let data = await ImageKnife.getInstance() + .getCacheImage(url, CacheStrategy.Memory); + if (data) { + width = data.imageWidth + height = data.imageHeight + imageFormat = data.type! + } expect(width != 0).assertTrue(); expect(height != 0).assertTrue(); expect(imageFormat != "").assertTrue(); }); }); -} +} \ No newline at end of file diff --git a/library/src/main/ets/ImageKnife.ets b/library/src/main/ets/ImageKnife.ets index e91344a..79c9fe6 100644 --- a/library/src/main/ets/ImageKnife.ets +++ b/library/src/main/ets/ImageKnife.ets @@ -314,7 +314,6 @@ export class ImageKnife { if (cacheType == CacheStrategy.Memory) { return (this.memoryCache as MemoryLruCache).maxMemory; } else { - console.log("sss---->isFileCacheInit:"+this.fileCache) if (this.isFileCacheInit()) { return this.fileCache?.maxMemory; } else {