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 #include <iostream>
17
18 #include "pixel_map.h"
19 #include "transaction/rs_interfaces.h"
20
21 using namespace OHOS;
22 using namespace OHOS::Rosen;
23 using namespace std;
24
25 constexpr uint32_t SIZE_WIDTH = 1;
26 constexpr uint32_t SIZE_HEIGHT = 1;
27
28 // Switch of watermark.
main()29 int main()
30 {
31 const uint32_t color[1] = { 0x6f0000ff };
32 uint32_t colorLength = sizeof(color) / sizeof(color[0]);
33 const int32_t offset = 0;
34 Media::InitializationOptions opts;
35 opts.size.width = SIZE_WIDTH;
36 opts.size.height = SIZE_HEIGHT;
37 opts.pixelFormat = Media::PixelFormat::RGBA_8888;
38 opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
39 int32_t stride = opts.size.width;
40 std::unique_ptr<Media::PixelMap> pixelMap1 = Media::PixelMap::Create(color, colorLength, offset, stride, opts);
41
42 cout << "ShowWatermark interface. Open: 1 Close: 0" << endl;
43 cout << "Enter: ";
44 int open;
45 cin >> open;
46
47 if (open) {
48 RSInterfaces::GetInstance().ShowWatermark(std::move(pixelMap1), true);
49 } else {
50 RSInterfaces::GetInstance().ShowWatermark(nullptr, false);
51 }
52 return 0;
53 }
54