OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.h" | 5 #include "ui/gfx/image/image.h" |
6 | 6 |
| 7 #import <UIKit/UIKit.h> |
7 #include <cmath> | 8 #include <cmath> |
8 #include <limits> | 9 #include <limits> |
9 #import <UIKit/UIKit.h> | |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
13 #include "base/memory/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
14 #include "ui/base/layout.h" | 14 #include "ui/base/layout.h" |
15 #include "ui/gfx/image/image_png_rep.h" | 15 #include "ui/gfx/image/image_png_rep.h" |
16 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
17 #include "ui/gfx/image/image_skia_util_ios.h" | 17 #include "ui/gfx/image/image_skia_util_ios.h" |
18 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
19 | 19 |
20 namespace gfx { | 20 namespace gfx { |
21 namespace internal { | 21 namespace internal { |
22 | 22 |
23 namespace { | 23 namespace { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 UIImage* image = UIImageFromImageSkiaRep(image_skia_rep); | 110 UIImage* image = UIImageFromImageSkiaRep(image_skia_rep); |
111 return Get1xPNGBytesFromUIImage(image); | 111 return Get1xPNGBytesFromUIImage(image); |
112 } | 112 } |
113 | 113 |
114 ImageSkia* ImageSkiaFromPNG( | 114 ImageSkia* ImageSkiaFromPNG( |
115 const std::vector<gfx::ImagePNGRep>& image_png_reps) { | 115 const std::vector<gfx::ImagePNGRep>& image_png_reps) { |
116 // iOS does not expose libpng, so conversion from PNG to ImageSkia must go | 116 // iOS does not expose libpng, so conversion from PNG to ImageSkia must go |
117 // through UIImage. | 117 // through UIImage. |
118 gfx::ImageSkia* image_skia = new gfx::ImageSkia(); | 118 gfx::ImageSkia* image_skia = new gfx::ImageSkia(); |
119 for (size_t i = 0; i < image_png_reps.size(); ++i) { | 119 for (size_t i = 0; i < image_png_reps.size(); ++i) { |
120 scoped_nsobject<UIImage> uiimage(CreateUIImageFromImagePNGRep( | 120 base::scoped_nsobject<UIImage> uiimage( |
121 image_png_reps[i])); | 121 CreateUIImageFromImagePNGRep(image_png_reps[i])); |
122 gfx::ImageSkiaRep image_skia_rep = ImageSkiaRepOfScaleFactorFromUIImage( | 122 gfx::ImageSkiaRep image_skia_rep = ImageSkiaRepOfScaleFactorFromUIImage( |
123 uiimage, image_png_reps[i].scale_factor); | 123 uiimage, image_png_reps[i].scale_factor); |
124 if (!image_skia_rep.is_null()) | 124 if (!image_skia_rep.is_null()) |
125 image_skia->AddRepresentation(image_skia_rep); | 125 image_skia->AddRepresentation(image_skia_rep); |
126 } | 126 } |
127 return image_skia; | 127 return image_skia; |
128 } | 128 } |
129 | 129 |
130 gfx::Size UIImageSize(UIImage* image) { | 130 gfx::Size UIImageSize(UIImage* image) { |
131 int width = static_cast<int>(image.size.width); | 131 int width = static_cast<int>(image.size.width); |
132 int height = static_cast<int>(image.size.height); | 132 int height = static_cast<int>(image.size.height); |
133 return gfx::Size(width, height); | 133 return gfx::Size(width, height); |
134 } | 134 } |
135 | 135 |
136 } // namespace internal | 136 } // namespace internal |
137 } // namespace gfx | 137 } // namespace gfx |
OLD | NEW |