OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCGUtils.h" | 8 #include "SkCGUtils.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 SkColorProfileType cpType = kLinear_SkColorProfileType; | 150 SkColorProfileType cpType = kLinear_SkColorProfileType; |
151 | 151 |
152 CGColorSpaceRef cs = CGImageGetColorSpace(image); | 152 CGColorSpaceRef cs = CGImageGetColorSpace(image); |
153 if (cs) { | 153 if (cs) { |
154 CGColorSpaceModel m = CGColorSpaceGetModel(cs); | 154 CGColorSpaceModel m = CGColorSpaceGetModel(cs); |
155 if (kCGColorSpaceModelRGB == m && colorspace_is_sRGB(cs)) { | 155 if (kCGColorSpaceModelRGB == m && colorspace_is_sRGB(cs)) { |
156 cpType = kSRGB_SkColorProfileType; | 156 cpType = kSRGB_SkColorProfileType; |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 bm->setInfo(SkImageInfo::MakeN32Premul(width, height, cpType)); | 160 SkAlphaType at = kPremul_SkAlphaType; |
| 161 switch (CGImageGetAlphaInfo(image)) { |
| 162 case kCGImageAlphaNone: |
| 163 case kCGImageAlphaNoneSkipLast: |
| 164 case kCGImageAlphaNoneSkipFirst: |
| 165 at = kOpaque_SkAlphaType; |
| 166 break; |
| 167 default: |
| 168 break; |
| 169 } |
| 170 |
| 171 bm->setInfo(SkImageInfo::Make(width, height, kN32_SkColorType, at, cpType)); |
161 if (SkImageDecoder::kDecodeBounds_Mode == mode) { | 172 if (SkImageDecoder::kDecodeBounds_Mode == mode) { |
162 return kSuccess; | 173 return kSuccess; |
163 } | 174 } |
164 | 175 |
165 if (!this->allocPixelRef(bm, NULL)) { | 176 if (!this->allocPixelRef(bm, NULL)) { |
166 return kFailure; | 177 return kFailure; |
167 } | 178 } |
168 | 179 |
169 SkAutoLockPixels alp(*bm); | 180 SkAutoLockPixels alp(*bm); |
170 | 181 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 394 |
384 SkAutoTCallVProc<const void, CFRelease> arsrc(imageSrc); | 395 SkAutoTCallVProc<const void, CFRelease> arsrc(imageSrc); |
385 const CFStringRef name = CGImageSourceGetType(imageSrc); | 396 const CFStringRef name = CGImageSourceGetType(imageSrc); |
386 if (NULL == name) { | 397 if (NULL == name) { |
387 return SkImageDecoder::kUnknown_Format; | 398 return SkImageDecoder::kUnknown_Format; |
388 } | 399 } |
389 return UTType_to_Format(name); | 400 return UTType_to_Format(name); |
390 } | 401 } |
391 | 402 |
392 static SkImageDecoder_FormatReg gFormatReg(get_format_cg); | 403 static SkImageDecoder_FormatReg gFormatReg(get_format_cg); |
OLD | NEW |