Home | History | Annotate | Download | only in cloud_print
      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 
      5 #include "base/logging.h"
      6 #include "chrome/utility/cloud_print/bitmap_image.h"
      7 
      8 namespace cloud_print {
      9 
     10 namespace {
     11 const uint8 kCurrentlySupportedNumberOfChannels = 4;
     12 }
     13 
     14 BitmapImage::BitmapImage(const gfx::Size& size,
     15                          Colorspace colorspace)
     16     : size_(size),
     17       colorspace_(colorspace),
     18       data_(new uint8[size.GetArea() * channels()]) {
     19 }
     20 
     21 BitmapImage::~BitmapImage() {
     22 }
     23 
     24 uint8 BitmapImage::channels() const {
     25   return kCurrentlySupportedNumberOfChannels;
     26 }
     27 
     28 const uint8* BitmapImage::GetPixel(const gfx::Point& point) const {
     29   DCHECK_LT(point.x(), size_.width());
     30   DCHECK_LT(point.y(), size_.height());
     31   return data_.get() + (point.y() * size_.width() + point.x()) * channels();
     32 }
     33 
     34 }  // namespace cloud_print
     35