Debian Codegraph @

libs/ibl/src/Image.cpp

raw
1 /*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <ibl/Image.h>
18
19 #include <utility>
20
21 namespace filament {
22 namespace ibl {
23
24 Image::Image() = default;
25
26 Image::Image(size_t w, size_t h, size_t stride)
27 : mBpr((stride ? stride : w) * sizeof(math::float3)),
28 mWidth(w),
29 mHeight(h),
30 mOwnedData(new uint8_t[mBpr * h]),
31 mData(mOwnedData.get()) {
32 }
33
34 void Image::reset() {
35 mOwnedData.release();
36 mWidth = 0;
37 mHeight = 0;
38 mBpr = 0;
39 mData = nullptr;
40 }
41
42 void Image::set(Image const& image) {
43 mOwnedData.release();
44 mWidth = image.mWidth;
45 mHeight = image.mHeight;
46 mBpr = image.mBpr;
47 mData = image.mData;
48 }
49
50 void Image::subset(Image const& image, size_t x, size_t y, size_t w, size_t h) {
51 mOwnedData.release();
52 mWidth = w;
53 mHeight = h;
54 mBpr = image.mBpr;
55 mData = static_cast<uint8_t*>(image.getPixelRef(x, y));
56 }
57
58 } // namespace ibl
59 } // namespace filament
60