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/image.h"
17
18 #include "impl_factory.h"
19
20 namespace OHOS {
21 namespace Rosen {
22 namespace Drawing {
Image()23 Image::Image() noexcept : imageImplPtr(ImplFactory::CreateImageImpl()), width_(0), height_(0) {}
24
Image(void * rawImg)25 Image::Image(void* rawImg) noexcept : imageImplPtr(ImplFactory::CreateImageImpl(rawImg)), width_(0), height_(0) {}
26
BuildFromBitmap(const Bitmap & bitmap)27 Image* Image::BuildFromBitmap(const Bitmap& bitmap)
28 {
29 return static_cast<Image*>(imageImplPtr->BuildFromBitmap(bitmap));
30 }
31
BuildFromPicture(const Picture & picture,const SizeI & dimensions,const Matrix & matrix,const Brush & brush,BitDepth bitDepth,std::shared_ptr<ColorSpace> colorSpace)32 Image* Image::BuildFromPicture(const Picture& picture, const SizeI& dimensions, const Matrix& matrix,
33 const Brush& brush, BitDepth bitDepth, std::shared_ptr<ColorSpace> colorSpace)
34 {
35 return static_cast<Image*>(
36 imageImplPtr->BuildFromPicture(picture, dimensions, matrix, brush, bitDepth, colorSpace));
37 }
38
GetWidth()39 int Image::GetWidth()
40 {
41 width_ = imageImplPtr->GetWidth();
42 return width_;
43 }
44
GetHeight()45 int Image::GetHeight()
46 {
47 height_ = imageImplPtr->GetHeight();
48 return height_;
49 }
50 } // namespace Drawing
51 } // namespace Rosen
52 } // namespace OHOS
53