ImageKnife/library/src/main/ets/model/ImageKnifeData.ets

83 lines
2.2 KiB
Plaintext

/*
* 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 { HeaderOptions } from '../ImageKnifeOption'
import { ImageKnifeRequest } from '../ImageKnifeRequest'
import { IEngineKey } from '../key/IEngineKey'
import { PixelMapTransformation } from '../transform/PixelMapTransformation'
import common from '@ohos.app.ability.common';
import { Size } from '@kit.ArkUI'
export interface ImageKnifeData {
source: PixelMap | string,
imageWidth: number,
imageHeight: number
}
/**
* 缓存策略
*/
export enum CacheStrategy {
// 默认-写入/读取内存和文件缓存
Default = 0,
// 只写入/读取内存缓存
Memory = 1,
// 只写入/读取文件缓存
File = 2
}
/**
* 区分是src,placehodler,还是error_holder
*/
export enum ImageKnifeRequestSource {
SRC,
PLACE_HOLDER,
ERROR_HOLDER
}
export interface ImageKnifeRequestWithSource {
request: ImageKnifeRequest
source: ImageKnifeRequestSource
}
/**
* request子线程处理时的返回
*/
export interface RequestJobResult {
pixelMap: PixelMap | string | undefined
bufferSize: number
fileKey: string
loadFail?: string,
size?:Size
}
/**
* request子线程处理时的请求参数
*/
export interface RequestJobRequest {
context: common.UIAbilityContext,
src: string | PixelMap | Resource,
headers?: Array<HeaderOptions>,
allHeaders: Map<string, Object>,
customGetImage?: (context: Context, src: string | PixelMap | Resource) => Promise<ArrayBuffer | undefined>,
onlyRetrieveFromCache?: boolean
requestSource: ImageKnifeRequestSource
transformation?: PixelMapTransformation
writeCacheStrategy?: CacheStrategy
signature?: string
engineKey: IEngineKey
}