OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "chrome/utility/cloud_print/bitmap_image.h" | 6 #include "chrome/utility/cloud_print/bitmap_image.h" |
7 | 7 |
8 namespace cloud_print { | 8 namespace cloud_print { |
9 | 9 |
10 namespace { | 10 namespace { |
11 const uint8 kCurrentlySupportedNumberOfChannels = 4; | 11 const uint8_t kCurrentlySupportedNumberOfChannels = 4; |
12 } | 12 } |
13 | 13 |
14 BitmapImage::BitmapImage(const gfx::Size& size, | 14 BitmapImage::BitmapImage(const gfx::Size& size, Colorspace colorspace) |
15 Colorspace colorspace) | |
16 : size_(size), | 15 : size_(size), |
17 colorspace_(colorspace), | 16 colorspace_(colorspace), |
18 data_(new uint8[size.GetArea() * channels()]) { | 17 data_(new uint8_t[size.GetArea() * channels()]) {} |
19 } | |
20 | 18 |
21 BitmapImage::~BitmapImage() { | 19 BitmapImage::~BitmapImage() { |
22 } | 20 } |
23 | 21 |
24 uint8 BitmapImage::channels() const { | 22 uint8_t BitmapImage::channels() const { |
25 return kCurrentlySupportedNumberOfChannels; | 23 return kCurrentlySupportedNumberOfChannels; |
26 } | 24 } |
27 | 25 |
28 const uint8* BitmapImage::GetPixel(const gfx::Point& point) const { | 26 const uint8_t* BitmapImage::GetPixel(const gfx::Point& point) const { |
29 DCHECK_LT(point.x(), size_.width()); | 27 DCHECK_LT(point.x(), size_.width()); |
30 DCHECK_LT(point.y(), size_.height()); | 28 DCHECK_LT(point.y(), size_.height()); |
31 return data_.get() + (point.y() * size_.width() + point.x()) * channels(); | 29 return data_.get() + (point.y() * size_.width() + point.x()) * channels(); |
32 } | 30 } |
33 | 31 |
34 } // namespace cloud_print | 32 } // namespace cloud_print |
OLD | NEW |