Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "ui/gfx/image/image_skia_util_mac.h" | 5 #include "ui/gfx/image/image_skia_util_mac.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #import <AppKit/AppKit.h> | 10 #import <AppKit/AppKit.h> |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin(); | 95 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin(); |
| 96 it != image_reps.end(); ++it) { | 96 it != image_reps.end(); ++it) { |
| 97 [image addRepresentation: | 97 [image addRepresentation: |
| 98 gfx::SkBitmapToNSBitmapImageRep(it->sk_bitmap())]; | 98 gfx::SkBitmapToNSBitmapImageRep(it->sk_bitmap())]; |
| 99 } | 99 } |
| 100 | 100 |
| 101 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; | 101 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; |
| 102 return [image.release() autorelease]; | 102 return [image.release() autorelease]; |
| 103 } | 103 } |
| 104 | 104 |
| 105 NSImage* NSImageFromImageSkiaWithColorSpace(const gfx::ImageSkia& image_skia, | |
| 106 CGColorSpaceRef color_space) { | |
| 107 if (image_skia.empty()) | |
| 108 return nil; | |
| 109 | |
| 110 scoped_nsobject<NSImage> image([[NSImage alloc] init]); | |
| 111 | |
| 112 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.GetRepresentations(); | |
|
Nico
2012/08/17 05:32:35
const ref?
sadrul
2012/08/17 05:57:43
Done.
| |
| 113 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin(); | |
| 114 it != image_reps.end(); ++it) { | |
| 115 [image addRepresentation: | |
| 116 gfx::SkBitmapToNSBitmapImageRepWithColorSpace(it->sk_bitmap(), | |
| 117 color_space)]; | |
| 118 } | |
| 119 | |
| 120 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; | |
| 121 return [image.release() autorelease]; | |
| 122 } | |
| 123 | |
| 105 } // namespace gfx | 124 } // namespace gfx |
| OLD | NEW |