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 implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_ADAPTER_PREVIEW_OSAL_PIXEL_MAP_PREVIEW_H
17 #define FOUNDATION_ACE_ADAPTER_PREVIEW_OSAL_PIXEL_MAP_PREVIEW_H
18 
19 #include "base/image/pixel_map.h"
20 
21 namespace OHOS::Ace {
22 class PixelMapPreview : public PixelMap {
DECLARE_ACE_TYPE(PixelMapPreview,PixelMap)23     DECLARE_ACE_TYPE(PixelMapPreview, PixelMap)
24 
25 public:
26     explicit PixelMapPreview(std::shared_ptr<Media::PixelMap> pixmap) : pixmap_(std::move(pixmap)) {}
27     static RefPtr<PixelMap> CreatePixelMap(void* sptrAddr);
28     static RefPtr<PixelMap> CreatePixelMapFromDataAbility(void* uniquePtr);
29     static RefPtr<PixelMap> ConvertSkImageToPixmap(
30         const uint32_t* colors, uint32_t colorLength, int32_t width, int32_t height);
31     int32_t GetWidth() const override;
32     int32_t GetHeight() const override;
33     bool GetPixelsVec(std::vector<uint8_t>& data) const override;
34     const uint8_t* GetPixels() const override;
35     PixelFormat GetPixelFormat() const override;
36     AlphaType GetAlphaType() const override;
37     int32_t GetRowStride() const override;
38     int32_t GetRowBytes() const override;
39     int32_t GetByteCount() const override;
40     void* GetPixelManager() const override;
41     void* GetRawPixelMapPtr() const override;
42     std::string GetId() override;
43     std::string GetModifyId() override;
44     void Scale(float xAxis, float yAxis) override;
45     void Scale(float xAxis, float yAxis, const AceAntiAliasingOption &option) override;
GetPixelMapSharedPtr()46     std::shared_ptr<Media::PixelMap> GetPixelMapSharedPtr() override
47     {
48         return pixmap_;
49     }
50     bool EncodeTlv(std::vector<uint8_t>& buff) override;
51 
52 private:
53     std::shared_ptr<Media::PixelMap> pixmap_;
54 };
55 } // namespace OHOS::Ace
56 
57 #endif // FOUNDATION_ACE_ADAPTER_PREVIEW_OSAL_PIXEL_MAP_PREVIEW_H
58