Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: ui/gfx/image/image_unittest_util_ios.mm

Issue 10963064: Properly flip the CGContext during UIImage->SkBitmap conversions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/image/image_unittest.cc ('k') | ui/ui_unittests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import <CoreGraphics/CoreGraphics.h>
6 #import <UIKit/UIKit.h>
7
8 #include "base/mac/scoped_cftyperef.h"
9 #include "skia/ext/skia_utils_ios.h"
10 #include "ui/gfx/image/image_unittest_util.h"
11
12 namespace gfx {
13 namespace test {
14
15 SkColor GetPlatformImageColor(PlatformImage image, int x, int y) {
16 // Start by extracting the target pixel into a 1x1 CGImage.
17 base::mac::ScopedCFTypeRef<CGImageRef> pixel_image(
18 CGImageCreateWithImageInRect(image.CGImage, CGRectMake(x, y, 1, 1)));
19
20 // Draw that pixel into a 1x1 bitmap context.
21 base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space(
22 CGColorSpaceCreateDeviceRGB());
23 base::mac::ScopedCFTypeRef<CGContextRef> bitmap_context(
24 CGBitmapContextCreate(NULL, 1, 1, 8, 4,
Robert Sesek 2012/09/24 20:27:03 Use kCFAllocatorDefault instead of NULL.
Robert Sesek 2012/09/24 20:27:03 Can you do /*name=*/ for the params on this line?
rohitrao (ping after 24h) 2012/09/24 20:39:10 The parameter is a data buffer, or NULL to make Qu
rohitrao (ping after 24h) 2012/09/24 20:39:10 Done.
Robert Sesek 2012/09/24 20:39:56 Ah my B.
25 color_space,
26 kCGImageAlphaPremultipliedFirst |
27 kCGBitmapByteOrder32Host));
28 CGContextDrawImage(bitmap_context, CGRectMake(0, 0, 1, 1), pixel_image);
29
30 // The CGBitmapContext has the same memory layout as SkColor, so we can just
31 // read an SkColor straight out of the context.
32 SkColor* data = (SkColor*)CGBitmapContextGetData(bitmap_context);
Robert Sesek 2012/09/24 20:27:03 reinterpret_cast<>?
rohitrao (ping after 24h) 2012/09/24 20:39:10 Done.
33 return *data;
34 }
35
36 } // namespace test
37 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_unittest.cc ('k') | ui/ui_unittests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698