• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "image_info.h"
17 
18 #include "string_ex.h"
19 #include "nlohmann/json.hpp"
20 #include "hilog_wrapper.h"
21 
22 namespace OHOS {
23 namespace AAFwk {
ReadFromParcel(Parcel & parcel)24 bool ImageHeader::ReadFromParcel(Parcel &parcel)
25 {
26     colorMode = parcel.ReadUint32();
27     reserved = parcel.ReadUint32();
28     width = parcel.ReadUint16();
29     height = parcel.ReadUint16();
30     return true;
31 }
32 
Unmarshalling(Parcel & parcel)33 ImageHeader *ImageHeader::Unmarshalling(Parcel &parcel)
34 {
35     ImageHeader *info = new (std::nothrow) ImageHeader();
36     if (info == nullptr) {
37         return nullptr;
38     }
39 
40     if (!info->ReadFromParcel(parcel)) {
41         delete info;
42         info = nullptr;
43     }
44     return info;
45 }
46 
Marshalling(Parcel & parcel) const47 bool ImageHeader::Marshalling(Parcel &parcel) const
48 {
49     parcel.WriteUint32(colorMode);
50     parcel.WriteUint32(reserved);
51     parcel.WriteUint16(width);
52     parcel.WriteUint16(height);
53     return true;
54 }
55 
ReadFromParcel(Parcel & parcel)56 bool ImageInfo::ReadFromParcel(Parcel &parcel)
57 {
58     return false;
59 }
60 
Unmarshalling(Parcel & parcel)61 ImageInfo *ImageInfo::Unmarshalling(Parcel &parcel)
62 {
63     ImageInfo *info = new (std::nothrow) ImageInfo();
64     if (info == nullptr) {
65         return nullptr;
66     }
67 
68     if (!info->ReadFromParcel(parcel)) {
69         delete info;
70         info = nullptr;
71     }
72     return info;
73 }
74 
Marshalling(Parcel & parcel) const75 bool ImageInfo::Marshalling(Parcel &parcel) const
76 {
77     return false;
78 }
79 }  // namespace AAFwk
80 }  // namespace OHOS