OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "skia/ext/skia_utils_mac.h" | 5 #include "skia/ext/skia_utils_mac.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/scoped_cftyperef.h" | 10 #include "base/scoped_cftyperef.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 NSImage* SkBitmapToNSImage(const SkBitmap& skiaBitmap) { | 170 NSImage* SkBitmapToNSImage(const SkBitmap& skiaBitmap) { |
171 // First convert SkBitmap to CGImageRef. | 171 // First convert SkBitmap to CGImageRef. |
172 CGImageRef cgimage = SkCreateCGImageRef(skiaBitmap); | 172 CGImageRef cgimage = SkCreateCGImageRef(skiaBitmap); |
173 | 173 |
174 // Now convert to NSImage. | 174 // Now convert to NSImage. |
175 NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc] | 175 NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc] |
176 initWithCGImage:cgimage] autorelease]; | 176 initWithCGImage:cgimage] autorelease]; |
177 CFRelease(cgimage); | 177 CFRelease(cgimage); |
178 NSImage* image = [[[NSImage alloc] init] autorelease]; | 178 NSImage* image = [[[NSImage alloc] init] autorelease]; |
179 [image addRepresentation:bitmap]; | 179 [image addRepresentation:bitmap]; |
| 180 [image setSize:NSMakeSize(skiaBitmap.width(), skiaBitmap.height())]; |
180 return image; | 181 return image; |
181 } | 182 } |
182 | 183 |
183 } // namespace gfx | 184 } // namespace gfx |
OLD | NEW |