1 /*
2  * Copyright (C) 2010-2011 Dmitry Marakasov
3  *
4  * This file is part of glosm.
5  *
6  * glosm is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * glosm is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with glosm.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "PixelBuffer.hh"
21 
PixelBuffer(int width,int height,int bpp)22 PixelBuffer::PixelBuffer(int width, int height, int bpp) : width_(width), height_(height), bpp_(bpp), pixels_(width * height * bpp) {
23 }
24 
GetData()25 unsigned char* PixelBuffer::GetData() {
26 	return pixels_.data();
27 }
28 
GetRowPointer(int row,int offset) const29 const unsigned char* PixelBuffer::GetRowPointer(int row, int offset) const {
30 	return pixels_.data() + row * width_ * bpp_ + offset * bpp_;
31 }
32 
GetReverseRowPointer(int row,int offset) const33 const unsigned char* PixelBuffer::GetReverseRowPointer(int row, int offset) const {
34 	return pixels_.data() + (height_ - 1 - row) * width_ * bpp_ + offset * bpp_;
35 }
36 
GetWidth() const37 int PixelBuffer::GetWidth() const {
38 	return width_;
39 }
40 
GetHeight() const41 int PixelBuffer::GetHeight() const {
42 	return height_;
43 }
44 
GetBPP() const45 int PixelBuffer::GetBPP() const {
46 	return bpp_;
47 }
48