[email protected] | 1bd1b5d | 2013-11-14 02:29:23 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
Lei Zhang | 1da18cf | 2018-01-27 07:18:29 | [diff] [blame] | 5 | #include "components/pwg_encoder/bitmap_image.h" |
[email protected] | 1bd1b5d | 2013-11-14 02:29:23 | [diff] [blame] | 6 | |
Lei Zhang | 1da18cf | 2018-01-27 07:18:29 | [diff] [blame] | 7 | #include "base/logging.h" |
8 | |||||
9 | namespace pwg_encoder { | ||||
[email protected] | 1bd1b5d | 2013-11-14 02:29:23 | [diff] [blame] | 10 | |
11 | namespace { | ||||
avi | 2729e44 | 2015-12-26 05:27:45 | [diff] [blame] | 12 | const uint8_t kCurrentlySupportedNumberOfChannels = 4; |
[email protected] | 1bd1b5d | 2013-11-14 02:29:23 | [diff] [blame] | 13 | } |
14 | |||||
avi | 2729e44 | 2015-12-26 05:27:45 | [diff] [blame] | 15 | BitmapImage::BitmapImage(const gfx::Size& size, Colorspace colorspace) |
[email protected] | fd1d342 | 2013-11-20 21:59:28 | [diff] [blame] | 16 | : size_(size), |
[email protected] | 1bd1b5d | 2013-11-14 02:29:23 | [diff] [blame] | 17 | colorspace_(colorspace), |
avi | 2729e44 | 2015-12-26 05:27:45 | [diff] [blame] | 18 | data_(new uint8_t[size.GetArea() * channels()]) {} |
[email protected] | 1bd1b5d | 2013-11-14 02:29:23 | [diff] [blame] | 19 | |
Lei Zhang | 1da18cf | 2018-01-27 07:18:29 | [diff] [blame] | 20 | BitmapImage::~BitmapImage() {} |
[email protected] | 1bd1b5d | 2013-11-14 02:29:23 | [diff] [blame] | 21 | |
avi | 2729e44 | 2015-12-26 05:27:45 | [diff] [blame] | 22 | uint8_t BitmapImage::channels() const { |
[email protected] | 1bd1b5d | 2013-11-14 02:29:23 | [diff] [blame] | 23 | return kCurrentlySupportedNumberOfChannels; |
24 | } | ||||
25 | |||||
avi | 2729e44 | 2015-12-26 05:27:45 | [diff] [blame] | 26 | const uint8_t* BitmapImage::GetPixel(const gfx::Point& point) const { |
[email protected] | fe7f2a87 | 2014-04-17 01:48:43 | [diff] [blame] | 27 | DCHECK_LT(point.x(), size_.width()); |
28 | DCHECK_LT(point.y(), size_.height()); | ||||
29 | return data_.get() + (point.y() * size_.width() + point.x()) * channels(); | ||||
30 | } | ||||
31 | |||||
Lei Zhang | 1da18cf | 2018-01-27 07:18:29 | [diff] [blame] | 32 | } // namespace pwg_encoder |