1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or wrapperied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ohos_adapter/bridge/ark_ohos_image_decoder_adapter_wrapper.h"
17
18 namespace OHOS::ArkWeb {
19
ArkOhosImageDecoderAdapterWrapper(ArkWebRefPtr<ArkOhosImageDecoderAdapter> ref)20 ArkOhosImageDecoderAdapterWrapper::ArkOhosImageDecoderAdapterWrapper(ArkWebRefPtr<ArkOhosImageDecoderAdapter> ref)
21 : ctocpp_(ref)
22 {}
23
ParseImageInfo(const uint8_t * data,uint32_t size)24 bool ArkOhosImageDecoderAdapterWrapper::ParseImageInfo(const uint8_t* data, uint32_t size)
25 {
26 return ctocpp_->ParseImageInfo(data, size);
27 }
28
GetEncodedFormat()29 std::string ArkOhosImageDecoderAdapterWrapper::GetEncodedFormat()
30 {
31 ArkWebString str = ctocpp_->GetEncodedFormat();
32 std::string format = ArkWebStringStructToClass(str);
33 ArkWebStringStructRelease(str);
34 return format;
35 }
36
GetImageWidth()37 int32_t ArkOhosImageDecoderAdapterWrapper::GetImageWidth()
38 {
39 return ctocpp_->GetImageWidth();
40 }
41
GetImageHeight()42 int32_t ArkOhosImageDecoderAdapterWrapper::GetImageHeight()
43 {
44 return ctocpp_->GetImageHeight();
45 }
46
DecodeToPixelMap(const uint8_t * data,uint32_t size)47 bool ArkOhosImageDecoderAdapterWrapper::DecodeToPixelMap(const uint8_t* data, uint32_t size)
48 {
49 return ctocpp_->DecodeToPixelMap(data, size);
50 }
51
52
Decode(const uint8_t * data,uint32_t size,OHOS::NWeb::AllocatorType type,bool useYuv)53 bool ArkOhosImageDecoderAdapterWrapper::Decode(const uint8_t* data,
54 uint32_t size,
55 OHOS::NWeb::AllocatorType type,
56 bool useYuv)
57 {
58 return ctocpp_->Decode(data, size, (uint32_t)type, useYuv);
59 }
60
GetFd()61 int32_t ArkOhosImageDecoderAdapterWrapper::GetFd()
62 {
63 return ctocpp_->GetFd();
64 }
65
GetStride()66 int32_t ArkOhosImageDecoderAdapterWrapper::GetStride()
67 {
68 return ctocpp_->GetStride();
69 }
70
GetOffset()71 int32_t ArkOhosImageDecoderAdapterWrapper::GetOffset()
72 {
73 return ctocpp_->GetOffset();
74 }
75
GetSize()76 uint64_t ArkOhosImageDecoderAdapterWrapper::GetSize()
77 {
78 return ctocpp_->GetSize();
79 }
80
GetNativeWindowBuffer()81 void* ArkOhosImageDecoderAdapterWrapper::GetNativeWindowBuffer()
82 {
83 return ctocpp_->GetNativeWindowBuffer();
84 }
85
GetPlanesCount()86 int32_t ArkOhosImageDecoderAdapterWrapper::GetPlanesCount()
87 {
88 return ctocpp_->GetPlanesCount();
89 }
90
ReleasePixelMap()91 void ArkOhosImageDecoderAdapterWrapper::ReleasePixelMap()
92 {
93 return ctocpp_->ReleasePixelMap();
94 }
95
GetDecodeData()96 void* ArkOhosImageDecoderAdapterWrapper::GetDecodeData()
97 {
98 return ctocpp_->GetDecodeData();
99 }
100
101 } // namespace OHOS::ArkWeb
102