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 #ifndef NINE_PATCH_LISTENER_H
17 #define NINE_PATCH_LISTENER_H
18 
19 #include <cstdint>
20 #include <cstdio>
21 #include <string>
22 #include "nocopyable.h"
23 #include "png_ninepatch_res.h"
24 
25 namespace OHOS {
26 namespace ImagePlugin {
27 class NinePatchListener {
28 public:
NinePatchListener()29     NinePatchListener() : patch_(nullptr), patchSize_(0)
30     {}
~NinePatchListener()31     ~NinePatchListener()
32     {
33         if (patch_ != nullptr) {
34             free(patch_);
35             patch_ = nullptr;
36         }
37     }
38     bool ReadChunk(const std::string &tag, void *data, size_t length);
39     void Scale(float scaleX, float scaleY, int32_t scaledWidth, int32_t scaledHeight);
40     PngNinePatchRes *patch_ = nullptr;
41     size_t patchSize_ = 0;
42 
43 private:
44     DISALLOW_COPY_AND_MOVE(NinePatchListener);
45 };
46 } // namespace ImagePlugin
47 } // namespace OHOS
48 #endif // NINE_PATCH_LISTENER_H
49