• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 DRAWING_CANVAS_H
17 #define DRAWING_CANVAS_H
18 #include "draw/canvas.h"
19 #include "drawing_error_code.h"
20 #include "utils/rect.h"
21 #include "utils/sampling_options.h"
22 
23 namespace OHOS {
24 namespace Media {
25 class PixelMap;
26 }
27 }
28 
29 class DrawingCanvasUtils {
30 public:
31     static OH_Drawing_ErrorCode DrawPixelMapNine(OHOS::Rosen::Drawing::Canvas* canvas,
32         std::shared_ptr<OHOS::Media::PixelMap> pixelMap, const OHOS::Rosen::Drawing::Rect* center,
33         const OHOS::Rosen::Drawing::Rect* dst, const OHOS::Rosen::Drawing::FilterMode mode);
34     static void DrawPixelMapRect(OHOS::Rosen::Drawing::Canvas* canvas, std::shared_ptr<OHOS::Media::PixelMap> pixelMap,
35         const OHOS::Rosen::Drawing::Rect* src, const OHOS::Rosen::Drawing::Rect* dst,
36         const OHOS::Rosen::Drawing::SamplingOptions* sampling);
37     static OH_Drawing_ErrorCode DrawPixelMapRectConstraint(OHOS::Rosen::Drawing::Canvas* canvas,
38         std::shared_ptr<OHOS::Media::PixelMap> pixelMap, const OHOS::Rosen::Drawing::Rect* src,
39         const OHOS::Rosen::Drawing::Rect* dst, const OHOS::Rosen::Drawing::SamplingOptions* sampling,
40         const OHOS::Rosen::Drawing::SrcRectConstraint constraint);
41     static void DrawRecordCmd(OHOS::Rosen::Drawing::Canvas* canvas,
42         const std::shared_ptr<OHOS::Rosen::Drawing::RecordCmd> recordCmd, bool canNesting = false);
43     static bool ExtractDrawingBitmap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap,
44         OHOS::Rosen::Drawing::Bitmap& bitmap);
45 };
46 
47 extern OH_Drawing_ErrorCode g_drawingErrorCode;
48 #endif // DRAWING_CANVAS_H