diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index 5b60743..52767e4 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -3,8 +3,6 @@ "buildOption": { "sourceOption": { "workers": [ - "./src/main/ets/pages/workers/worker1.js", - "./src/main/ets/pages/workers/gifParseWorker.ts", './src/main/ets/workers/GifLoadWorker.ts', './src/main/ets/workers/PngLoadWorker.ts', './src/main/ets/workers/MyWorker.ts' diff --git a/entry/src/main/ets/pages/gifTestCasePage.ets b/entry/src/main/ets/pages/gifTestCasePage.ets index 133203b..7208694 100644 --- a/entry/src/main/ets/pages/gifTestCasePage.ets +++ b/entry/src/main/ets/pages/gifTestCasePage.ets @@ -12,8 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {GIFParseImpl} from '@ohos/imageknife' -import ArkWorker from '@ohos.worker' +import { GIFParseImpl } from '@ohos/imageknife' +import worker from '@ohos.worker'; + @Entry @Component struct gifTestCasePage { @@ -51,7 +52,7 @@ struct gifTestCasePage { globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.gifSample').id) .then(data => { console.log('basicTestFileIOPage - 本地加载资源 解析后数据data length = ' + data.byteLength) - let worker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', { + let local_worker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', { type: 'classic', name: 'ImageKnifeParseGIF' }) @@ -64,7 +65,7 @@ struct gifTestCasePage { console.log('加载gif图片自带worker suc,长度='+data.length) this.pixels = data[0]['drawPixelMap'] } - },worker) + },local_worker) }) .catch(err => { console.log('basicTestFileIOPage - 本地加载资源err' + JSON.stringify(err)); @@ -111,7 +112,7 @@ struct gifTestCasePage { aboutToAppear() { console.log("aboutToAppear()") - this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', { + this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', { type: 'classic', name: 'ImageKnifeParseGIF' }) diff --git a/entry/src/main/ets/pages/pngjTestCasePage.ets b/entry/src/main/ets/pages/pngjTestCasePage.ets index 7145b43..5aa8e17 100644 --- a/entry/src/main/ets/pages/pngjTestCasePage.ets +++ b/entry/src/main/ets/pages/pngjTestCasePage.ets @@ -12,12 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import router from '@system.router'; import { Pngj } from '@ohos/imageknife' -import resourceManager from '@ohos.resourceManager'; import { FileUtils } from '@ohos/imageknife' -import featureability from '@ohos.ability.featureAbility' -import ArkWorker from '@ohos.worker' +import worker from '@ohos.worker'; @Entry @Component @@ -109,11 +106,11 @@ struct PngjTestCasePage { if (!this.pngdecodeRun2) { this.pngdecodeRun2 = true; let pngj = new Pngj(); - let worker = new ArkWorker.Worker('entry/ets/pages/workers/worker1.js', { + let png_worker = new worker.ThreadWorker('entry/ets/workers/PngLoadWorker.ts', { type: 'classic', name: 'readPngImageAsync' }) - pngj.readPngImageAsync(worker, this.pngSource1, (sender, value) => { + pngj.readPngImageAsync(png_worker, this.pngSource1, (sender, value) => { this.pngSource1 = sender this.hint2 = 'img with=' + value.width + ' img height=' + value.height + ' img depth=' + value.depth + ' img ctype=' + value.ctype @@ -154,11 +151,11 @@ struct PngjTestCasePage { if (!this.pngdecodeRun3) { this.pngdecodeRun3 = true; let pngj = new Pngj(); - let worker = new ArkWorker.Worker('entry/ets/pages/workers/worker1.js', { + let png_worker = new worker.ThreadWorker('entry/ets/workers/PngLoadWorker.ts', { type: 'classic', name: 'writePngWithStringAsync' }) - pngj.writePngWithStringAsync(worker, 'hello world', this.pngSource3, (sender, value) => { + pngj.writePngWithStringAsync(png_worker, 'hello world', this.pngSource3, (sender, value) => { this.pngSource3 = sender FileUtils.getInstance().createFileProcess( this.rootFolder + '/pngj', @@ -204,11 +201,11 @@ struct PngjTestCasePage { if (!this.pngdecodeRun4) { this.pngdecodeRun4 = true; let pngj = new Pngj(); - let worker = new ArkWorker.Worker('entry/ets/pages/workers/worker1.js', { + let png_worker = new worker.ThreadWorker('entry/ets/workers/PngLoadWorker.ts', { type: 'classic', name: 'writePngAsync' }) - pngj.writePngAsync(worker, this.pngSource4, (sender, value) => { + pngj.writePngAsync(png_worker, this.pngSource4, (sender, value) => { this.pngSource4 = sender FileUtils.getInstance().createFileProcess( this.rootFolder + '/pngj', diff --git a/entry/src/main/ets/pages/tempUrlTestPage.ets b/entry/src/main/ets/pages/tempUrlTestPage.ets index b167380..71c5737 100644 --- a/entry/src/main/ets/pages/tempUrlTestPage.ets +++ b/entry/src/main/ets/pages/tempUrlTestPage.ets @@ -19,7 +19,8 @@ import { ImageKnifeDrawFactory, ScaleType } from '@ohos/imageknife' -import ArkWorker from '@ohos.worker' +import worker from '@ohos.worker'; + @Entry @Component struct tempUrlTestPage { @@ -84,7 +85,7 @@ struct tempUrlTestPage { } aboutToAppear() { - this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', { + this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', { type: 'classic', name: 'ImageKnifeParseGIF' }) diff --git a/entry/src/main/ets/pages/testGifDontAnimatePage.ets b/entry/src/main/ets/pages/testGifDontAnimatePage.ets index 551dffc..6f4ff0b 100644 --- a/entry/src/main/ets/pages/testGifDontAnimatePage.ets +++ b/entry/src/main/ets/pages/testGifDontAnimatePage.ets @@ -14,8 +14,8 @@ */ import {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/imageknife' -import {RotateImageTransformation} from '@ohos/imageknife' -import ArkWorker from '@ohos.worker' +import worker from '@ohos.worker' + @Entry @Component struct TestGifDontAnimatePage { @@ -85,7 +85,7 @@ struct TestGifDontAnimatePage { } aboutToAppear() { - this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', { + this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', { type: 'classic', name: 'ImageKnifeParseGIF' }) diff --git a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets index 1e8ed32..ddbe57c 100644 --- a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets +++ b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets @@ -14,8 +14,8 @@ */ import {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/imageknife' -import {RotateImageTransformation} from '@ohos/imageknife' -import ArkWorker from '@ohos.worker' +import worker from '@ohos.worker' + @Entry @Component struct TestImageKnifeOptionChangedPage { @@ -185,7 +185,7 @@ struct TestImageKnifeOptionChangedPage { aboutToAppear() { console.log("aboutToAppear()") - this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', { + this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', { type: 'classic', name: 'ImageKnifeParseGIF' }) diff --git a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage3.ets b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage3.ets index 6b0d443..9dd37ea 100644 --- a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage3.ets +++ b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage3.ets @@ -18,7 +18,8 @@ import {ScaleType} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/imageknife' import {GrayscaleTransformation} from '@ohos/imageknife' import {SketchFilterTransformation} from '@ohos/imageknife' -import ArkWorker from '@ohos.worker' +import worker from '@ohos.worker' + @Entry @Component struct TestImageKnifeOptionChangedPage3 { @@ -198,7 +199,7 @@ struct TestImageKnifeOptionChangedPage3 { } aboutToAppear() { console.log("aboutToAppear()") - this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', { + this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', { type: 'classic', name: 'ImageKnifeParseGIF' }) diff --git a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage4.ets b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage4.ets index 3583282..d6007db 100644 --- a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage4.ets +++ b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage4.ets @@ -23,7 +23,8 @@ import { IDrawLifeCycle, ScaleType } from '@ohos/imageknife' -import ArkWorker from '@ohos.worker' +import worker from '@ohos.worker'; + @Entry @Component struct TestImageKnifeOptionChangedPage4 { @@ -113,7 +114,7 @@ struct TestImageKnifeOptionChangedPage4 { aboutToAppear() { console.log("aboutToAppear()") - this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', { + this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', { type: 'classic', name: 'ImageKnifeParseGIF' }) diff --git a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage5.ets b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage5.ets index 25cae43..92bb5bd 100644 --- a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage5.ets +++ b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage5.ets @@ -24,7 +24,8 @@ import { ScaleType, ImageKnifeDrawFactory } from '@ohos/imageknife' -import ArkWorker from '@ohos.worker' +import worker from '@ohos.worker'; + @Entry @Component struct TestImageKnifeOptionChangedPage5 { @@ -95,7 +96,7 @@ struct TestImageKnifeOptionChangedPage5 { aboutToAppear() { console.log("aboutToAppear()") - this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', { + this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', { type: 'classic', name: 'ImageKnifeParseGIF' }) diff --git a/entry/src/main/ets/pages/testPreloadPage.ets b/entry/src/main/ets/pages/testPreloadPage.ets index 8b88655..2a12b06 100644 --- a/entry/src/main/ets/pages/testPreloadPage.ets +++ b/entry/src/main/ets/pages/testPreloadPage.ets @@ -15,7 +15,7 @@ import {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/imageknife' import {RequestOption} from '@ohos/imageknife' -import ArkWorker from '@ohos.worker' +import worker from '@ohos.worker' @Entry @Component @@ -614,7 +614,7 @@ struct TestPreloadPage { } aboutToAppear() { - this.globalGifWorker = new ArkWorker.Worker('entry/ets/pages/workers/gifParseWorker.ts', { + this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', { type: 'classic', name: 'ImageKnifeParseGIF' }) diff --git a/entry/src/main/ets/pages/workers/gifParseWorker.ts b/entry/src/main/ets/pages/workers/gifParseWorker.ts deleted file mode 100644 index 427f5ab..0000000 --- a/entry/src/main/ets/pages/workers/gifParseWorker.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2022 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 arkWorker from '@ohos.worker'; -import { gifHandler } from '@ohos/imageknife/GifWorker' - -arkWorker.parentPort.onmessage = gifHandler; - - - - - - diff --git a/entry/src/main/ets/pages/workers/worker1.js b/entry/src/main/ets/pages/workers/worker1.js deleted file mode 100644 index 9aff18e..0000000 --- a/entry/src/main/ets/pages/workers/worker1.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2021 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 arkWorker from '@ohos.worker'; - -import {handler} from '@ohos/imageknife/PngWork' - -arkWorker.parentPort.onmessage = handler - - - - - - - - - diff --git a/entry/src/main/resources/base/media/test.gif b/entry/src/main/resources/base/media/test.gif new file mode 100644 index 0000000..fceab16 Binary files /dev/null and b/entry/src/main/resources/base/media/test.gif differ