1 // Copyright (c) 2012 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 "ui/gfx/image/image_skia_rep.h" 6 7 namespace gfx { 8 9 ImageSkiaRep::ImageSkiaRep() : scale_(1.0f) { 10 } 11 12 ImageSkiaRep::~ImageSkiaRep() { 13 } 14 15 ImageSkiaRep::ImageSkiaRep(const gfx::Size& size, float scale) : scale_(scale) { 16 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, 17 static_cast<int>(size.width() * scale), 18 static_cast<int>(size.height() * scale)); 19 bitmap_.allocPixels(); 20 } 21 22 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src, float scale) 23 : bitmap_(src), 24 scale_(scale) { 25 } 26 27 int ImageSkiaRep::GetWidth() const { 28 return static_cast<int>(bitmap_.width() / scale_); 29 } 30 31 int ImageSkiaRep::GetHeight() const { 32 return static_cast<int>(bitmap_.height() / scale_); 33 } 34 35 } // namespace gfx 36