75 lines
2.9 KiB
Plaintext
75 lines
2.9 KiB
Plaintext
/*
|
|
* 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 {GlideImage} from "../glide/GlideImage.ets"
|
|
import {GlideOption} from "../glide/GlideOption.ets"
|
|
import {FileUtils} from "../cache/FileUtils.ets"
|
|
import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
|
|
import {RoundedCornersTransformation} from "../glide/transform/RoundedCornersTransformation.ets"
|
|
import resourceManager from '@ohos.resourceManager';
|
|
import image from "@ohos.multimedia.image"
|
|
@Entry
|
|
@Component
|
|
struct JpegProgressTestCasePage {
|
|
|
|
|
|
build() {
|
|
Scroll() {
|
|
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
|
Button('点击调用渐进式解码')
|
|
.onClick(()=> {
|
|
resourceManager.getResourceManager()
|
|
.then(result => {
|
|
result.getMedia($r('app.media.jpgSample').id)
|
|
.then(data => {
|
|
let arrayBuffer = FileUtils.getInstance().uint8ArrayToBuffer(data);
|
|
let imageSourceIncrementalSApi = image.createIncrementalSource(data);
|
|
let array = [1,2,3,4,5,6,7,8,9,10];
|
|
imageSourceIncrementalSApi.updateData(array, false,(error,data) => {
|
|
console.log("data is null="+(data == null || data == undefined))
|
|
console.log("array = "+array)
|
|
console.log("data ="+data)
|
|
|
|
})
|
|
})
|
|
})
|
|
|
|
})
|
|
Button('点击调用渐进式解码带上length')
|
|
.onClick(()=> {
|
|
resourceManager.getResourceManager()
|
|
.then(result => {
|
|
result.getMedia($r('app.media.jpgSample').id)
|
|
.then(data => {
|
|
let arrayBuffer = FileUtils.getInstance().uint8ArrayToBuffer(data);
|
|
let imageSourceIncrementalSApi = image.createIncrementalSource(data);
|
|
let array = [1,2,3,4,5,6,7,8,9,10];
|
|
imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data) => {
|
|
console.log("data is null="+(data == null || data == undefined))
|
|
console.log("array = "+array)
|
|
console.log("data ="+data)
|
|
|
|
})
|
|
})
|
|
})
|
|
|
|
})
|
|
}
|
|
}
|
|
.width('100%')
|
|
.height('100%')
|
|
}
|
|
}
|
|
|