blob: 2e302bb889170ddb57be13c34d3d337e59021670 [file] [log] [blame]
[email protected]1bd1b5d2013-11-14 02:29:231// 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 Zhang1da18cf2018-01-27 07:18:295#include "components/pwg_encoder/bitmap_image.h"
[email protected]1bd1b5d2013-11-14 02:29:236
Lei Zhang1da18cf2018-01-27 07:18:297#include "base/logging.h"
8
9namespace pwg_encoder {
[email protected]1bd1b5d2013-11-14 02:29:2310
11namespace {
avi2729e442015-12-26 05:27:4512const uint8_t kCurrentlySupportedNumberOfChannels = 4;
[email protected]1bd1b5d2013-11-14 02:29:2313}
14
avi2729e442015-12-26 05:27:4515BitmapImage::BitmapImage(const gfx::Size& size, Colorspace colorspace)
[email protected]fd1d3422013-11-20 21:59:2816 : size_(size),
[email protected]1bd1b5d2013-11-14 02:29:2317 colorspace_(colorspace),
avi2729e442015-12-26 05:27:4518 data_(new uint8_t[size.GetArea() * channels()]) {}
[email protected]1bd1b5d2013-11-14 02:29:2319
Lei Zhang1da18cf2018-01-27 07:18:2920BitmapImage::~BitmapImage() {}
[email protected]1bd1b5d2013-11-14 02:29:2321
avi2729e442015-12-26 05:27:4522uint8_t BitmapImage::channels() const {
[email protected]1bd1b5d2013-11-14 02:29:2323 return kCurrentlySupportedNumberOfChannels;
24}
25
avi2729e442015-12-26 05:27:4526const uint8_t* BitmapImage::GetPixel(const gfx::Point& point) const {
[email protected]fe7f2a872014-04-17 01:48:4327 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 Zhang1da18cf2018-01-27 07:18:2932} // namespace pwg_encoder