From 185cff282c4fb9a3a9714c47d00066f304f4785d Mon Sep 17 00:00:00 2001 From: zhoulisheng <635547767@qq.com> Date: Tue, 21 Nov 2023 15:44:09 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=88=A0=E9=99=A4pngLoadWorker.ets=20?= =?UTF-8?q?=E5=92=8C=20pngWorkers.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoulisheng <635547767@qq.com> --- entry/src/main/ets/workers/PngLoadWorker.ets | 23 ---------- entry/src/main/ets/workers/pngWorker.ts | 44 -------------------- 2 files changed, 67 deletions(-) delete mode 100644 entry/src/main/ets/workers/PngLoadWorker.ets delete mode 100644 entry/src/main/ets/workers/pngWorker.ts diff --git a/entry/src/main/ets/workers/PngLoadWorker.ets b/entry/src/main/ets/workers/PngLoadWorker.ets deleted file mode 100644 index 7eb75c7..0000000 --- a/entry/src/main/ets/workers/PngLoadWorker.ets +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 worker, { ThreadWorkerGlobalScope, MessageEvents, ErrorEvent } from '@ohos.worker'; -import { UPNG } from '@ohos/libraryimageknife' -import {resolvePngWorker} from './pngWorker' -const workerPort: ThreadWorkerGlobalScope = worker.workerPort; - -workerPort.onmessage = (e: MessageEvents)=> { - resolvePngWorker(workerPort,UPNG,e) -} \ No newline at end of file diff --git a/entry/src/main/ets/workers/pngWorker.ts b/entry/src/main/ets/workers/pngWorker.ts deleted file mode 100644 index 4540a95..0000000 --- a/entry/src/main/ets/workers/pngWorker.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 worker, { ThreadWorkerGlobalScope, MessageEvents, ErrorEvent } from '@ohos.worker'; -export function resolvePngWorker (workerPort,UPNG, e: MessageEvents) { - let data = e.data; - switch (data.type) { - case 'readPngImageAsync': - let png = UPNG.decode(data.data); - let array = png.data; - let arrayData = array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset) - png.data = arrayData; - let dataObj = { type: 'readPngImageAsync', data: png, receiver: data.data } - workerPort.postMessage(dataObj, [png.data, data.data]); - break; - case 'writePngWithStringAsync': - let addInfo = data.info; - let pngDecode = UPNG.decode(data.data); - let newPng = UPNG.encodeWithString(addInfo, UPNG.toRGBA8(pngDecode), pngDecode.width, pngDecode.height, 0) - let dataObj2 = { type: 'writePngWithStringAsync', data: newPng, receiver: data.data } - workerPort.postMessage(dataObj2, [newPng, data.data]); - break; - case 'writePngAsync': - let pngDecode3 = UPNG.decode(data.data); - let newPng3 = UPNG.encode(UPNG.toRGBA8(pngDecode3), pngDecode3.width, pngDecode3.height, 0) - let dataObj3 = { type: 'writePngAsync', data: newPng3, receiver: data.data } - workerPort.postMessage(dataObj3, [newPng3, data.data]); - break; - default: - break - } -} \ No newline at end of file