forked from floraachy/ImageKnife
112 lines
2.9 KiB
Plaintext
112 lines
2.9 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'
|
|
import { DownsampleStrategy } from '../downsampling/DownsampleStartegy'
|
|
export interface ImageKnifeData {
|
|
source: PixelMap | string,
|
|
imageWidth: number,
|
|
imageHeight: number,
|
|
type?:string,
|
|
imageAnimator?: Array<ImageFrameInfo>
|
|
}
|
|
/**
|
|
* onComplete成功回调
|
|
*/
|
|
export interface EventImage {
|
|
width: number;
|
|
height: number;
|
|
componentWidth: number;
|
|
componentHeight: number;
|
|
loadingStatus: number;
|
|
contentWidth: number;
|
|
contentHeight: number;
|
|
contentOffsetX: number;
|
|
contentOffsetY: 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,
|
|
type?: string,
|
|
pixelMapList?:Array<PixelMap>,
|
|
delayList?: Array<number>
|
|
}
|
|
|
|
/**
|
|
* request子线程处理时的请求参数
|
|
*/
|
|
export interface RequestJobRequest {
|
|
context: common.UIAbilityContext,
|
|
src: string | number,
|
|
headers?: Array<HeaderOptions>,
|
|
allHeaders: Map<string, Object>,
|
|
componentWidth: number,
|
|
componentHeight: number,
|
|
customGetImage?: (context: Context, src: string | PixelMap | Resource) => Promise<ArrayBuffer | undefined>,
|
|
onlyRetrieveFromCache?: boolean
|
|
requestSource: ImageKnifeRequestSource
|
|
transformation?: PixelMapTransformation
|
|
writeCacheStrategy?: CacheStrategy
|
|
signature?: string
|
|
engineKey: IEngineKey
|
|
isWatchProgress: boolean
|
|
memoryKey: string
|
|
fileCacheFolder: string,
|
|
isAnimator?: boolean,
|
|
moduleName?:string,
|
|
resName?: string,
|
|
targetWidth: number
|
|
targetHeight: number
|
|
downsampType?: DownsampleStrategy
|
|
}
|
|
|