OLD | NEW |
1 #include "sk_tool_utils.h" | 1 #include "sk_tool_utils.h" |
2 | 2 |
3 namespace sk_tool_utils { | 3 namespace sk_tool_utils { |
4 | 4 |
| 5 const char* colortype_name(SkColorType ct) { |
| 6 switch (ct) { |
| 7 case kUnknown_SkColorType: return "Unknown"; |
| 8 case kAlpha_8_SkColorType: return "Alpha_8"; |
| 9 case kIndex_8_SkColorType: return "Index_8"; |
| 10 case kARGB_4444_SkColorType: return "ARGB_4444"; |
| 11 case kRGB_565_SkColorType: return "RGB_565"; |
| 12 case kRGBA_8888_SkColorType: return "RGBA_8888"; |
| 13 case kBGRA_8888_SkColorType: return "BGRA_8888"; |
| 14 default: |
| 15 SkASSERT(false); |
| 16 return "unexpected colortype"; |
| 17 } |
| 18 } |
| 19 |
5 void config8888_to_imagetypes(SkCanvas::Config8888 config, SkColorType* ct, SkAl
phaType* at) { | 20 void config8888_to_imagetypes(SkCanvas::Config8888 config, SkColorType* ct, SkAl
phaType* at) { |
6 switch (config) { | 21 switch (config) { |
7 case SkCanvas::kNative_Premul_Config8888: | 22 case SkCanvas::kNative_Premul_Config8888: |
8 *ct = kPMColor_SkColorType; | 23 *ct = kPMColor_SkColorType; |
9 *at = kPremul_SkAlphaType; | 24 *at = kPremul_SkAlphaType; |
10 break; | 25 break; |
11 case SkCanvas::kNative_Unpremul_Config8888: | 26 case SkCanvas::kNative_Unpremul_Config8888: |
12 *ct = kPMColor_SkColorType; | 27 *ct = kPMColor_SkColorType; |
13 *at = kUnpremul_SkAlphaType; | 28 *at = kUnpremul_SkAlphaType; |
14 break; | 29 break; |
(...skipping 24 matching lines...) Expand all Loading... |
39 tmp.lockPixels(); | 54 tmp.lockPixels(); |
40 | 55 |
41 SkImageInfo info = tmp.info(); | 56 SkImageInfo info = tmp.info(); |
42 info.fColorType = colorType; | 57 info.fColorType = colorType; |
43 info.fAlphaType = alphaType; | 58 info.fAlphaType = alphaType; |
44 | 59 |
45 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y); | 60 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y); |
46 } | 61 } |
47 | 62 |
48 } | 63 } |
OLD | NEW |