1 /*
2 * Copyright (c) 2021-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 "image/bitmap.h"
17
18 #include "impl_factory.h"
19
20 namespace OHOS {
21 namespace Rosen {
22 namespace Drawing {
Bitmap()23 Bitmap::Bitmap()
24 : bmpImplPtr(ImplFactory::CreateBitmapImpl()),
25 format_({ COLORTYPE_UNKNOWN, ALPHATYPE_UNKNOWN })
26 {}
27
~Bitmap()28 Bitmap::~Bitmap() {}
29
Build(int32_t width,int32_t height,const BitmapFormat & format,int32_t stride)30 void Bitmap::Build(int32_t width, int32_t height, const BitmapFormat& format, int32_t stride)
31 {
32 format_ = format;
33 bmpImplPtr->Build(width, height, format, stride);
34 }
35
GetWidth() const36 int Bitmap::GetWidth() const
37 {
38 return bmpImplPtr->GetWidth();
39 }
40
GetHeight() const41 int Bitmap::GetHeight() const
42 {
43 return bmpImplPtr->GetHeight();
44 }
45
SetPixels(void * pixel)46 void Bitmap::SetPixels(void* pixel)
47 {
48 bmpImplPtr->SetPixels(pixel);
49 }
50
GetPixels() const51 void* Bitmap::GetPixels() const
52 {
53 return bmpImplPtr->GetPixels();
54 }
55
CopyPixels(Bitmap & dst,int srcLeft,int srcTop,int width,int height) const56 void Bitmap::CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height) const
57 {
58 bmpImplPtr->CopyPixels(dst, srcLeft, srcTop, width, height);
59 }
60
ClearWithColor(const ColorQuad & color) const61 void Bitmap::ClearWithColor(const ColorQuad& color) const
62 {
63 bmpImplPtr->ClearWithColor(color);
64 }
65
IsValid() const66 bool Bitmap::IsValid() const
67 {
68 return bmpImplPtr->IsValid();
69 }
70
GetColor(int x,int y) const71 ColorQuad Bitmap::GetColor(int x, int y) const
72 {
73 return bmpImplPtr->GetColor(x, y);
74 }
75
Free()76 void Bitmap::Free()
77 {
78 bmpImplPtr->Free();
79 }
80
GetFormat() const81 BitmapFormat Bitmap::GetFormat() const
82 {
83 return format_;
84 }
85 } // namespace Drawing
86 } // namespace Rosen
87 } // namespace OHOS
88