1 /*
2 * Copyright (c) 2022 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 "bitmap_test.h"
17
18 using namespace OHOS::Media;
19
20 namespace OHOS {
21 namespace Rosen {
22 namespace Drawing {
23 using TestFunc = std::function<void(Canvas&, uint32_t, uint32_t)>;
TestDrawBitmap(Canvas & canvas,uint32_t width,uint32_t height)24 void BitmapTest::TestDrawBitmap(Canvas& canvas, uint32_t width, uint32_t height)
25 {
26 LOGI("+++++++ TestDrawBitmap");
27 Bitmap bmp;
28 BitmapFormat format { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE };
29 bmp.Build(200, 200, format); // bitmap width and height
30 bmp.ClearWithColor(Drawing::Color::COLOR_BLUE);
31
32 Pen pen;
33 pen.SetAntiAlias(true);
34 pen.SetColor(Drawing::Color::COLOR_BLUE);
35 pen.SetWidth(10); // The thickness of the pen is 10
36 canvas.AttachPen(pen);
37 canvas.DrawBitmap(bmp, 500, 500); // draw bitmap at (fx, fy)
38
39 LOGI("------- TestDrawBitmap");
40 }
41
BitmapTestCase()42 std::vector<BitmapTest::TestFunc> BitmapTest::BitmapTestCase()
43 {
44 std::vector<TestFunc> testFuncVec;
45 testFuncVec.push_back(TestDrawBitmap);
46 return testFuncVec;
47 }
48 } // namespace Drawing
49 } // namespace Rosen
50 } // namespace OHOS
51