diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-24 23:28:13 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-24 23:28:13 +0000 |
commit | 3ee8852b73624373d2ace2c3d36880df0e9293ed (patch) | |
tree | 0a8ea0a1f62a2b23758f239d03f2728fda1e0e4f /skia | |
parent | fb312ebce43358b862d36f4c0aca6dffc9273abe (diff) | |
download | chromium_src-3ee8852b73624373d2ace2c3d36880df0e9293ed.zip chromium_src-3ee8852b73624373d2ace2c3d36880df0e9293ed.tar.gz chromium_src-3ee8852b73624373d2ace2c3d36880df0e9293ed.tar.bz2 |
Properly flip the CGContext during UIImage->SkBitmap conversions.
Skia's origin is in the upper-left whereas CG's origin is in the lower-left, so
the CGContext needs to be flipped in order to prevent the resulting image from
being upside-down.
TBR=thakis@chromium.org
BUG=None
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10963064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r-- | skia/ext/skia_utils_ios.mm | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/skia/ext/skia_utils_ios.mm b/skia/ext/skia_utils_ios.mm index 9d4c14a..a52a998 100644 --- a/skia/ext/skia_utils_ios.mm +++ b/skia/ext/skia_utils_ios.mm @@ -47,6 +47,12 @@ SkBitmap UIImageToSkBitmap(UIImage* image, CGSize size, bool is_opaque) { if (!context) return bitmap; + // We need to invert the y-axis of the canvas so that Core Graphics drawing + // happens right-side up. Skia has an upper-left origin and CG has a lower- + // left one. + CGContextScaleCTM(context, 1.0, -1.0); + CGContextTranslateCTM(context, 0, -size.height); + // UIGraphicsPushContext be called from the main thread. // TODO(rohitrao): We can use CG to make this thread safe, but the mac code // calls setCurrentContext, so it's similarly limited to the main thread. |