• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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       pixels_(nullptr),
26       width_(0),
27       height_(0),
28       format_({ COLORTYPE_UNKNOWN, ALPHATYPE_UNKNOWN })
29 {}
30 
~Bitmap()31 Bitmap::~Bitmap() {}
32 
Build(const int width,const int height,const BitmapFormat & format)33 void Bitmap::Build(const int width, const int height, const BitmapFormat& format)
34 {
35     bmpImplPtr->Build(width, height, format);
36 }
37 
GetWidth()38 int Bitmap::GetWidth()
39 {
40     width_ = bmpImplPtr->GetWidth();
41     return width_;
42 }
43 
GetHeight()44 int Bitmap::GetHeight()
45 {
46     height_ = bmpImplPtr->GetHeight();
47     return height_;
48 }
49 
SetPixels(void * pixel)50 void Bitmap::SetPixels(void* pixel)
51 {
52     pixels_ = pixel;
53     bmpImplPtr->SetPixels(pixel);
54 }
55 
GetPixels()56 void* Bitmap::GetPixels()
57 {
58     pixels_ = bmpImplPtr->GetPixels();
59     return pixels_;
60 }
61 
CopyPixels(Bitmap & dst,int srcLeft,int srcTop,int width,int height) const62 void Bitmap::CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height) const
63 {
64     bmpImplPtr->CopyPixels(dst, srcLeft, srcTop, width, height);
65 }
66 
ClearWithColor(const ColorQuad & color) const67 void Bitmap::ClearWithColor(const ColorQuad& color) const
68 {
69     bmpImplPtr->ClearWithColor(color);
70 }
71 
IsValid() const72 bool Bitmap::IsValid() const
73 {
74     return bmpImplPtr->IsValid();
75 }
76 
GetColor(int x,int y) const77 ColorQuad Bitmap::GetColor(int x, int y) const
78 {
79     return bmpImplPtr->GetColor(x, y);
80 }
81 
Free()82 void Bitmap::Free()
83 {
84     bmpImplPtr->Free();
85 }
86 
GetFormat() const87 BitmapFormat Bitmap::GetFormat() const
88 {
89     return format_;
90 }
91 } // namespace Drawing
92 } // namespace Rosen
93 } // namespace OHOS
94