diff options
Diffstat (limited to 'ui/gfx/image/image_mac.mm')
-rw-r--r-- | ui/gfx/image/image_mac.mm | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/ui/gfx/image/image_mac.mm b/ui/gfx/image/image_mac.mm index eeed857..55b4aa4 100644 --- a/ui/gfx/image/image_mac.mm +++ b/ui/gfx/image/image_mac.mm @@ -1,46 +1,25 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import <AppKit/AppKit.h> -#import <vector> -#include "base/memory/scoped_nsobject.h" #include "base/memory/scoped_ptr.h" #include "skia/ext/skia_utils_mac.h" #include "third_party/skia/include/core/SkBitmap.h" -#include "ui/gfx/image/image_skia.h" namespace gfx { namespace internal { -gfx::ImageSkia NSImageToImageSkia(NSImage* image) { - gfx::ImageSkia image_skia; +bool NSImageToSkBitmaps(NSImage* image, std::vector<const SkBitmap*>* bitmaps) { for (NSImageRep* imageRep in [image representations]) { - NSSize imageRepSize = [imageRep size]; - SkBitmap bitmap(gfx::NSImageRepToSkBitmap(imageRep, imageRepSize, false)); - if (!bitmap.isNull() && !bitmap.empty()) { - float scaleFactor = imageRepSize.width / [image size].width; - image_skia.AddBitmapForScale(bitmap, scaleFactor); - } + scoped_ptr<SkBitmap> bitmap(new SkBitmap( + gfx::NSImageRepToSkBitmap(imageRep, [imageRep size], false))); + if (bitmap->isNull()) + return false; + bitmaps->push_back(bitmap.release()); } - return image_skia; -} - -NSImage* ImageSkiaToNSImage(const gfx::ImageSkia* image_skia) { - if (image_skia->empty()) - return nil; - - scoped_nsobject<NSImage> image([[NSImage alloc] init]); - - const std::vector<SkBitmap> bitmaps = image_skia->bitmaps(); - for (std::vector<SkBitmap>::const_iterator it = bitmaps.begin(); - it != bitmaps.end(); ++it) { - [image addRepresentation:gfx::SkBitmapToNSBitmapImageRep(*it)]; - } - - [image setSize:NSMakeSize(image_skia->width(), image_skia->height())]; - return [image.release() autorelease]; + return true; } } // namespace internal |