forked from floraachy/ImageKnife
77 lines
2.7 KiB
Plaintext
77 lines
2.7 KiB
Plaintext
/*
|
|
* 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 { ImageKnife, ImageKnifeComponent, ImageKnifeGlobal, ImageKnifeOption } from "@ohos/libraryimageknife"
|
|
import worker from '@ohos.worker';
|
|
|
|
let gifUrl = "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658"
|
|
|
|
let data: string[] = [
|
|
'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658',
|
|
'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
|
|
'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700',
|
|
'https://img-blog.csdnimg.cn/20191215043500229.png',
|
|
'https://res.vmallres.com/cmscdn/CN/2023-03/7052a601ac3e428c84c9415ad9734735.gif',
|
|
'https://img-blog.csdn.net/20140514114029140'
|
|
]
|
|
|
|
@Entry
|
|
@Component
|
|
struct TestManyGifLoadWithPage {
|
|
|
|
@State p1: PixelMap | undefined = undefined
|
|
@State p2: PixelMap | undefined = undefined
|
|
@State workerOption: ImageKnifeOption = {
|
|
loadSrc: $r('app.media.icon'),
|
|
placeholderSrc: $r('app.media.icon_loading'),
|
|
errorholderSrc: $r('app.media.icon_failed')
|
|
};
|
|
|
|
build() {
|
|
Column() {
|
|
Text('gif Demo').align(Alignment.Center).fontSize(25).margin(10).fontWeight(FontWeight.Bolder)
|
|
Row() {
|
|
Column() {
|
|
Button('use Origin Image').align(Alignment.Center).fontSize(10).margin(2)
|
|
Image(gifUrl).width('100%').height(100).backgroundColor(Color.Blue).objectFit(ImageFit.Contain)
|
|
}.width('50%').backgroundColor(Color.Orange)
|
|
|
|
Column() {
|
|
Button('use ImageKnifeComponent').align(Alignment.Center).fontSize(10).margin(2)
|
|
ImageKnifeComponent({ imageKnifeOption: { loadSrc: gifUrl } })
|
|
.width('100%')
|
|
.height(100)
|
|
.backgroundColor(Color.Orange)
|
|
}.width('50%').backgroundColor(Color.Blue)
|
|
}
|
|
|
|
Grid() {
|
|
ForEach(data, (url: string) => {
|
|
GridItem(){
|
|
ImageKnifeComponent({imageKnifeOption:{
|
|
loadSrc:url
|
|
}}).backgroundColor(0x38393D).width(150).height(100)
|
|
}
|
|
})
|
|
}.rowsGap(2)
|
|
.columnsGap(2)
|
|
}.width('100%').height('100%').backgroundColor(0xF1F3F5)
|
|
}
|
|
aboutToAppear(){
|
|
|
|
}
|
|
aboutToDisappear(){
|
|
|
|
}
|
|
} |