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

Side by Side Diff: src/utils/ios/SkImageDecoder_iOS.mm

Issue 1197963003: Remove old iOS porting files. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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 | « src/utils/ios/SkFontHost_iOS.mm ('k') | src/utils/ios/SkOSFile_iOS.mm » ('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 /*
2 * Copyright 2010 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #import <CoreGraphics/CoreGraphics.h>
9 #include <CoreGraphics/CGColorSpace.h>
10 #import <UIKit/UIKit.h>
11
12 #include "SkImageDecoder.h"
13 #include "SkImageEncoder.h"
14 #include "SkMovie.h"
15 #include "SkStream_NSData.h"
16
17 class SkImageDecoder_iOS : public SkImageDecoder {
18 protected:
19 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode);
20 };
21
22 #define BITMAP_INFO (kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast)
23
24 bool SkImageDecoder_iOS::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
25
26 NSData* data = NSData_dataWithStream(stream);
27
28 UIImage* uimage = [UIImage imageWithData:data];
29
30 const int width = uimage.size.width;
31 const int height = uimage.size.height;
32 bm->setInfo(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType), 0);
33 if (SkImageDecoder::kDecodeBounds_Mode == mode) {
34 return true;
35 }
36
37 if (!this->allocPixelRef(bm, NULL)) {
38 return false;
39 }
40
41 bm->lockPixels();
42 bm->eraseColor(0);
43
44 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
45 CGContextRef cg = CGBitmapContextCreate(bm->getPixels(), width, height,
46 8, bm->rowBytes(), cs, BITMAP_INFO);
47 CGContextDrawImage(cg, CGRectMake(0, 0, width, height), uimage.CGImage);
48 CGContextRelease(cg);
49 CGColorSpaceRelease(cs);
50
51 bm->unlockPixels();
52 return true;
53 }
54
55 /////////////////////////////////////////////////////////////////////////
56
57 SkImageDecoder* SkImageDecoder::Factory(SkStreamRewindable* stream) {
58 return new SkImageDecoder_iOS;
59 }
60
61 SkMovie* SkMovie::DecodeStream(SkStreamRewindable* stream) {
62 return NULL;
63 }
64
65
OLDNEW
« no previous file with comments | « src/utils/ios/SkFontHost_iOS.mm ('k') | src/utils/ios/SkOSFile_iOS.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698