Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1 | #Topic Image_Info |
| 2 | #Alias Image_Info_Reference |
| 3 | |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 4 | Image_Info specifies the dimensions and encoding of the pixels in a Bitmap. |
| 5 | The dimensions are integral width and height. The encoding is how pixel |
| 6 | bits describe Color_Alpha, transparency; Color components red, blue, |
| 7 | and green; and Color_Space, the range and linearity of colors. |
| 8 | |
| 9 | Image_Info describes an uncompressed raster pixels. In contrast, Image |
| 10 | additionally describes compressed pixels like PNG, and Surface describes |
| 11 | destinations on the GPU. Image and Surface may be specified by Image_Info, |
| 12 | but Image and Surface may not contain Image_Info. |
| 13 | |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 14 | #Subtopic Overview |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 15 | #Subtopic Subtopic |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 16 | #Populate |
| 17 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 18 | ## |
| 19 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 20 | #Subtopic Constant |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 21 | #Populate |
| 22 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 23 | |
| 24 | # ------------------------------------------------------------------------------ |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 25 | #Subtopic Alpha_Type |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 26 | #Line # encoding for pixel transparency ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 27 | #Alias Alpha_Type |
| 28 | #Alias Alpha_Types |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 29 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 30 | #PhraseDef list_of_alpha_types |
| 31 | kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType, |
| 32 | kUnpremul_SkAlphaType |
| 33 | ## |
| 34 | |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 35 | #Enum SkAlphaType |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 36 | #Line # encoding for pixel transparency ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 37 | |
| 38 | #Code |
| 39 | enum SkAlphaType { |
| 40 | kUnknown_SkAlphaType, |
| 41 | kOpaque_SkAlphaType, |
| 42 | kPremul_SkAlphaType, |
| 43 | kUnpremul_SkAlphaType, |
| 44 | kLastEnum_SkAlphaType = kUnpremul_SkAlphaType, |
| 45 | }; |
| 46 | ## |
| 47 | |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 48 | Describes how to interpret the alpha component of a pixel. A pixel may |
| 49 | be opaque, or Color_Alpha, describing multiple levels of transparency. |
| 50 | |
| 51 | In simple blending, Color_Alpha weights the draw color and the destination |
| 52 | color to create a new color. If alpha describes a weight from zero to one: |
| 53 | |
| 54 | #Formula |
| 55 | new color = draw color * alpha + destination color * (1 - alpha) |
| 56 | ## |
| 57 | |
| 58 | In practice alpha is encoded in two or more bits, where 1.0 equals all bits set. |
| 59 | |
| 60 | Color_RGB may have Color_Alpha included in each component value; the stored |
| 61 | value is the original Color_RGB multiplied by Color_Alpha. Premultiplied color |
| 62 | components improve performance. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 63 | |
| 64 | #Const kUnknown_SkAlphaType 0 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 65 | Alpha_Type is uninitialized. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 66 | ## |
| 67 | #Const kOpaque_SkAlphaType 1 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 68 | Pixels are opaque. The Color_Type must have no explicit alpha |
| 69 | component, or all alpha components must be set to their maximum value. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 70 | ## |
| 71 | #Const kPremul_SkAlphaType 2 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 72 | Pixels have alpha premultiplied into color components. |
| 73 | Surface pixels must be premultiplied. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 74 | ## |
| 75 | #Const kUnpremul_SkAlphaType 3 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 76 | Pixel color component values are independent of alpha value. |
| 77 | Images generated from encoded data like PNG do not premultiply pixel color |
| 78 | components. kUnpremul_SkAlphaType is supported for Image pixels, but not for |
| 79 | Surface pixels. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 80 | ## |
| 81 | |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 82 | #NoExample |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 83 | ## |
| 84 | |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 85 | #SeeAlso SkColorType SkColorSpace |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 86 | |
| 87 | #Enum SkAlphaType ## |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 88 | |
| 89 | #Subtopic Opaque |
| 90 | |
| 91 | Use Opaque as a hint to optimize drawing when alpha component |
| 92 | of all pixel is set to its maximum value of 1.0; all alpha component bits are set. |
| 93 | If Image_Info is set to Opaque but all alpha values are not 1.0, results are |
| 94 | undefined. |
| 95 | |
| 96 | #Example |
| 97 | #Height 64 |
| 98 | #Description |
| 99 | SkPreMultiplyARGB parameter a is set to 255, its maximum value, and is interpreted |
| 100 | as Color_Alpha of 1.0. kOpaque_SkAlphaType may be set to improve performance. |
| 101 | If SkPreMultiplyARGB parameter a is set to a value smaller than 255, |
| 102 | kPremul_SkAlphaType must be used instead to avoid undefined results. |
| 103 | The four displayed values are the original component values, though not necessarily |
| 104 | in the same order. |
| 105 | ## |
| 106 | SkPMColor color = SkPreMultiplyARGB(255, 50, 100, 150); |
| 107 | SkString s; |
| 108 | s.printf("%u %u %u %u", SkColorGetA(color), SkColorGetR(color), |
| 109 | SkColorGetG(color), SkColorGetB(color)); |
| 110 | SkPaint paint; |
| 111 | paint.setAntiAlias(true); |
| 112 | canvas->drawString(s, 10, 62, paint); |
| 113 | canvas->scale(50, 50); |
| 114 | SkBitmap bitmap; |
| 115 | SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kOpaque_SkAlphaType); |
| 116 | if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) { |
| 117 | canvas->drawBitmap(bitmap, 0, 0); |
| 118 | } |
| 119 | ## |
| 120 | |
| 121 | #Subtopic Opaque ## |
| 122 | |
| 123 | #Subtopic Premul |
| 124 | |
| 125 | Use Premul when stored color components are the original color multiplied by the |
| 126 | alpha component. The alpha component range of 0.0 to 1.0 is achieved by dividing |
| 127 | the integer bit value by the maximum bit value. |
| 128 | |
| 129 | #Formula |
| 130 | stored color = original color * alpha / max alpha |
| 131 | ## |
| 132 | |
| 133 | The color component must be equal to or smaller than the alpha component, |
| 134 | or the results are undefined. |
| 135 | |
| 136 | #Example |
| 137 | #Description |
| 138 | SkPreMultiplyARGB parameter a is set to 150, less than its maximum value, and is |
| 139 | interpreted as Color_Alpha of about 0.6. kPremul_SkAlphaType must be set, since |
| 140 | SkPreMultiplyARGB parameter a is set to a value smaller than 255, |
| 141 | to avoid undefined results. |
| 142 | The four displayed values reflect that the alpha component has been multiplied |
| 143 | by the original color. |
| 144 | ## |
| 145 | #Height 64 |
| 146 | SkPMColor color = SkPreMultiplyARGB(150, 50, 100, 150); |
| 147 | SkString s; |
| 148 | s.printf("%u %u %u %u", SkColorGetA(color), SkColorGetR(color), |
| 149 | SkColorGetG(color), SkColorGetB(color)); |
| 150 | SkPaint paint; |
| 151 | paint.setAntiAlias(true); |
| 152 | canvas->drawString(s, 10, 62, paint); |
| 153 | canvas->scale(50, 50); |
| 154 | SkBitmap bitmap; |
| 155 | SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kPremul_SkAlphaType); |
| 156 | if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) { |
| 157 | canvas->drawBitmap(bitmap, 0, 0); |
| 158 | } |
| 159 | ## |
| 160 | |
| 161 | #Subtopic Premul ## |
| 162 | |
| 163 | #Subtopic Unpremul |
| 164 | |
| 165 | Use Unpremul if stored color components are not divided by the alpha component. |
| 166 | Some drawing destinations may not support Unpremul. |
| 167 | |
| 168 | #Bug 7079 |
| 169 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 170 | #Height 64 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 171 | #Description |
| 172 | SkColorSetARGB parameter a is set to 150, less than its maximum value, and is |
| 173 | interpreted as Color_Alpha of about 0.6. color is not premultiplied; |
| 174 | color components may have values greater than color alpha. |
| 175 | The four displayed values are the original component values, though not necessarily |
| 176 | in the same order. |
| 177 | ## |
| 178 | SkColor color = SkColorSetARGB(150, 50, 100, 255); |
| 179 | SkString s; |
| 180 | s.printf("%u %u %u %u", SkColorGetA(color), SkColorGetR(color), |
| 181 | SkColorGetG(color), SkColorGetB(color)); |
| 182 | SkPaint paint; |
| 183 | paint.setAntiAlias(true); |
| 184 | canvas->drawString(s, 10, 62, paint); |
| 185 | canvas->scale(50, 50); |
| 186 | SkBitmap bitmap; |
| 187 | SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kUnpremul_SkAlphaType); |
| 188 | if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) { |
| 189 | canvas->drawBitmap(bitmap, 0, 0); |
| 190 | } |
| 191 | ## |
| 192 | |
| 193 | #Subtopic Unpremul ## |
| 194 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 195 | #Method static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) |
| 196 | #In Property |
| 197 | #Line # returns if Alpha_Type equals kOpaque_SkAlphaType ## |
| 198 | |
| 199 | #Param at one of: #list_of_alpha_types# |
| 200 | ## |
| 201 | #Return true if at equals kOpaque_SkAlphaType ## |
| 202 | #NoExample |
| 203 | ## |
| 204 | ## |
| 205 | |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 206 | #Subtopic Alpha_Type ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 207 | |
| 208 | # ------------------------------------------------------------------------------ |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 209 | #Subtopic Color_Type |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 210 | #Line # encoding for pixel color ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 211 | #Alias Color_Type |
| 212 | #Alias Color_Types |
Cary Clark | 2a8c48b | 2018-02-15 17:31:24 -0500 | [diff] [blame] | 213 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 214 | #PhraseDef list_of_color_types |
| 215 | kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType, |
| 216 | kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType, |
| 217 | kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType, |
| 218 | kGray_8_SkColorType, kRGBA_F16_SkColorType |
| 219 | ## |
| 220 | |
Cary Clark | 2a8c48b | 2018-02-15 17:31:24 -0500 | [diff] [blame] | 221 | #Subtopic Native |
| 222 | #Alias Native_Color_Type |
| 223 | #Substitute native SkColorType |
| 224 | ## |
| 225 | |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 226 | #Enum SkColorType |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 227 | #Line # encoding for pixel color ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 228 | |
| 229 | #Code |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 230 | ###$ |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 231 | enum SkColorType { |
| 232 | kUnknown_SkColorType, |
| 233 | kAlpha_8_SkColorType, |
| 234 | kRGB_565_SkColorType, |
| 235 | kARGB_4444_SkColorType, |
| 236 | kRGBA_8888_SkColorType, |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 237 | kRGB_888x_SkColorType, |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 238 | kBGRA_8888_SkColorType, |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 239 | kRGBA_1010102_SkColorType, |
| 240 | kRGB_101010x_SkColorType, |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 241 | kGray_8_SkColorType, |
| 242 | kRGBA_F16_SkColorType, |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 243 | |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 244 | kLastEnum_SkColorType = kRGBA_F16_SkColorType, |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 245 | |
| 246 | #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 247 | kN32_SkColorType = kBGRA_8888_SkColorType, |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 248 | #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 249 | kN32_SkColorType = kRGBA_8888_SkColorType, |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 250 | #else |
| 251 | #error "SK_*32_SHIFT values must correspond to BGRA or RGBA byte order" |
| 252 | #endif |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 253 | }; |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 254 | $$$# |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 255 | ## |
| 256 | |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 257 | Describes how pixel bits encode color. A pixel may be an alpha mask, a |
| 258 | gray level, Color_RGB, or Color_ARGB. |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 259 | |
| 260 | kN32_SkColorType selects the native 32-bit Color_ARGB format. On Little_Endian |
| 261 | processors, pixels containing 8-bit Color_ARGB components pack into 32-bit |
| 262 | kBGRA_8888_SkColorType. On Big_Endian processors, pixels pack into 32-bit |
| 263 | kRGBA_8888_SkColorType. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 264 | |
| 265 | #Const kUnknown_SkColorType 0 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 266 | |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 267 | ## |
| 268 | #Const kAlpha_8_SkColorType 1 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 269 | Encodes Color_Alpha as Alpha_8 pixel in an 8-bit byte. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 270 | ## |
| 271 | #Const kRGB_565_SkColorType 2 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 272 | Encodes Color_RGB as BGR_565 pixel in a 16-bit word. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 273 | ## |
| 274 | #Const kARGB_4444_SkColorType 3 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 275 | Encodes Color_ARGB as ABGR_4444 pixel in a 16-bit word. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 276 | ## |
| 277 | #Const kRGBA_8888_SkColorType 4 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 278 | Encodes Color_ARGB as RGBA_8888 pixel in a 32-bit word. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 279 | ## |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 280 | #Const kRGB_888x_SkColorType 5 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 281 | Encodes Color_RGB as RGB_888x pixel in a 32-bit word. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 282 | ## |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 283 | #Const kBGRA_8888_SkColorType 6 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 284 | Encodes Color_ARGB as BGRA_8888 pixel in a 32-bit word. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 285 | ## |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 286 | #Const kRGBA_1010102_SkColorType 7 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 287 | Encodes Color_ARGB as RGBA_1010102 pixel in a 32-bit word. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 288 | ## |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 289 | #Const kRGB_101010x_SkColorType 8 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 290 | Encodes Color_RGB as RGB_101010x pixel in a 32-bit word. |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 291 | ## |
| 292 | #Const kGray_8_SkColorType 9 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 293 | Encodes Color_Gray as Gray_8 in an 8-bit byte. |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 294 | ## |
| 295 | #Const kRGBA_F16_SkColorType 10 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 296 | Encodes Color_ARGB as RGBA_F16 in a 64-bit word. |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 297 | ## |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 298 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 299 | #ToDo can be 4 or 6; how to document? ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 300 | #Const kN32_SkColorType 4 |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 301 | Encodes Color_ARGB as either RGBA_8888 or BGRA_8888, whichever |
| 302 | is native to the platform. |
| 303 | ## |
| 304 | |
| 305 | #NoExample |
| 306 | ## |
| 307 | |
| 308 | #SeeAlso SkAlphaType SkColorSpace |
| 309 | |
| 310 | #Enum SkColorType ## |
| 311 | |
| 312 | #Subtopic Alpha_8 |
| 313 | |
| 314 | Alpha_8 is an 8-bit byte pixel encoding that represents transparency. A value of zero is |
| 315 | completely transparent; a value of 255 is completely opaque. Bitmap with Alpha_8 |
| 316 | pixels does not visibly draw, because its pixels have no color information. |
| 317 | The paired SkAlphaType is ignored. |
| 318 | |
| 319 | #Example |
| 320 | #Description |
| 321 | Alpha_8 pixels can modify another draw. orangePaint fills the bounds of bitmap, |
| 322 | with its transparency set to alpha8 pixel value. |
| 323 | ## |
| 324 | #Height 64 |
| 325 | canvas->scale(16, 16); |
| 326 | SkBitmap bitmap; |
| 327 | SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kAlpha_8_SkColorType, kOpaque_SkAlphaType); |
| 328 | bitmap.allocPixels(imageInfo); |
| 329 | SkCanvas offscreen(bitmap); |
| 330 | offscreen.clear(SK_ColorGREEN); |
| 331 | SkPaint orangePaint; |
| 332 | orangePaint.setARGB(0xFF, 0xFF, 0xA5, 0x00); |
| 333 | canvas->drawBitmap(bitmap, 0, 0, &orangePaint); |
| 334 | uint8_t alpha8[] = { 0xFF, 0xBB, 0x77, 0x33 }; |
| 335 | SkPixmap alphaPixmap(imageInfo, &alpha8, imageInfo.minRowBytes()); |
| 336 | if (bitmap.writePixels(alphaPixmap, 0, 0)) { |
| 337 | canvas->drawBitmap(bitmap, 2, 2, &orangePaint); |
| 338 | } |
| 339 | ## |
| 340 | ## |
| 341 | |
| 342 | #Subtopic BGR_565 |
| 343 | |
| 344 | BGR_565 is a 16-bit word pixel encoding that contains five bits of blue, |
| 345 | six bits of green, and five bits of red. BGR_565 is fully opaque as if its |
| 346 | Color_Alpha was set to one, and should always be paired with kOpaque_SkAlphaType. |
| 347 | |
| 348 | #Illustration |
| 349 | |
| 350 | #Example |
| 351 | #Height 96 |
| 352 | canvas->scale(16, 16); |
| 353 | SkBitmap bitmap; |
| 354 | SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_565_SkColorType, kOpaque_SkAlphaType); |
| 355 | bitmap.allocPixels(imageInfo); |
| 356 | SkCanvas offscreen(bitmap); |
| 357 | offscreen.clear(SK_ColorGREEN); |
| 358 | canvas->drawBitmap(bitmap, 0, 0); |
| 359 | auto pack565 = [](unsigned r, unsigned g, unsigned b) -> uint16_t { |
| 360 | return (b << 0) | (g << 5) | (r << 11); |
| 361 | }; |
| 362 | uint16_t red565[] = { pack565(0x1F, 0x00, 0x00), pack565(0x17, 0x00, 0x00), |
| 363 | pack565(0x0F, 0x00, 0x00), pack565(0x07, 0x00, 0x00) }; |
| 364 | uint16_t blue565[] = { pack565(0x00, 0x00, 0x1F), pack565(0x00, 0x00, 0x17), |
| 365 | pack565(0x00, 0x00, 0x0F), pack565(0x00, 0x00, 0x07) }; |
| 366 | SkPixmap redPixmap(imageInfo, &red565, imageInfo.minRowBytes()); |
| 367 | if (bitmap.writePixels(redPixmap, 0, 0)) { |
| 368 | canvas->drawBitmap(bitmap, 2, 2); |
| 369 | } |
| 370 | SkPixmap bluePixmap(imageInfo, &blue565, imageInfo.minRowBytes()); |
| 371 | if (bitmap.writePixels(bluePixmap, 0, 0)) { |
| 372 | canvas->drawBitmap(bitmap, 4, 4); |
| 373 | } |
| 374 | ## |
| 375 | ## |
| 376 | |
| 377 | #Subtopic ABGR_4444 |
| 378 | |
| 379 | ABGR_4444 is a 16-bit word pixel encoding that contains four bits of alpha, |
| 380 | four bits of blue, four bits of green, and four bits of red. |
| 381 | |
| 382 | #Illustration |
| 383 | |
| 384 | If paired with kPremul_SkAlphaType: blue, green, and red components are |
| 385 | premultiplied by the alpha value. If blue, green, or red is greater than alpha, |
| 386 | the drawn result is undefined. |
| 387 | |
| 388 | If paired with kUnpremul_SkAlphaType: alpha, blue, green, and red components |
| 389 | may have any value. There may be a performance penalty with unpremultipled |
| 390 | pixels. |
| 391 | |
| 392 | If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; |
| 393 | blue, green, and red components are fully opaque. If any alpha component is |
| 394 | less than 15, the drawn result is undefined. |
| 395 | |
| 396 | #Bug 7648 |
| 397 | |
| 398 | #Example |
| 399 | #Height 96 |
| 400 | canvas->scale(16, 16); |
| 401 | SkBitmap bitmap; |
| 402 | SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kARGB_4444_SkColorType, kPremul_SkAlphaType); |
| 403 | bitmap.allocPixels(imageInfo); |
| 404 | SkCanvas offscreen(bitmap); |
| 405 | offscreen.clear(SK_ColorGREEN); |
| 406 | canvas->drawBitmap(bitmap, 0, 0); |
| 407 | auto pack4444 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint16_t { |
| 408 | return (a << 0) | (b << 4) | (g << 8) | (r << 12); |
| 409 | }; |
| 410 | uint16_t red4444[] = { pack4444(0xF, 0xF, 0x0, 0x0), pack4444(0xF, 0xb, 0x0, 0x0), |
| 411 | pack4444(0xF, 0x7, 0x0, 0x0), pack4444(0xF, 0x3, 0x0, 0x0) }; |
| 412 | uint16_t blue4444[] = { pack4444(0xF, 0x0, 0x0, 0xF), pack4444(0xF, 0x0, 0x0, 0xb), |
| 413 | pack4444(0xF, 0x0, 0x0, 0x7), pack4444(0xF, 0x0, 0x0, 0x3) }; |
| 414 | SkPixmap redPixmap(imageInfo, &red4444, imageInfo.minRowBytes()); |
| 415 | if (bitmap.writePixels(redPixmap, 0, 0)) { |
| 416 | canvas->drawBitmap(bitmap, 2, 2); |
| 417 | } |
| 418 | SkPixmap bluePixmap(imageInfo, &blue4444, imageInfo.minRowBytes()); |
| 419 | if (bitmap.writePixels(bluePixmap, 0, 0)) { |
| 420 | canvas->drawBitmap(bitmap, 4, 4); |
| 421 | } |
| 422 | ## |
| 423 | ## |
| 424 | |
| 425 | #Subtopic RGBA_8888 |
| 426 | |
| 427 | RGBA_8888 is a 32-bit word pixel encoding that contains eight bits of red, |
| 428 | eight bits of green, eight bits of blue, and eight bits of alpha. |
| 429 | |
| 430 | #Illustration |
| 431 | |
| 432 | If paired with kPremul_SkAlphaType: red, green, and blue components are |
| 433 | premultiplied by the alpha value. If red, green, or blue is greater than alpha, |
| 434 | the drawn result is undefined. |
| 435 | |
| 436 | If paired with kUnpremul_SkAlphaType: alpha, red, green, and blue components |
| 437 | may have any value. There may be a performance penalty with unpremultipled |
| 438 | pixels. |
| 439 | |
| 440 | If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; |
| 441 | red, green, and blue components are fully opaque. If any alpha component is |
| 442 | less than 255, the drawn result is undefined. |
| 443 | |
| 444 | On Big_Endian platforms, RGBA_8888 is the native Color_Type, and will have |
| 445 | the best performance. Use kN32_SkColorType to choose the best Color_Type for |
| 446 | the platform at compile time. |
| 447 | |
| 448 | #Example |
| 449 | #Height 96 |
| 450 | canvas->scale(16, 16); |
| 451 | SkBitmap bitmap; |
| 452 | SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_8888_SkColorType, kPremul_SkAlphaType); |
| 453 | bitmap.allocPixels(imageInfo); |
| 454 | SkCanvas offscreen(bitmap); |
| 455 | offscreen.clear(SK_ColorGREEN); |
| 456 | canvas->drawBitmap(bitmap, 0, 0); |
| 457 | auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t { |
| 458 | return (r << 0) | (g << 8) | (b << 16) | (a << 24); |
| 459 | }; |
| 460 | uint32_t red8888[] = { pack8888(0xFF, 0xFF, 0x0, 0x0), pack8888(0xFF, 0xbb, 0x0, 0x0), |
| 461 | pack8888(0xFF, 0x77, 0x0, 0x0), pack8888(0xFF, 0x33, 0x0, 0x0) }; |
| 462 | uint32_t blue8888[] = { pack8888(0xFF, 0x0, 0x0, 0x0FF), pack8888(0xFF, 0x0, 0x0, 0x0bb), |
| 463 | pack8888(0xFF, 0x0, 0x0, 0x077), pack8888(0xFF, 0x0, 0x0, 0x033) }; |
| 464 | SkPixmap redPixmap(imageInfo, &red8888, imageInfo.minRowBytes()); |
| 465 | if (bitmap.writePixels(redPixmap, 0, 0)) { |
| 466 | canvas->drawBitmap(bitmap, 2, 2); |
| 467 | } |
| 468 | SkPixmap bluePixmap(imageInfo, &blue8888, imageInfo.minRowBytes()); |
| 469 | if (bitmap.writePixels(bluePixmap, 0, 0)) { |
| 470 | canvas->drawBitmap(bitmap, 4, 4); |
| 471 | } |
| 472 | ## |
| 473 | ## |
| 474 | |
| 475 | #Subtopic RGB_888x |
| 476 | |
| 477 | RGB_888x is a 32-bit word pixel encoding that contains eight bits of red, |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 478 | eight bits of green, eight bits of blue, and eight unused bits. RGB_888x is fully |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 479 | opaque as if its Color_Alpha was set to one, and should always be paired with |
| 480 | kOpaque_SkAlphaType. |
| 481 | |
| 482 | #Illustration |
| 483 | |
| 484 | #Example |
| 485 | #Bug 7645 |
| 486 | #Height 96 |
| 487 | #Platform cpu |
| 488 | canvas->scale(16, 16); |
| 489 | SkBitmap bitmap; |
| 490 | SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_888x_SkColorType, kOpaque_SkAlphaType); |
| 491 | bitmap.allocPixels(imageInfo); |
| 492 | SkCanvas offscreen(bitmap); |
| 493 | offscreen.clear(SK_ColorGREEN); |
| 494 | canvas->drawBitmap(bitmap, 0, 0); |
| 495 | auto pack888 = [](unsigned r, unsigned g, unsigned b) -> uint32_t { |
| 496 | return (r << 0) | (g << 8) | (b << 16); |
| 497 | }; |
| 498 | uint32_t red888[] = { pack888(0xFF, 0x00, 0x00), pack888(0xbb, 0x00, 0x00), |
| 499 | pack888(0x77, 0x00, 0x00), pack888(0x33, 0x00, 0x00) }; |
| 500 | uint32_t blue888[] = { pack888(0x00, 0x00, 0xFF), pack888(0x00, 0x00, 0xbb), |
| 501 | pack888(0x00, 0x00, 0x77), pack888(0x00, 0x00, 0x33) }; |
| 502 | if (bitmap.installPixels(imageInfo, (void*) red888, imageInfo.minRowBytes())) { |
| 503 | canvas->drawBitmap(bitmap, 2, 2); |
| 504 | } |
| 505 | if (bitmap.installPixels(imageInfo, (void*) blue888, imageInfo.minRowBytes())) { |
| 506 | canvas->drawBitmap(bitmap, 4, 4); |
| 507 | } |
| 508 | ## |
| 509 | ## |
| 510 | |
| 511 | #Subtopic BGRA_8888 |
| 512 | |
| 513 | BGRA_8888 is a 32-bit word pixel encoding that contains eight bits of blue, |
| 514 | eight bits of green, eight bits of red, and eight bits of alpha. |
| 515 | |
| 516 | #Illustration |
| 517 | |
| 518 | If paired with kPremul_SkAlphaType: blue, green, and red components are |
| 519 | premultiplied by the alpha value. If blue, green, or red is greater than alpha, |
| 520 | the drawn result is undefined. |
| 521 | |
| 522 | If paired with kUnpremul_SkAlphaType: blue, green, red, and alpha components |
| 523 | may have any value. There may be a performance penalty with unpremultipled |
| 524 | pixels. |
| 525 | |
| 526 | If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; |
| 527 | blue, green, and red components are fully opaque. If any alpha component is |
| 528 | less than 255, the drawn result is undefined. |
| 529 | |
| 530 | On Little_Endian platforms, BGRA_8888 is the native Color_Type, and will have |
| 531 | the best performance. Use kN32_SkColorType to choose the best Color_Type for |
| 532 | the platform at compile time. |
| 533 | |
| 534 | #Example |
| 535 | #Height 96 |
| 536 | canvas->scale(16, 16); |
| 537 | SkBitmap bitmap; |
| 538 | SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kBGRA_8888_SkColorType, kPremul_SkAlphaType); |
| 539 | bitmap.allocPixels(imageInfo); |
| 540 | SkCanvas offscreen(bitmap); |
| 541 | offscreen.clear(SK_ColorGREEN); |
| 542 | canvas->drawBitmap(bitmap, 0, 0); |
| 543 | auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t { |
| 544 | return (b << 0) | (g << 8) | (r << 16) | (a << 24); |
| 545 | }; |
| 546 | uint32_t red8888[] = { pack8888(0xFF, 0xFF, 0x0, 0x0), pack8888(0xFF, 0xbb, 0x0, 0x0), |
| 547 | pack8888(0xFF, 0x99, 0x0, 0x0), pack8888(0xFF, 0x55, 0x0, 0x0) }; |
| 548 | uint32_t blue8888[] = { pack8888(0xFF, 0x0, 0x0, 0x0FF), pack8888(0xFF, 0x0, 0x0, 0x0bb), |
| 549 | pack8888(0xFF, 0x0, 0x0, 0x099), pack8888(0xFF, 0x0, 0x0, 0x055) }; |
| 550 | SkPixmap redPixmap(imageInfo, &red8888, imageInfo.minRowBytes()); |
| 551 | if (bitmap.writePixels(redPixmap, 0, 0)) { |
| 552 | canvas->drawBitmap(bitmap, 2, 2); |
| 553 | } |
| 554 | SkPixmap bluePixmap(imageInfo, &blue8888, imageInfo.minRowBytes()); |
| 555 | if (bitmap.writePixels(bluePixmap, 0, 0)) { |
| 556 | canvas->drawBitmap(bitmap, 4, 4); |
| 557 | } |
| 558 | ## |
| 559 | ## |
| 560 | |
| 561 | #Subtopic RGBA_1010102 |
| 562 | |
| 563 | RGBA_1010102 is a 32-bit word pixel encoding that contains ten bits of red, |
| 564 | ten bits of green, ten bits of blue, and two bits of alpha. Possible alpha |
| 565 | values are zero: fully transparent; one: 33% opaque; two: 67% opaque; |
| 566 | three: fully opaque. |
| 567 | |
| 568 | #Illustration |
| 569 | |
| 570 | If paired with kPremul_SkAlphaType: red, green, and blue components are |
| 571 | premultiplied by the alpha value. If red, green, or blue is greater than the |
| 572 | alpha replicated to ten bits, the drawn result is undefined. |
| 573 | |
| 574 | If paired with kUnpremul_SkAlphaType: alpha, red, green, and blue components |
| 575 | may have any value. There may be a performance penalty with unpremultipled |
| 576 | pixels. |
| 577 | |
| 578 | If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; |
| 579 | red, green, and blue components are fully opaque. If any alpha component is |
| 580 | less than 3, the drawn result is undefined. |
| 581 | |
| 582 | #Example |
| 583 | #Bug 7645 |
| 584 | #Height 96 |
| 585 | #Platform cpu |
| 586 | canvas->scale(16, 16); |
| 587 | SkBitmap bitmap; |
| 588 | SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_1010102_SkColorType, kOpaque_SkAlphaType); |
| 589 | bitmap.allocPixels(imageInfo); |
| 590 | SkCanvas offscreen(bitmap); |
| 591 | offscreen.clear(SK_ColorGREEN); |
| 592 | canvas->drawBitmap(bitmap, 0, 0); |
| 593 | auto pack1010102 = [](unsigned r, unsigned g, unsigned b, unsigned a) -> uint32_t { |
| 594 | return (r << 0) | (g << 10) | (b << 20) | (a << 30); |
| 595 | }; |
| 596 | uint32_t redBits[] = { pack1010102(0x3FF, 0x000, 0x000, 0x3), |
| 597 | pack1010102(0x2ff, 0x000, 0x000, 0x3), |
| 598 | pack1010102(0x1ff, 0x000, 0x000, 0x3), |
| 599 | pack1010102(0x0ff, 0x000, 0x000, 0x3) }; |
| 600 | uint32_t blueBits[] = { pack1010102(0x000, 0x000, 0x3FF, 0x3), |
| 601 | pack1010102(0x000, 0x000, 0x2ff, 0x3), |
| 602 | pack1010102(0x000, 0x000, 0x1ff, 0x3), |
| 603 | pack1010102(0x000, 0x000, 0x0ff, 0x3) }; |
| 604 | if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) { |
| 605 | canvas->drawBitmap(bitmap, 2, 2); |
| 606 | } |
| 607 | SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes()); |
| 608 | if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) { |
| 609 | canvas->drawBitmap(bitmap, 4, 4); |
| 610 | } |
| 611 | ## |
| 612 | ## |
| 613 | |
| 614 | #Subtopic RGB_101010x |
| 615 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 616 | RGB_101010x is a 32-bit word pixel encoding that contains ten bits of red, |
| 617 | ten bits of green, ten bits of blue, and two unused bits. RGB_101010x is fully |
| 618 | opaque as if its Color_Alpha was set to one, and should always be paired with |
| 619 | kOpaque_SkAlphaType. |
| 620 | |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 621 | #Illustration |
| 622 | |
| 623 | #Example |
| 624 | #Bug 7645 |
| 625 | #Height 96 |
| 626 | #Platform cpu |
| 627 | canvas->scale(16, 16); |
| 628 | SkBitmap bitmap; |
| 629 | SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_101010x_SkColorType, kOpaque_SkAlphaType); |
| 630 | bitmap.allocPixels(imageInfo); |
| 631 | SkCanvas offscreen(bitmap); |
| 632 | offscreen.clear(SK_ColorGREEN); |
| 633 | canvas->drawBitmap(bitmap, 0, 0); |
| 634 | auto pack101010x = [](unsigned r, unsigned g, unsigned b) -> uint32_t { |
| 635 | return (r << 0) | (g << 10) | (b << 20); |
| 636 | }; |
| 637 | uint32_t redBits[] = { pack101010x(0x3FF, 0x000, 0x000), pack101010x(0x2ff, 0x000, 0x000), |
| 638 | pack101010x(0x1ff, 0x000, 0x000), pack101010x(0x0ff, 0x000, 0x000) }; |
| 639 | uint32_t blueBits[] = { pack101010x(0x000, 0x000, 0x3FF), pack101010x(0x000, 0x000, 0x2ff), |
| 640 | pack101010x(0x000, 0x000, 0x1ff), pack101010x(0x000, 0x000, 0x0ff) }; |
| 641 | if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) { |
| 642 | canvas->drawBitmap(bitmap, 2, 2); |
| 643 | } |
| 644 | SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes()); |
| 645 | if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) { |
| 646 | canvas->drawBitmap(bitmap, 4, 4); |
| 647 | } |
| 648 | ## |
| 649 | ## |
| 650 | |
| 651 | #Subtopic Gray_8 |
| 652 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 653 | Gray_8 is an 8-bit byte pixel encoding that represents equal values for red, |
| 654 | blue, and green, reprsenting colors from black to white. Gray_8 is fully |
| 655 | opaque as if its Color_Alpha was set to one, and should always be paired with |
| 656 | kOpaque_SkAlphaType. |
| 657 | |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 658 | #Example |
| 659 | #Height 64 |
| 660 | canvas->scale(16, 16); |
| 661 | SkBitmap bitmap; |
| 662 | SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kGray_8_SkColorType, kOpaque_SkAlphaType); |
| 663 | bitmap.allocPixels(imageInfo); |
| 664 | SkCanvas offscreen(bitmap); |
| 665 | offscreen.clear(SK_ColorGREEN); |
| 666 | canvas->drawBitmap(bitmap, 0, 0); |
| 667 | uint8_t gray8[] = { 0xFF, 0xBB, 0x77, 0x33 }; |
| 668 | SkPixmap grayPixmap(imageInfo, &gray8, imageInfo.minRowBytes()); |
| 669 | if (bitmap.writePixels(grayPixmap, 0, 0)) { |
| 670 | canvas->drawBitmap(bitmap, 2, 2); |
| 671 | } |
| 672 | ## |
| 673 | ## |
| 674 | |
| 675 | #Subtopic RGBA_F16 |
| 676 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 677 | RGBA_F16 is a 64-bit word pixel encoding that contains sixteen bits of blue, |
| 678 | sixteen bits of green, sixteen bits of red, and sixteen bits of alpha. |
| 679 | |
| 680 | Each component encodes a floating point value using |
| 681 | #A Half floats # https://www.khronos.org/opengl/wiki/Small_Float_Formats ## |
| 682 | . Meaningful colors are represented by the range 0.0 to 1.0, although smaller |
| 683 | and larger values may be useful when used in combination with Transfer_Mode. |
| 684 | |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 685 | #Illustration |
| 686 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 687 | If paired with kPremul_SkAlphaType: blue, green, and red components are |
| 688 | premultiplied by the alpha value. If blue, green, or red is greater than alpha, |
| 689 | the drawn result is undefined. |
| 690 | |
| 691 | If paired with kUnpremul_SkAlphaType: blue, green, red, and alpha components |
| 692 | may have any value. There may be a performance penalty with unpremultipled |
| 693 | pixels. |
| 694 | |
| 695 | If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; |
| 696 | blue, green, and red components are fully opaque. If any alpha component is |
| 697 | less than 255, the drawn result is undefined. |
| 698 | |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 699 | #ToDo |
| 700 | FloatToHalf should be replaced with SkFloatToHalf if/when that's made public |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 701 | ## |
| 702 | |
| 703 | #Example |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 704 | #Height 96 |
| 705 | #Function |
| 706 | union FloatUIntUnion { |
| 707 | uint32_t fUInt; |
| 708 | float fFloat; |
| 709 | }; |
| 710 | |
| 711 | uint16_t FloatToHalf(float f) { |
| 712 | static const FloatUIntUnion magic = { 15 << 23 }; |
| 713 | static const uint32_t round_mask = ~0xfffu; |
| 714 | FloatUIntUnion floatUnion; |
| 715 | floatUnion.fFloat = f; |
| 716 | uint32_t sign = floatUnion.fUInt & 0x80000000u; |
| 717 | floatUnion.fUInt ^= sign; |
| 718 | floatUnion.fUInt &= round_mask; |
| 719 | floatUnion.fFloat *= magic.fFloat; |
| 720 | floatUnion.fUInt -= round_mask; |
| 721 | return (floatUnion.fUInt >> 13) | (sign >> 16); |
| 722 | } |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 723 | ## |
| 724 | |
Cary Clark | f895a42 | 2018-02-27 09:54:21 -0500 | [diff] [blame] | 725 | void draw(SkCanvas* canvas) { |
| 726 | canvas->scale(16, 16); |
| 727 | SkBitmap bitmap; |
| 728 | SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_F16_SkColorType, kPremul_SkAlphaType); |
| 729 | bitmap.allocPixels(imageInfo); |
| 730 | SkCanvas offscreen(bitmap); |
| 731 | offscreen.clear(SK_ColorGREEN); |
| 732 | canvas->drawBitmap(bitmap, 0, 0); |
| 733 | auto H = [](float c) -> uint16_t { |
| 734 | return FloatToHalf(c); |
| 735 | }; |
| 736 | // R G B A |
| 737 | uint16_t red_f16[][4] = { { H(1.0f), H(0.0f), H(0.0f), H(1.0f) }, |
| 738 | { H(.75f), H(0.0f), H(0.0f), H(1.0f) }, |
| 739 | { H(.50f), H(0.0f), H(0.0f), H(1.0f) }, |
| 740 | { H(.25f), H(0.0f), H(0.0f), H(1.0f) } }; |
| 741 | uint16_t blue_f16[][4] = { { H(0.0f), H(0.0f), H(1.0f), H(1.0f) }, |
| 742 | { H(0.0f), H(0.0f), H(.75f), H(1.0f) }, |
| 743 | { H(0.0f), H(0.0f), H(.50f), H(1.0f) }, |
| 744 | { H(0.0f), H(0.0f), H(.25f), H(1.0f) } }; |
| 745 | SkPixmap redPixmap(imageInfo, red_f16, imageInfo.minRowBytes()); |
| 746 | if (bitmap.writePixels(redPixmap, 0, 0)) { |
| 747 | canvas->drawBitmap(bitmap, 2, 2); |
| 748 | } |
| 749 | SkPixmap bluePixmap(imageInfo, blue_f16, imageInfo.minRowBytes()); |
| 750 | if (bitmap.writePixels(bluePixmap, 0, 0)) { |
| 751 | canvas->drawBitmap(bitmap, 4, 4); |
| 752 | } |
| 753 | } |
| 754 | ## |
| 755 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 756 | |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 757 | #Subtopic Color_Type ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 758 | |
| 759 | # ------------------------------------------------------------------------------ |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 760 | |
| 761 | #Method int SkColorTypeBytesPerPixel(SkColorType ct) |
| 762 | #In Property |
| 763 | #Line # returns Color_Type byte size ## |
| 764 | |
| 765 | Returns the number of bytes required to store a pixel, including unused padding. |
| 766 | Returns zero if ct is kUnknown_SkColorType or invalid. |
| 767 | |
| 768 | #Param ct one of: #list_of_color_types# |
| 769 | ## |
| 770 | |
| 771 | #Return bytes per pixel ## |
| 772 | |
| 773 | #Example |
| 774 | #Height 192 |
| 775 | const char* colors[] = { "Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x", |
| 776 | "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16" }; |
| 777 | SkPaint paint; |
| 778 | paint.setTypeface(SkTypeface::MakeFromName("monospace", SkFontStyle())); |
| 779 | paint.setAntiAlias(true); |
| 780 | paint.setTextSize(10); |
| 781 | int y = 15; |
| 782 | canvas->drawString(" colorType bytes", 10, y, paint); |
| 783 | for (SkColorType colorType : { #list_of_color_types# |
| 784 | } ) { |
| 785 | int result = SkColorTypeBytesPerPixel(colorType); |
| 786 | SkString string; |
| 787 | string.printf("%13s %4d", colors[(int) colorType], result); |
| 788 | canvas->drawString(string, 10, y += 14, paint); |
| 789 | } |
| 790 | ## |
| 791 | #SeeAlso SkImageInfo::bytesPerPixel |
| 792 | ## |
| 793 | |
| 794 | # ------------------------------------------------------------------------------ |
| 795 | |
| 796 | #Method bool SkColorTypeIsAlwaysOpaque(SkColorType ct) |
| 797 | #In Property |
| 798 | #Line # returns if Color_Type includes Color_Alpha ## |
| 799 | |
| 800 | Returns true if Color_Type always decodes Color_Alpha to 1.0, making the pixel |
| 801 | fully opaque. If true, Color_Type does not reserve bits to encode Color_Alpha. |
| 802 | |
| 803 | #Param ct one of: #list_of_color_types# |
| 804 | ## |
| 805 | |
| 806 | #Return true if Color_Alpha is always set to 1.0 ## |
| 807 | |
| 808 | #Example |
| 809 | #Height 192 |
| 810 | const char* colors[] = { "Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x", |
| 811 | "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16" }; |
| 812 | SkPaint paint; |
| 813 | paint.setTypeface(SkTypeface::MakeFromName("monospace", SkFontStyle())); |
| 814 | paint.setAntiAlias(true); |
| 815 | paint.setTextSize(10); |
| 816 | int y = 15; |
| 817 | canvas->drawString(" colorType bytes", 10, y, paint); |
| 818 | for (SkColorType colorType : { #list_of_color_types# |
| 819 | } ) { |
| 820 | bool result = SkColorTypeIsAlwaysOpaque(colorType); |
| 821 | SkString string; |
| 822 | string.printf("%13s %6s", colors[(int) colorType], result ? "true" : "false"); |
| 823 | canvas->drawString(string, 10, y += 14, paint); |
| 824 | } |
| 825 | ## |
| 826 | #SeeAlso SkColorTypeValidateAlphaType |
| 827 | ## |
| 828 | |
| 829 | # ------------------------------------------------------------------------------ |
| 830 | |
| 831 | #Method bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, |
| 832 | SkAlphaType* canonical = nullptr) |
| 833 | #In Property |
| 834 | #Line # returns if Alpha_Type is valid ## |
| 835 | |
| 836 | Returns true if canonical can be set to a valid Alpha_Type for colorType. If |
| 837 | there is more than one valid canonical Alpha_Type, set to alphaType, if valid. |
| 838 | If true is returned and canonical is not nullptr, store valid Alpha_Type. |
| 839 | |
| 840 | Returns false only if alphaType is kUnknown_SkAlphaType, color type is not |
| 841 | kUnknown_SkColorType, and Color_Type is not always opaque. If false is returned, |
| 842 | canonical is ignored. |
| 843 | |
| 844 | For kUnknown_SkColorType: set canonical to kUnknown_SkAlphaType and return true. |
| 845 | For kAlpha_8_SkColorType: set canonical to kPremul_SkAlphaType or |
| 846 | kOpaque_SkAlphaType and return true if alphaType is not kUnknown_SkAlphaType. |
| 847 | For kRGB_565_SkColorType, kRGB_888x_SkColorType, kRGB_101010x_SkColorType, and |
| 848 | kGray_8_SkColorType: set canonical to kOpaque_SkAlphaType and return true. |
| 849 | For kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kBGRA_8888_SkColorType, |
| 850 | kRGBA_1010102_SkColorType, and kRGBA_F16_SkColorType: set canonical to alphaType |
| 851 | and return true if alphaType is not kUnknown_SkAlphaType. |
| 852 | |
| 853 | #Param colorType one of: #list_of_color_types# |
| 854 | ## |
| 855 | #Param alphaType one of: #list_of_alpha_types# |
| 856 | ## |
| 857 | #Param canonical storage for Alpha_Type ## |
| 858 | |
| 859 | #Return true if valid Alpha_Type can be associated with colorType ## |
| 860 | |
| 861 | #Example |
| 862 | #Height 640 |
| 863 | const char* colors[] = { "Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x", |
| 864 | "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16" }; |
| 865 | const char* alphas[] = {"Unknown ", "Opaque ", "Premul ", "Unpremul"}; |
| 866 | SkAlphaType alphaTypes[] = { #list_of_alpha_types# |
| 867 | }; |
| 868 | SkPaint paint; |
| 869 | paint.setTypeface(SkTypeface::MakeFromName("monospace", SkFontStyle())); |
| 870 | paint.setAntiAlias(true); |
| 871 | paint.setTextSize(10); |
| 872 | int y = 15; |
| 873 | canvas->drawString(" colorType alphaType canonical", 10, y, paint); |
| 874 | for (SkColorType colorType : { #list_of_color_types# |
| 875 | } ) { |
| 876 | for (SkAlphaType alphaType : alphaTypes) { |
| 877 | SkAlphaType canonicalAlphaType = kUnknown_SkAlphaType; |
| 878 | bool result = SkColorTypeValidateAlphaType(colorType, alphaType, &canonicalAlphaType); |
| 879 | SkString string; |
| 880 | string.printf("%13s %10s %10s", colors[(int) colorType], alphas[(int) alphaType], |
| 881 | result ? alphas[(int) canonicalAlphaType] : "------ "); |
| 882 | canvas->drawString(string, 10, y += 14, paint); |
| 883 | } |
| 884 | } |
| 885 | ## |
| 886 | #SeeAlso SkColorTypeIsAlwaysOpaque |
| 887 | ## |
| 888 | |
| 889 | # ------------------------------------------------------------------------------ |
Cary Clark | 77295347 | 2018-02-12 09:38:08 -0500 | [diff] [blame] | 890 | #Subtopic YUV_ColorSpace |
| 891 | #Alias YUV_ColorSpace |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 892 | #Enum SkYUVColorSpace |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 893 | #Line # color range of YUV pixels ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 894 | |
| 895 | #Code |
| 896 | enum SkYUVColorSpace { |
| 897 | kJPEG_SkYUVColorSpace, |
| 898 | kRec601_SkYUVColorSpace, |
| 899 | kRec709_SkYUVColorSpace, |
| 900 | kLastEnum_SkYUVColorSpace = kRec709_SkYUVColorSpace, |
| 901 | }; |
| 902 | ## |
| 903 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 904 | Describes color range of YUV pixels. The color mapping from YUV to RGB varies |
| 905 | depending on the source. YUV pixels may be generated by JPEG images, standard |
| 906 | video streams, or high definition video streams. Each has its own mapping from |
| 907 | YUV and RGB. |
| 908 | |
| 909 | JPEG YUV values encode the full range of 0 to 255 for all three components. |
| 910 | Video YUV values range from 16 to 235 for all three components. Details of |
| 911 | encoding and conversion to RGB are described in |
| 912 | #A YCbCr color space # https://en.wikipedia.org/wiki/YCbCr ## |
| 913 | . |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 914 | |
| 915 | #Const kJPEG_SkYUVColorSpace 0 |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 916 | Describes standard JPEG color space; |
| 917 | #A CCIR 601 # https://en.wikipedia.org/wiki/Rec._601 ## |
| 918 | with full range of 0 to 255 for components. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 919 | ## |
| 920 | #Const kRec601_SkYUVColorSpace 1 |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 921 | Describes standard used by SDTV; |
| 922 | #A CCIR 601 # https://en.wikipedia.org/wiki/Rec._601 ## |
| 923 | with studio range of 16 to 235 range for components. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 924 | ## |
| 925 | #Const kRec709_SkYUVColorSpace 2 |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 926 | Describes standard used by HDTV; |
| 927 | #A Rec. 709 # http://en.wikipedia.org/wiki/Rec._709 ## |
| 928 | with studio range of 16 to 235 range for components. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 929 | ## |
| 930 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 931 | #NoExample |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 932 | ## |
| 933 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 934 | #SeeAlso SkImage::MakeFromYUVTexturesCopy SkImage::MakeFromNV12TexturesCopy |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 935 | |
| 936 | #Enum SkYUVColorSpace ## |
Cary Clark | 77295347 | 2018-02-12 09:38:08 -0500 | [diff] [blame] | 937 | #Subtopic YUV_ColorSpace ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 938 | |
| 939 | # ------------------------------------------------------------------------------ |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 940 | |
| 941 | #Struct SkImageInfo |
| 942 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 943 | Describes pixel dimensions and encoding. Bitmap, Image, PixMap, and Surface |
| 944 | can be created from Image_Info. Image_Info can be retrieved from Bitmap and |
| 945 | Pixmap, but not from Image and Surface. For example, Image and Surface |
| 946 | implementations may defer pixel depth, so may not completely specify Image_Info. |
| 947 | |
| 948 | Image_Info contains dimensions, the pixel integral width and height. It encodes |
| 949 | how pixel bits describe Color_Alpha, transparency; Color components red, blue, |
| 950 | and green; and Color_Space, the range and linearity of colors. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 951 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 952 | #Subtopic Member_Function |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 953 | #Populate |
| 954 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 955 | |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 956 | #Subtopic Related_Function |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 957 | #Populate |
| 958 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 959 | |
| 960 | # ------------------------------------------------------------------------------ |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 961 | #Subtopic Constructor |
| 962 | #Populate |
| 963 | ## |
| 964 | |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 965 | #Method SkImageInfo() |
| 966 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 967 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 968 | #Line # creates with zero dimensions, kUnknown_SkColorType, kUnknown_SkAlphaType ## |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 969 | Creates an empty Image_Info with kUnknown_SkColorType, kUnknown_SkAlphaType, |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 970 | a width and height of zero, and no Color_Space. |
| 971 | |
| 972 | #Return empty Image_Info ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 973 | |
| 974 | #Example |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 975 | #Height 32 |
| 976 | #Description |
| 977 | An empty Image_Info may be passed to SkCanvas::accessTopLayerPixels as storage |
| 978 | for the Canvas actual Image_Info. |
| 979 | ## |
| 980 | SkImageInfo imageInfo; |
| 981 | size_t rowBytes; |
| 982 | SkIPoint origin; |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 983 | (void) canvas->accessTopLayerPixels(&imageInfo, &rowBytes, &origin); |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 984 | const char* alphaType[] = { "Unknown", "Opaque", "Premul", "Unpremul" }; |
| 985 | SkString string; |
| 986 | string.printf("k%s_SkAlphaType", alphaType[(int) imageInfo.alphaType()]); |
| 987 | SkPaint paint; |
| 988 | canvas->drawString(string, 20, 20, paint); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 989 | ## |
| 990 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 991 | #SeeAlso Make MakeN32 MakeS32 MakeA8 |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 992 | |
| 993 | #Method ## |
| 994 | |
| 995 | # ------------------------------------------------------------------------------ |
| 996 | |
| 997 | #Method static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at, |
| 998 | sk_sp<SkColorSpace> cs = nullptr) |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 999 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1000 | #Line # creates Image_Info from dimensions, Color_Type, Alpha_Type, Color_Space ## |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1001 | Creates Image_Info from integral dimensions width and height, Color_Type ct, |
| 1002 | Alpha_Type at, and optionally Color_Space cs. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1003 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1004 | If Color_Space cs is nullptr and Image_Info is part of drawing source: Color_Space |
| 1005 | defaults to sRGB, mapping into Surface Color_Space. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1006 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1007 | Parameters are not validated to see if their values are legal, or that the |
| 1008 | combination is supported. |
| 1009 | |
| 1010 | #Param width pixel column count; must be zero or greater ## |
| 1011 | #Param height pixel row count; must be zero or greater ## |
| 1012 | #Param ct one of: #list_of_color_types# |
| 1013 | ## |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1014 | #Param at one of: #list_of_alpha_types# |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1015 | ## |
| 1016 | #Param cs range of colors; may be nullptr ## |
| 1017 | |
| 1018 | #Return created Image_Info ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1019 | |
| 1020 | #Example |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1021 | #Height 48 |
| 1022 | uint8_t storage[][5] = {{ 0xCA, 0xDA, 0xCA, 0xC9, 0xA3 }, |
| 1023 | { 0xAC, 0xA8, 0x89, 0xA7, 0x87 }, |
| 1024 | { 0x9B, 0xB5, 0xE5, 0x95, 0x46 }, |
| 1025 | { 0x90, 0x81, 0xC5, 0x71, 0x33 }, |
| 1026 | { 0x75, 0x55, 0x44, 0x40, 0x30 }}; |
| 1027 | SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kOpaque_SkAlphaType); |
| 1028 | SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5); |
| 1029 | SkBitmap bitmap; |
| 1030 | bitmap.installPixels(pixmap); |
| 1031 | canvas->scale(8, 8); |
| 1032 | canvas->drawBitmap(bitmap, 0, 0); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1033 | ## |
| 1034 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1035 | #SeeAlso MakeN32 MakeN32Premul MakeS32 MakeA8 |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1036 | |
| 1037 | #Method ## |
| 1038 | |
| 1039 | # ------------------------------------------------------------------------------ |
| 1040 | |
| 1041 | #Method static SkImageInfo MakeN32(int width, int height, SkAlphaType at, |
| 1042 | sk_sp<SkColorSpace> cs = nullptr) |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1043 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1044 | #Line # creates Image_Info with Native_Color_Type ## |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1045 | Creates Image_Info from integral dimensions width and height, kN32_SkColorType, |
| 1046 | Alpha_Type at, and optionally Color_Space cs. kN32_SkColorType will equal either |
| 1047 | kBGRA_8888_SkColorType or kRGBA_8888_SkColorType, whichever is optimal. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1048 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1049 | If Color_Space cs is nullptr and Image_Info is part of drawing source: Color_Space |
| 1050 | defaults to sRGB, mapping into Surface Color_Space. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1051 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1052 | Parameters are not validated to see if their values are legal, or that the |
| 1053 | combination is supported. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1054 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1055 | #Param width pixel column count; must be zero or greater ## |
| 1056 | #Param height pixel row count; must be zero or greater ## |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1057 | #Param at one of: #list_of_alpha_types# |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1058 | ## |
| 1059 | #Param cs range of colors; may be nullptr ## |
| 1060 | |
| 1061 | #Return created Image_Info ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1062 | |
| 1063 | #Example |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1064 | #Height 128 |
| 1065 | SkBitmap bitmap; |
| 1066 | bitmap.allocPixels(SkImageInfo::MakeN32(16, 16, kPremul_SkAlphaType)); |
| 1067 | SkCanvas offscreen(bitmap); |
| 1068 | offscreen.clear(SK_ColorWHITE); |
| 1069 | SkPaint paint; |
| 1070 | offscreen.drawString("g", 0, 10, paint); |
| 1071 | canvas->scale(8, 8); |
| 1072 | canvas->drawBitmap(bitmap, 0, 0); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1073 | ## |
| 1074 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1075 | #SeeAlso Make MakeN32Premul MakeS32 MakeA8 |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1076 | |
| 1077 | #Method ## |
| 1078 | |
| 1079 | # ------------------------------------------------------------------------------ |
| 1080 | |
| 1081 | #Method static SkImageInfo MakeS32(int width, int height, SkAlphaType at) |
| 1082 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1083 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1084 | #Line # creates Image_Info with Native_Color_Type, sRGB Color_Space ## |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1085 | Creates Image_Info from integral dimensions width and height, kN32_SkColorType, |
| 1086 | Alpha_Type at, with sRGB Color_Space. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1087 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1088 | Parameters are not validated to see if their values are legal, or that the |
| 1089 | combination is supported. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1090 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1091 | #Param width pixel column count; must be zero or greater ## |
| 1092 | #Param height pixel row count; must be zero or greater ## |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1093 | #Param at one of: #list_of_alpha_types# |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1094 | ## |
| 1095 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1096 | #Return created Image_Info ## |
| 1097 | |
| 1098 | #Example |
| 1099 | #Set sRGB |
| 1100 | #Height 128 |
| 1101 | #Description |
| 1102 | Top gradient is drawn to offscreen without Color_Space. It is darker than middle |
| 1103 | gradient, drawn to offscreen with sRGB Color_Space. Bottom gradient shares bits |
| 1104 | with middle, but does not specify the Color_Space in noColorSpaceBitmap. A source |
| 1105 | without Color_Space is treated as sRGB; the bottom gradient is identical to the |
| 1106 | middle gradient. |
| 1107 | ## |
| 1108 | const int width = 256; |
| 1109 | const int height = 32; |
| 1110 | SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
| 1111 | SkColor gradColors[] = { 0xFFAA0055, 0xFF11CC88 }; |
| 1112 | SkPoint gradPoints[] = { { 0, 0 }, { width, 0 } }; |
| 1113 | SkPaint gradPaint; |
| 1114 | gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, |
| 1115 | SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode)); |
| 1116 | SkBitmap bitmap; |
| 1117 | bitmap.allocPixels(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType)); |
| 1118 | SkCanvas offscreen(bitmap); |
| 1119 | offscreen.drawRect(SkRect::MakeWH(width, height), gradPaint); |
| 1120 | canvas->drawBitmap(bitmap, 0, 0); |
| 1121 | bitmap.allocPixels(SkImageInfo::MakeS32(width, height, kPremul_SkAlphaType)); |
| 1122 | SkCanvas sRGBOffscreen(bitmap); |
| 1123 | sRGBOffscreen.drawRect(SkRect::MakeWH(width, height), gradPaint); |
| 1124 | canvas->drawBitmap(bitmap, 0, 48); |
| 1125 | SkBitmap noColorSpaceBitmap; |
| 1126 | noColorSpaceBitmap.setInfo(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType)); |
| 1127 | noColorSpaceBitmap.setPixels(bitmap.getAddr(0, 0)); |
| 1128 | canvas->drawBitmap(noColorSpaceBitmap, 0, 96); |
| 1129 | ## |
| 1130 | |
| 1131 | #SeeAlso Make MakeN32 MakeN32Premul MakeA8 |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1132 | |
| 1133 | #Method ## |
| 1134 | |
| 1135 | # ------------------------------------------------------------------------------ |
| 1136 | |
| 1137 | #Method static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs = nullptr) |
| 1138 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1139 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1140 | #Line # creates Image_Info with Native_Color_Type, kPremul_SkAlphaType ## |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1141 | Creates Image_Info from integral dimensions width and height, kN32_SkColorType, |
| 1142 | kPremul_SkAlphaType, with optional Color_Space. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1143 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1144 | If Color_Space cs is nullptr and Image_Info is part of drawing source: Color_Space |
| 1145 | defaults to sRGB, mapping into Surface Color_Space. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1146 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1147 | Parameters are not validated to see if their values are legal, or that the |
| 1148 | combination is supported. |
| 1149 | |
| 1150 | #Param width pixel column count; must be zero or greater ## |
| 1151 | #Param height pixel row count; must be zero or greater ## |
| 1152 | #Param cs range of colors; may be nullptr ## |
| 1153 | |
| 1154 | #Return created Image_Info ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1155 | |
| 1156 | #Example |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 1157 | #Height 128 |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1158 | SkBitmap bitmap; |
| 1159 | bitmap.allocPixels(SkImageInfo::MakeN32Premul(18, 18)); |
| 1160 | SkCanvas offscreen(bitmap); |
| 1161 | offscreen.clear(SK_ColorWHITE); |
| 1162 | SkPaint paint; |
| 1163 | paint.setAntiAlias(true); |
| 1164 | paint.setTextSize(15); |
| 1165 | offscreen.drawString("\xF0\x9F\x98\xB8", 1, 15, paint); |
| 1166 | canvas->scale(6, 6); |
| 1167 | canvas->drawBitmap(bitmap, 0, 0); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1168 | ## |
| 1169 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1170 | #SeeAlso MakeN32 MakeS32 MakeA8 Make |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1171 | |
| 1172 | #Method ## |
| 1173 | |
| 1174 | # ------------------------------------------------------------------------------ |
| 1175 | |
| 1176 | #Method static SkImageInfo MakeN32Premul(const SkISize& size) |
| 1177 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1178 | #In Constructor |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1179 | Creates Image_Info from integral dimensions width and height, kN32_SkColorType, |
| 1180 | kPremul_SkAlphaType, with Color_Space set to nullptr. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1181 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1182 | If Image_Info is part of drawing source: Color_Space defaults to sRGB, mapping |
| 1183 | into Surface Color_Space. |
| 1184 | |
| 1185 | Parameters are not validated to see if their values are legal, or that the |
| 1186 | combination is supported. |
| 1187 | |
| 1188 | #Param size width and height, each must be zero or greater ## |
| 1189 | |
| 1190 | #Return created Image_Info ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1191 | |
| 1192 | #Example |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 1193 | #Height 128 |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1194 | SkBitmap bitmap; |
| 1195 | bitmap.allocPixels(SkImageInfo::MakeN32Premul({18, 18})); |
| 1196 | SkCanvas offscreen(bitmap); |
| 1197 | offscreen.clear(SK_ColorWHITE); |
| 1198 | SkPaint paint; |
| 1199 | paint.setAntiAlias(true); |
| 1200 | paint.setTextSize(15); |
| 1201 | offscreen.drawString("\xF0\x9F\x98\xB9", 1, 15, paint); |
| 1202 | canvas->scale(6, 6); |
| 1203 | canvas->drawBitmap(bitmap, 0, 0); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1204 | ## |
| 1205 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1206 | #SeeAlso MakeN32 MakeS32 MakeA8 Make |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1207 | |
| 1208 | #Method ## |
| 1209 | |
| 1210 | # ------------------------------------------------------------------------------ |
| 1211 | |
| 1212 | #Method static SkImageInfo MakeA8(int width, int height) |
| 1213 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1214 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1215 | #Line # creates Image_Info with kAlpha_8_SkColorType, kPremul_SkAlphaType ## |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1216 | Creates Image_Info from integral dimensions width and height, kAlpha_8_SkColorType, |
| 1217 | kPremul_SkAlphaType, with Color_Space set to nullptr. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1218 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1219 | #Param width pixel column count; must be zero or greater ## |
| 1220 | #Param height pixel row count; must be zero or greater ## |
| 1221 | |
| 1222 | #Return created Image_Info ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1223 | |
| 1224 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1225 | #Height 64 |
| 1226 | uint8_t pixels[][8] = { { 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00}, |
| 1227 | { 0x00, 0x7f, 0xff, 0x3f, 0x3f, 0x7f, 0x3f, 0x00}, |
| 1228 | { 0x3f, 0xff, 0x7f, 0x00, 0x7f, 0xff, 0x7f, 0x00}, |
| 1229 | { 0x00, 0x3f, 0x00, 0x00, 0x3f, 0x7f, 0x3f, 0x00}, |
| 1230 | { 0x3f, 0x7f, 0x7f, 0x3f, 0x00, 0x00, 0x00, 0x00}, |
| 1231 | { 0x7f, 0xff, 0xff, 0x7f, 0x00, 0x3f, 0x7f, 0x3f}, |
| 1232 | { 0x7f, 0xff, 0xff, 0x7f, 0x00, 0x7f, 0xff, 0x7f}, |
| 1233 | { 0x3f, 0x7f, 0x7f, 0x3f, 0x00, 0x3f, 0x7f, 0x3f} }; |
| 1234 | SkBitmap bitmap; |
| 1235 | bitmap.installPixels(SkImageInfo::MakeA8(8, 8), |
| 1236 | (void*) pixels, sizeof(pixels[0])); |
| 1237 | SkPaint paint; |
| 1238 | canvas->scale(4, 4); |
| 1239 | for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xFF007F00} ) { |
| 1240 | paint.setColor(color); |
| 1241 | canvas->drawBitmap(bitmap, 0, 0, &paint); |
| 1242 | canvas->translate(12, 0); |
| 1243 | } |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1244 | ## |
| 1245 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1246 | #SeeAlso MakeN32 MakeS32 Make |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1247 | |
| 1248 | #Method ## |
| 1249 | |
| 1250 | # ------------------------------------------------------------------------------ |
| 1251 | |
| 1252 | #Method static SkImageInfo MakeUnknown(int width, int height) |
| 1253 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1254 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1255 | #Line # creates Image_Info with kUnknown_SkColorType, kUnknown_SkAlphaType ## |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1256 | Creates Image_Info from integral dimensions width and height, kUnknown_SkColorType, |
| 1257 | kUnknown_SkAlphaType, with Color_Space set to nullptr. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1258 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1259 | Returned Image_Info as part of source does not draw, and as part of destination |
| 1260 | can not be drawn to. |
| 1261 | |
| 1262 | #Param width pixel column count; must be zero or greater ## |
| 1263 | #Param height pixel row count; must be zero or greater ## |
| 1264 | |
| 1265 | #Return created Image_Info ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1266 | |
| 1267 | #Example |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1268 | #Height 32 |
| 1269 | #Width 384 |
| 1270 | SkImageInfo info; // default constructor |
| 1271 | SkString string; |
| 1272 | string.printf("SkImageInfo() %c= SkImageInfo::MakeUnknown(0, 0)", |
| 1273 | info == SkImageInfo::MakeUnknown(0, 0) ? '=' : '!'); |
| 1274 | SkPaint paint; |
| 1275 | canvas->drawString(string, 0, 12, paint); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1276 | ## |
| 1277 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1278 | #SeeAlso SkImageInfo() MakeN32 MakeS32 Make |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1279 | |
| 1280 | #Method ## |
| 1281 | |
| 1282 | # ------------------------------------------------------------------------------ |
| 1283 | |
| 1284 | #Method static SkImageInfo MakeUnknown() |
| 1285 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 1286 | #In Constructor |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1287 | Creates Image_Info from integral dimensions width and height set to zero, |
| 1288 | kUnknown_SkColorType, kUnknown_SkAlphaType, with Color_Space set to nullptr. |
| 1289 | |
| 1290 | Returned Image_Info as part of source does not draw, and as part of destination |
| 1291 | can not be drawn to. |
| 1292 | |
| 1293 | #Return created Image_Info ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1294 | |
| 1295 | #Example |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1296 | #Height 32 |
| 1297 | #Width 384 |
| 1298 | SkImageInfo info; // default constructor |
| 1299 | SkString string; |
| 1300 | string.printf("SkImageInfo() %c= SkImageInfo::MakeUnknown()", |
| 1301 | info == SkImageInfo::MakeUnknown() ? '=' : '!'); |
| 1302 | SkPaint paint; |
| 1303 | canvas->drawString(string, 0, 12, paint); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1304 | ## |
| 1305 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1306 | #SeeAlso SkImageInfo() MakeN32 MakeS32 Make |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1307 | |
| 1308 | #Method ## |
| 1309 | |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1310 | |
| 1311 | # ------------------------------------------------------------------------------ |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1312 | #Subtopic Property |
| 1313 | #Populate |
| 1314 | #Line # metrics and attributes ## |
| 1315 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1316 | |
| 1317 | #Method int width() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1318 | #In Property |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1319 | #Line # returns pixel column count ## |
| 1320 | Returns pixel count in each row. |
| 1321 | |
| 1322 | #Return pixel width ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1323 | |
| 1324 | #Example |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1325 | #Image 4 |
| 1326 | #Height 96 |
| 1327 | canvas->translate(10, 10); |
| 1328 | canvas->drawBitmap(source, 0, 0); |
| 1329 | SkImageInfo imageInfo = source.info(); |
| 1330 | canvas->translate(0, imageInfo.height()); |
| 1331 | SkPaint paint; |
| 1332 | paint.setTextAlign(SkPaint::kCenter_Align); |
| 1333 | canvas->drawLine(0, 10, imageInfo.width(), 10, paint); |
| 1334 | canvas->drawString("width", imageInfo.width() / 2, 25, paint); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1335 | ## |
| 1336 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1337 | #SeeAlso height SkBitmap::width SkPixelRef::width SkImage::width SkSurface::width |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1338 | |
| 1339 | #Method ## |
| 1340 | |
| 1341 | # ------------------------------------------------------------------------------ |
| 1342 | |
| 1343 | #Method int height() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1344 | #In Property |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1345 | #Line # returns pixel row count ## |
| 1346 | Returns pixel row count. |
| 1347 | |
| 1348 | #Return pixel height ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1349 | |
| 1350 | #Example |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1351 | #Image 4 |
| 1352 | #Height 96 |
| 1353 | canvas->translate(10, 20); |
| 1354 | canvas->drawBitmap(source, 0, 0); |
| 1355 | SkImageInfo imageInfo = source.info(); |
| 1356 | SkPaint paint; |
| 1357 | paint.setTextAlign(SkPaint::kCenter_Align); |
| 1358 | paint.setVerticalText(true); |
| 1359 | canvas->drawLine(imageInfo.width() + 10, 0, imageInfo.width() + 10, imageInfo.height(), paint); |
| 1360 | canvas->drawString("height", imageInfo.width() + 25, imageInfo.height() / 2, paint); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1361 | ## |
| 1362 | |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1363 | #SeeAlso width SkBitmap::height SkPixelRef::height SkImage::height SkSurface::height |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1364 | |
| 1365 | #Method ## |
| 1366 | |
| 1367 | # ------------------------------------------------------------------------------ |
| 1368 | |
| 1369 | #Method SkColorType colorType() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1370 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1371 | #Line # returns Color_Type ## |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 1372 | Returns Color_Type, one of: #list_of_color_types#. |
| 1373 | |
| 1374 | #Return Color_Type ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1375 | |
| 1376 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1377 | const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x", |
| 1378 | "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"}; |
| 1379 | SkImageInfo info = SkImageInfo::MakeA8(16, 32); |
| 1380 | SkDebugf("color type: k" "%s" "_SkColorType\n", colors[info.colorType()]); |
| 1381 | #StdOut |
| 1382 | color type: kAlpha_8_SkColorType |
| 1383 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1384 | ## |
| 1385 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1386 | #SeeAlso alphaType SkPixmap::colorType SkBitmap::colorType |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1387 | |
| 1388 | #Method ## |
| 1389 | |
| 1390 | # ------------------------------------------------------------------------------ |
| 1391 | |
| 1392 | #Method SkAlphaType alphaType() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1393 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1394 | #Line # Returns Alpha_Type ## |
| 1395 | Returns Alpha_Type, one of: #list_of_alpha_types#. |
| 1396 | |
| 1397 | #Return Alpha_Type ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1398 | |
| 1399 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1400 | const char* alphas[] = {"Unknown", "Opaque", "Premul", "Unpremul"}; |
| 1401 | SkImageInfo info = SkImageInfo::MakeA8(16, 32); |
| 1402 | SkDebugf("alpha type: k" "%s" "_SkAlphaType\n", alphas[info.alphaType()]); |
| 1403 | #StdOut |
| 1404 | alpha type: kPremul_SkAlphaType |
| 1405 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1406 | ## |
| 1407 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1408 | #SeeAlso colorType SkPixmap::alphaType SkBitmap::alphaType |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1409 | |
| 1410 | #Method ## |
| 1411 | |
| 1412 | # ------------------------------------------------------------------------------ |
| 1413 | |
| 1414 | #Method SkColorSpace* colorSpace() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1415 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1416 | #Line # returns Color_Space ## |
| 1417 | Returns Color_Space, the range of colors. The reference count of |
| 1418 | Color_Space is unchanged. The returned Color_Space is immutable. |
| 1419 | |
| 1420 | #Return Color_Space, or nullptr ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1421 | |
| 1422 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1423 | #Description |
| 1424 | SkColorSpace::MakeSRGBLinear creates Color_Space with linear gamma |
| 1425 | and an sRGB gamut. This Color_Space gamma is not close to sRGB gamma. |
| 1426 | ## |
| 1427 | SkImageInfo info = SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType, |
| 1428 | SkColorSpace::MakeSRGBLinear()); |
| 1429 | SkColorSpace* colorSpace = info.colorSpace(); |
| 1430 | SkDebugf("gammaCloseToSRGB: %s gammaIsLinear: %s isSRGB: %s\n", |
| 1431 | colorSpace->gammaCloseToSRGB() ? "true" : "false", |
| 1432 | colorSpace->gammaIsLinear() ? "true" : "false", |
| 1433 | colorSpace->isSRGB() ? "true" : "false"); |
| 1434 | #StdOut |
| 1435 | gammaCloseToSRGB: false gammaIsLinear: true isSRGB: false |
| 1436 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1437 | ## |
| 1438 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1439 | #SeeAlso Color_Space SkPixmap::colorSpace SkBitmap::colorSpace |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1440 | |
| 1441 | #Method ## |
| 1442 | |
| 1443 | # ------------------------------------------------------------------------------ |
| 1444 | |
| 1445 | #Method sk_sp<SkColorSpace> refColorSpace() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1446 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1447 | #Line # returns Color_Space ## |
| 1448 | Returns smart pointer to Color_Space, the range of colors. The smart pointer |
| 1449 | tracks the number of objects sharing this Color_Space reference so the memory |
| 1450 | is released when the owners destruct. |
| 1451 | |
| 1452 | The returned Color_Space is immutable. |
| 1453 | |
| 1454 | #Return Color_Space wrapped in a smart pointer ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1455 | |
| 1456 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1457 | SkImageInfo info1 = SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType, |
| 1458 | SkColorSpace::MakeSRGBLinear()); |
| 1459 | SkImageInfo info2 = SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType, |
| 1460 | info1.refColorSpace()); |
| 1461 | SkColorSpace* colorSpace = info2.colorSpace(); |
| 1462 | SkDebugf("gammaCloseToSRGB: %s gammaIsLinear: %s isSRGB: %s\n", |
| 1463 | colorSpace->gammaCloseToSRGB() ? "true" : "false", |
| 1464 | colorSpace->gammaIsLinear() ? "true" : "false", |
| 1465 | colorSpace->isSRGB() ? "true" : "false"); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1466 | ## |
| 1467 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1468 | #SeeAlso Color_Space SkBitmap::refColorSpace |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1469 | |
| 1470 | #Method ## |
| 1471 | |
| 1472 | # ------------------------------------------------------------------------------ |
| 1473 | |
| 1474 | #Method bool isEmpty() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1475 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1476 | #Line # returns if dimensions contain pixels ## |
| 1477 | |
| 1478 | Returns if Image_Info describes an empty area of pixels by checking if either |
| 1479 | width or height is zero or smaller. |
| 1480 | |
| 1481 | #Return true if either dimension is zero or smaller ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1482 | |
| 1483 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1484 | for (int width : { 0, 2 } ) { |
| 1485 | for (int height : { 0, 2 } ) { |
| 1486 | SkImageInfo imageInfo= SkImageInfo::MakeA8(width, height); |
| 1487 | SkDebugf("width: %d height: %d empty: %s\n", width, height, |
| 1488 | imageInfo.isEmpty() ? "true" : "false"); |
| 1489 | } |
| 1490 | } |
| 1491 | #StdOut |
| 1492 | width: 0 height: 0 empty: true |
| 1493 | width: 0 height: 2 empty: true |
| 1494 | width: 2 height: 0 empty: true |
| 1495 | width: 2 height: 2 empty: false |
| 1496 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1497 | ## |
| 1498 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1499 | #SeeAlso dimensions bounds SkBitmap::empty SkPixmap::bounds |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1500 | |
| 1501 | #Method ## |
| 1502 | |
| 1503 | # ------------------------------------------------------------------------------ |
| 1504 | |
| 1505 | #Method bool isOpaque() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1506 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1507 | #Line # returns if Alpha_Type is kOpaque_SkAlphaType ## |
| 1508 | |
| 1509 | Returns true if Alpha_Type is set to hint that all pixels are opaque; their |
| 1510 | Color_Alpha value is implicitly or explicitly 1.0. If true, and all pixels are |
| 1511 | not opaque, Skia may draw incorrectly. |
| 1512 | |
| 1513 | Does not check if Color_Type allows Alpha, or if any pixel value has |
| 1514 | transparency. |
| 1515 | |
| 1516 | #Return true if Alpha_Type is kOpaque_SkAlphaType ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1517 | |
| 1518 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1519 | const int height = 2; |
| 1520 | const int width = 2; |
| 1521 | SkBitmap bitmap; |
| 1522 | SkImageInfo imageInfo = SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); |
| 1523 | bitmap.setInfo(imageInfo); |
| 1524 | for (int index = 0; index < 2; ++index) { |
| 1525 | bitmap.allocPixels(); |
| 1526 | bitmap.eraseColor(0x00000000); |
| 1527 | SkDebugf("isOpaque: %s\n", imageInfo.isOpaque() ? "true" : "false"); |
| 1528 | bitmap.eraseColor(0xFFFFFFFF); |
| 1529 | SkDebugf("isOpaque: %s\n", imageInfo.isOpaque() ? "true" : "false"); |
| 1530 | imageInfo = imageInfo.makeAlphaType(kOpaque_SkAlphaType); |
| 1531 | bitmap.setInfo(imageInfo); |
| 1532 | } |
| 1533 | #StdOut |
| 1534 | isOpaque: false |
| 1535 | isOpaque: false |
| 1536 | isOpaque: true |
| 1537 | isOpaque: true |
| 1538 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1539 | ## |
| 1540 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1541 | #SeeAlso Color_Alpha SkColorTypeValidateAlphaType SkBitmap::isOpaque SkImage::isOpaque SkPixmap::isOpaque |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1542 | |
| 1543 | #Method ## |
| 1544 | |
| 1545 | # ------------------------------------------------------------------------------ |
| 1546 | |
| 1547 | #Method SkISize dimensions() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1548 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1549 | #Line # returns width() and height() ## |
| 1550 | |
| 1551 | Returns ISize { width(), height() }. |
| 1552 | |
| 1553 | #Return integral size of width() and height() ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1554 | |
| 1555 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1556 | const int height = 2; |
| 1557 | const int width = 2; |
| 1558 | SkImageInfo imageInfo = SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); |
| 1559 | SkISize dimensions = imageInfo.dimensions(); |
| 1560 | SkIRect bounds = imageInfo.bounds(); |
| 1561 | SkIRect dimensionsAsBounds = SkIRect::MakeSize(dimensions); |
| 1562 | SkDebugf("dimensionsAsBounds %c= bounds\n", dimensionsAsBounds == bounds ? '=' : '!'); |
| 1563 | #StdOut |
| 1564 | dimensionsAsBounds == bounds |
| 1565 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1566 | ## |
| 1567 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1568 | #SeeAlso width height bounds SkBitmap::dimensions |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1569 | |
| 1570 | #Method ## |
| 1571 | |
| 1572 | # ------------------------------------------------------------------------------ |
| 1573 | |
| 1574 | #Method SkIRect bounds() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1575 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1576 | #Line # returns width() and height() as Rectangle ## |
| 1577 | Returns IRect { 0, 0, width(), height() }. |
| 1578 | |
| 1579 | #Return integral rectangle from origin to width() and height() ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1580 | |
| 1581 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1582 | #Height 64 |
| 1583 | #Image 4 |
| 1584 | canvas->scale(.5f, .5f); |
| 1585 | SkImageInfo imageInfo = source.info(); |
| 1586 | SkIRect bounds = imageInfo.bounds(); |
| 1587 | for (int x : { 0, bounds.width() } ) { |
| 1588 | for (int y : { 0, bounds.height() } ) { |
| 1589 | canvas->drawBitmap(source, x, y); |
| 1590 | } |
| 1591 | } |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1592 | ## |
| 1593 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1594 | #SeeAlso width height dimensions |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1595 | |
| 1596 | #Method ## |
| 1597 | |
| 1598 | # ------------------------------------------------------------------------------ |
| 1599 | |
| 1600 | #Method bool gammaCloseToSRGB() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1601 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1602 | #Line # Returns if Color_Space gamma is approximately the same as sRGB ## |
| 1603 | |
| 1604 | Returns true if associated Color_Space is not nullptr, and Color_Space gamma |
| 1605 | is approximately the same as sRGB. |
| 1606 | This includes the |
| 1607 | ###$ |
| 1608 | $A sRGB transfer function $ https://en.wikipedia.org/wiki/SRGB#The_sRGB_transfer_function_(%22gamma%22) $$ |
| 1609 | $$$# |
| 1610 | as well as a gamma curve described by a 2.2 exponent. |
| 1611 | |
| 1612 | #Return true if Color_Space gamma is approximately the same as sRGB ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1613 | |
| 1614 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1615 | #Height 144 |
| 1616 | const int width = 256; |
| 1617 | const int height = 64; |
| 1618 | auto drawLabel = [=](const char* what, bool closeToSRGB) -> void { |
| 1619 | SkString string; |
| 1620 | string.printf("%s gamma is %s" "close to sRGB", what, closeToSRGB ? "" : "not "); |
| 1621 | SkPaint paint; |
| 1622 | paint.setAntiAlias(true); |
| 1623 | paint.setTextAlign(SkPaint::kCenter_Align); |
| 1624 | canvas->drawString(string, width / 2, 56, paint); |
| 1625 | }; |
| 1626 | SkColor gradColors[] = { 0xFFFF7F00, 0xFF00FF7F, 0xFF0000FF, 0xFF7F7FFF }; |
| 1627 | SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } }; |
| 1628 | SkPaint gradPaint; |
| 1629 | gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, |
| 1630 | SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode)); |
| 1631 | canvas->drawRect(SkRect::MakeWH(width, height), gradPaint); |
| 1632 | drawLabel("canvas", canvas->imageInfo().gammaCloseToSRGB()); |
| 1633 | SkBitmap bitmap; |
| 1634 | SkImageInfo offscreenInfo = SkImageInfo::MakeS32(width, height, kPremul_SkAlphaType); |
| 1635 | bitmap.allocPixels(offscreenInfo); |
| 1636 | SkCanvas sRGBOffscreen(bitmap); |
| 1637 | sRGBOffscreen.drawRect(SkRect::MakeWH(width, height), gradPaint); |
| 1638 | canvas->translate(0, 80); |
| 1639 | canvas->drawBitmap(bitmap, 0, 0); |
| 1640 | drawLabel("offscreen", offscreenInfo.gammaCloseToSRGB()); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1641 | ## |
| 1642 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1643 | #SeeAlso SkColorSpace::gammaCloseToSRGB |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1644 | |
| 1645 | #Method ## |
| 1646 | |
| 1647 | # ------------------------------------------------------------------------------ |
| 1648 | |
| 1649 | #Method SkImageInfo makeWH(int newWidth, int newHeight) const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1650 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1651 | #Line # creates Image_Info with changed dimensions ## |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1652 | Creates Image_Info with the same Color_Type, Color_Space, and Alpha_Type, |
| 1653 | with dimensions set to width and height. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1654 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1655 | #Param newWidth pixel column count; must be zero or greater ## |
| 1656 | #Param newHeight pixel row count; must be zero or greater ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1657 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1658 | #Return created Image_Info ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1659 | |
| 1660 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1661 | #Height 144 |
| 1662 | #Image 3 |
| 1663 | SkImageInfo canvasImageInfo = canvas->imageInfo(); |
| 1664 | SkRect canvasBounds = SkRect::Make(canvasImageInfo.bounds()); |
| 1665 | canvas->drawBitmapRect(source, source.bounds(), canvasBounds, nullptr); |
| 1666 | SkImageInfo insetImageInfo = |
| 1667 | canvasImageInfo.makeWH(canvasBounds.width() / 2, canvasBounds.height() / 2); |
| 1668 | SkBitmap inset; |
| 1669 | inset.allocPixels(insetImageInfo); |
| 1670 | SkCanvas offscreen(inset); |
| 1671 | offscreen.drawBitmapRect(source, source.bounds(), SkRect::Make(inset.bounds()), nullptr); |
| 1672 | canvas->drawBitmap(inset, canvasBounds.width() / 4, canvasBounds.height() / 4); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1673 | ## |
| 1674 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1675 | #SeeAlso Make makeAlphaType makeColorSpace makeColorType |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1676 | |
| 1677 | #Method ## |
| 1678 | |
| 1679 | # ------------------------------------------------------------------------------ |
| 1680 | |
| 1681 | #Method SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1682 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1683 | #Line # creates Image_Info with changed Alpha_Type ## |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1684 | Creates Image_Info with same Color_Type, Color_Space, width, and height, |
| 1685 | with Alpha_Type set to newAlphaType. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1686 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1687 | Created Image_Info contains newAlphaType even if it is incompatible with |
| 1688 | Color_Type, in which case Alpha_Type in Image_Info is ignored. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1689 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1690 | #Param newAlphaType one of: #list_of_alpha_types# |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1691 | ## |
| 1692 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1693 | #Return created Image_Info ## |
| 1694 | |
| 1695 | #Example |
| 1696 | #Image 3 |
| 1697 | const int width = 256; |
| 1698 | const int height = 128; |
| 1699 | SkColor pixels[height][width]; |
| 1700 | for (int y = 0; y < height; ++y) { |
| 1701 | for (int x = 0; x < width; ++x) { |
| 1702 | int red = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 4 + y) * 0.03f))); |
| 1703 | int blue = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 3 + y) * 0.04f))); |
| 1704 | int green = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 2 + y) * 0.05f))); |
| 1705 | int alpha = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 1 + y) * 0.006f))); |
| 1706 | pixels[y][x] = |
| 1707 | SkColorSetARGB(alpha, red * alpha / 255, green * alpha / 255, blue * alpha / 255); |
| 1708 | } |
| 1709 | } |
| 1710 | SkBitmap bitmap; |
| 1711 | SkImageInfo info = SkImageInfo::Make(width, height, kBGRA_8888_SkColorType, kPremul_SkAlphaType); |
| 1712 | bitmap.installPixels(info, (void*) pixels, sizeof(SkColor) * width); |
| 1713 | canvas->drawBitmap(source, 0, 0); |
| 1714 | canvas->drawBitmap(bitmap, 0, 0); |
| 1715 | SkImageInfo unpremulInfo = info.makeAlphaType(kUnpremul_SkAlphaType); |
| 1716 | bitmap.installPixels(unpremulInfo, (void*) pixels, sizeof(SkColor) * width); |
| 1717 | canvas->drawBitmap(bitmap, 0, 128); |
| 1718 | ## |
| 1719 | |
| 1720 | #SeeAlso Make MakeA8 makeColorType makeColorSpace |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1721 | |
| 1722 | #Method ## |
| 1723 | |
| 1724 | # ------------------------------------------------------------------------------ |
| 1725 | |
| 1726 | #Method SkImageInfo makeColorType(SkColorType newColorType) const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1727 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1728 | #Line # creates Image_Info with changed Color_Type ## |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1729 | Creates Image_Info with same Alpha_Type, Color_Space, width, and height, |
| 1730 | with Color_Type set to newColorType. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1731 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1732 | #Param newColorType one of: #list_of_color_types# |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1733 | ## |
| 1734 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1735 | #Return created Image_Info ## |
| 1736 | |
| 1737 | #Example |
| 1738 | const int width = 256; |
| 1739 | const int height = 128; |
| 1740 | SkColor pixels[height][width]; |
| 1741 | for (int y = 0; y < height; ++y) { |
| 1742 | for (int x = 0; x < width; ++x) { |
| 1743 | int red = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 4 + y) * 0.03f))); |
| 1744 | int blue = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 3 + y) * 0.04f))); |
| 1745 | int green = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 2 + y) * 0.05f))); |
| 1746 | int alpha = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 1 + y) * 0.006f))); |
| 1747 | pixels[y][x] = |
| 1748 | SkColorSetARGB(alpha, red * alpha / 255, green * alpha / 255, blue * alpha / 255); |
| 1749 | } |
| 1750 | } |
| 1751 | SkBitmap bitmap; |
| 1752 | SkImageInfo info = SkImageInfo::Make(width, height, kBGRA_8888_SkColorType, kPremul_SkAlphaType); |
| 1753 | bitmap.installPixels(info, (void*) pixels, sizeof(SkColor) * width); |
| 1754 | canvas->drawBitmap(source, 0, 0); |
| 1755 | canvas->drawBitmap(bitmap, 0, 0); |
| 1756 | SkImageInfo rgbaInfo = info.makeColorType(kRGBA_8888_SkColorType); |
| 1757 | bitmap.installPixels(rgbaInfo, (void*) pixels, sizeof(SkColor) * width); |
| 1758 | canvas->drawBitmap(bitmap, 0, 128); |
| 1759 | ## |
| 1760 | |
| 1761 | #SeeAlso Make makeAlphaType makeColorSpace |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1762 | |
| 1763 | #Method ## |
| 1764 | |
| 1765 | # ------------------------------------------------------------------------------ |
| 1766 | |
| 1767 | #Method SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1768 | #In Constructor |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1769 | #Line # creates Image_Info with changed Color_Space ## |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1770 | Creates Image_Info with same Alpha_Type, Color_Type, width, and height, |
| 1771 | with Color_Space set to cs. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1772 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1773 | #Param cs range of colors; may be nullptr ## |
| 1774 | |
| 1775 | #Return created Image_Info ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1776 | |
| 1777 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1778 | #Height 224 |
| 1779 | const int width = 256; |
| 1780 | const int height = 64; |
| 1781 | auto drawLabel = [=](const char* what, bool closeToSRGB) -> void { |
| 1782 | SkString string; |
| 1783 | string.printf("%s gamma is %s" "close to sRGB", what, closeToSRGB ? "" : "not "); |
| 1784 | SkPaint paint; |
| 1785 | paint.setAntiAlias(true); |
| 1786 | paint.setTextAlign(SkPaint::kCenter_Align); |
| 1787 | canvas->drawString(string, width / 2, 56, paint); |
| 1788 | }; |
| 1789 | SkColor gradColors[] = { 0xFFFF7F00, 0xFF00FF7F, 0xFF0000FF, 0xFF7F7FFF }; |
| 1790 | SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } }; |
| 1791 | SkPaint gradPaint; |
| 1792 | gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, |
| 1793 | SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode)); |
| 1794 | canvas->drawRect(SkRect::MakeWH(width, height), gradPaint); |
| 1795 | drawLabel("canvas", canvas->imageInfo().gammaCloseToSRGB()); |
| 1796 | SkBitmap bitmap; |
| 1797 | SkImageInfo offscreenInfo = SkImageInfo::MakeS32(width, height, kPremul_SkAlphaType); |
| 1798 | bitmap.allocPixels(offscreenInfo); |
| 1799 | SkCanvas sRGBOffscreen(bitmap); |
| 1800 | sRGBOffscreen.drawRect(SkRect::MakeWH(width, height), gradPaint); |
| 1801 | canvas->translate(0, 80); |
| 1802 | canvas->drawBitmap(bitmap, 0, 0); |
| 1803 | drawLabel("offscreen", offscreenInfo.gammaCloseToSRGB()); |
| 1804 | SkImageInfo linearGamma = |
| 1805 | offscreenInfo.makeColorSpace(offscreenInfo.colorSpace()->makeLinearGamma()); |
| 1806 | bitmap.allocPixels(linearGamma); |
| 1807 | SkCanvas lgOffscreen(bitmap); |
| 1808 | lgOffscreen.drawRect(SkRect::MakeWH(width, height), gradPaint); |
| 1809 | canvas->translate(0, 80); |
| 1810 | canvas->drawBitmap(bitmap, 0, 0); |
| 1811 | drawLabel("linear", linearGamma.gammaCloseToSRGB()); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1812 | ## |
| 1813 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1814 | #SeeAlso Make MakeS32 makeAlphaType makeColorType |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1815 | |
| 1816 | #Method ## |
| 1817 | |
| 1818 | # ------------------------------------------------------------------------------ |
| 1819 | |
| 1820 | #Method int bytesPerPixel() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1821 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1822 | #Line # returns number of bytes in pixel based on Color_Type ## |
| 1823 | Returns number of bytes per pixel required by Color_Type. |
| 1824 | Returns zero if colorType( is kUnknown_SkColorType. |
| 1825 | |
| 1826 | #Return bytes in pixel ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1827 | |
| 1828 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1829 | const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x", |
| 1830 | "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"}; |
| 1831 | for (SkColorType colorType : { #list_of_color_types# |
| 1832 | } ) { |
| 1833 | SkImageInfo info = SkImageInfo::Make(1, 1, colorType, kOpaque_SkAlphaType); |
| 1834 | SkDebugf("color: k" "%s" "_SkColorType" "%*s" "bytesPerPixel: %d\n", |
| 1835 | colors[colorType], 13 - strlen(colors[colorType]), " ", |
| 1836 | info.bytesPerPixel()); |
| 1837 | } |
| 1838 | #StdOut |
| 1839 | color: kUnknown_SkColorType bytesPerPixel: 0 |
| 1840 | color: kAlpha_8_SkColorType bytesPerPixel: 1 |
| 1841 | color: kRGB_565_SkColorType bytesPerPixel: 2 |
| 1842 | color: kARGB_4444_SkColorType bytesPerPixel: 2 |
| 1843 | color: kRGBA_8888_SkColorType bytesPerPixel: 4 |
| 1844 | color: kRGB_888x_SkColorType bytesPerPixel: 4 |
| 1845 | color: kBGRA_8888_SkColorType bytesPerPixel: 4 |
| 1846 | color: kRGBA_1010102_SkColorType bytesPerPixel: 4 |
| 1847 | color: kRGB_101010x_SkColorType bytesPerPixel: 4 |
| 1848 | color: kGray_8_SkColorType bytesPerPixel: 1 |
| 1849 | color: kRGBA_F16_SkColorType bytesPerPixel: 8 |
| 1850 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1851 | ## |
| 1852 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1853 | #SeeAlso width shiftPerPixel SkBitmap::bytesPerPixel |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1854 | |
| 1855 | #Method ## |
| 1856 | |
| 1857 | # ------------------------------------------------------------------------------ |
| 1858 | |
| 1859 | #Method int shiftPerPixel() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1860 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1861 | #Line # returns bit shift from pixels to bytes ## |
| 1862 | Returns bit shift converting row bytes to row pixels. |
| 1863 | Returns zero for kUnknown_SkColorType. |
| 1864 | |
| 1865 | #Return one of: 0, 1, 2, 3; left shift to convert pixels to bytes ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1866 | |
| 1867 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1868 | const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x", |
| 1869 | "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"}; |
| 1870 | for (SkColorType colorType : { #list_of_color_types# |
| 1871 | } ) { |
| 1872 | SkImageInfo info = SkImageInfo::Make(1, 1, colorType, kOpaque_SkAlphaType); |
| 1873 | SkDebugf("color: k" "%s" "_SkColorType" "%*s" "shiftPerPixel: %d\n", |
| 1874 | colors[colorType], 14 - strlen(colors[colorType]), " ", |
| 1875 | info.shiftPerPixel()); |
| 1876 | } |
| 1877 | #StdOut |
| 1878 | color: kUnknown_SkColorType shiftPerPixel: 0 |
| 1879 | color: kAlpha_8_SkColorType shiftPerPixel: 0 |
| 1880 | color: kRGB_565_SkColorType shiftPerPixel: 1 |
| 1881 | color: kARGB_4444_SkColorType shiftPerPixel: 1 |
| 1882 | color: kRGBA_8888_SkColorType shiftPerPixel: 2 |
| 1883 | color: kRGB_888x_SkColorType shiftPerPixel: 2 |
| 1884 | color: kBGRA_8888_SkColorType shiftPerPixel: 2 |
| 1885 | color: kRGBA_1010102_SkColorType shiftPerPixel: 2 |
| 1886 | color: kRGB_101010x_SkColorType shiftPerPixel: 2 |
| 1887 | color: kGray_8_SkColorType shiftPerPixel: 0 |
| 1888 | color: kRGBA_F16_SkColorType shiftPerPixel: 3 |
| 1889 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1890 | ## |
| 1891 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 1892 | #SeeAlso bytesPerPixel minRowBytes SkBitmap::shiftPerPixel SkPixmap::shiftPerPixel |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1893 | |
| 1894 | #Method ## |
| 1895 | |
| 1896 | # ------------------------------------------------------------------------------ |
| 1897 | |
| 1898 | #Method uint64_t minRowBytes64() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1899 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1900 | #Line # returns width() times bytesPerPixel in 64 bits ## |
| 1901 | |
| 1902 | Returns minimum bytes per row, computed from pixel width() and Color_Type, which |
| 1903 | specifies bytesPerPixel(). Bitmap maximum value for row bytes must be representable |
| 1904 | as a positive value in a 32-bit signed integer. |
| 1905 | |
| 1906 | #Return width() times bytesPerPixel as unsigned 64-bit integer ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1907 | |
| 1908 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1909 | for (int shift = 24; shift < 32; ++shift) { |
| 1910 | int width = 1 << shift; |
| 1911 | SkImageInfo imageInfo = |
| 1912 | SkImageInfo::Make(width, 1, kRGBA_F16_SkColorType, kPremul_SkAlphaType); |
| 1913 | uint64_t minRowBytes = imageInfo.minRowBytes64(); |
| 1914 | bool widthTooLarge = (uint64_t) (int32_t) minRowBytes != minRowBytes; |
| 1915 | SkDebugf("RGBA_F16 width %d (0x%08x) %s\n", |
| 1916 | width, width, widthTooLarge ? "too large" : "OK"); |
| 1917 | } |
| 1918 | #StdOut |
| 1919 | RGBA_F16 width 16777216 (0x01000000) OK |
| 1920 | RGBA_F16 width 33554432 (0x02000000) OK |
| 1921 | RGBA_F16 width 67108864 (0x04000000) OK |
| 1922 | RGBA_F16 width 134217728 (0x08000000) OK |
| 1923 | RGBA_F16 width 268435456 (0x10000000) too large |
| 1924 | RGBA_F16 width 536870912 (0x20000000) too large |
| 1925 | RGBA_F16 width 1073741824 (0x40000000) too large |
| 1926 | RGBA_F16 width -2147483648 (0x80000000) too large |
| 1927 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1928 | ## |
| 1929 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1930 | #SeeAlso minRowBytes computeByteSize computeMinByteSize validRowBytes |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1931 | |
| 1932 | #Method ## |
| 1933 | |
| 1934 | # ------------------------------------------------------------------------------ |
| 1935 | |
| 1936 | #Method size_t minRowBytes() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1937 | #In Property |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1938 | #Line # returns width() times bytesPerPixel in 32 bits ## |
| 1939 | |
| 1940 | Returns minimum bytes per row, computed from pixel width() and Color_Type, which |
| 1941 | specifies bytesPerPixel(). Bitmap maximum value for row bytes must be representable |
| 1942 | as a positive value in a 32-bit signed integer. |
| 1943 | |
| 1944 | #Return width() times bytesPerPixel as signed 32-bit integer ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1945 | |
| 1946 | #Example |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1947 | for (int shift = 24; shift < 32; ++shift) { |
| 1948 | int width = 1 << shift; |
| 1949 | SkImageInfo imageInfo = |
| 1950 | SkImageInfo::Make(width, 1, kRGBA_F16_SkColorType, kPremul_SkAlphaType); |
| 1951 | size_t minRowBytes = imageInfo.minRowBytes(); |
| 1952 | bool widthTooLarge = !minRowBytes; |
| 1953 | SkDebugf("RGBA_F16 width %d (0x%08x) %s\n", |
| 1954 | width, width, widthTooLarge ? "too large" : "OK"); |
| 1955 | } |
| 1956 | #StdOut |
| 1957 | RGBA_F16 width 16777216 (0x01000000) OK |
| 1958 | RGBA_F16 width 33554432 (0x02000000) OK |
| 1959 | RGBA_F16 width 67108864 (0x04000000) OK |
| 1960 | RGBA_F16 width 134217728 (0x08000000) OK |
| 1961 | RGBA_F16 width 268435456 (0x10000000) too large |
| 1962 | RGBA_F16 width 536870912 (0x20000000) too large |
| 1963 | RGBA_F16 width 1073741824 (0x40000000) too large |
| 1964 | RGBA_F16 width -2147483648 (0x80000000) too large |
| 1965 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1966 | ## |
| 1967 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1968 | #SeeAlso minRowBytes64 computeByteSize computeMinByteSize validRowBytes |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1969 | |
| 1970 | #Method ## |
| 1971 | |
| 1972 | # ------------------------------------------------------------------------------ |
| 1973 | |
| 1974 | #Method size_t computeOffset(int x, int y, size_t rowBytes) const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1975 | #In Utility |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1976 | #Line # returns byte offset within pixel array ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1977 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1978 | Returns byte offset of pixel from pixel base address. |
| 1979 | |
| 1980 | Asserts in debug build if x or y is outside of bounds. Does not assert if |
| 1981 | rowBytes is smaller than minRowBytes, even though result may be incorrect. |
| 1982 | |
| 1983 | #Param x column index, zero or greater, and less than width() ## |
| 1984 | #Param y row index, zero or greater, and less than height() ## |
| 1985 | #Param rowBytes size of pixel row or larger ## |
| 1986 | |
| 1987 | #Return offset within pixel array ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 1988 | |
| 1989 | #Example |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 1990 | #Height 128 |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 1991 | uint8_t pixels[][12] = { { 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00}, |
| 1992 | { 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00}, |
| 1993 | { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00}, |
| 1994 | { 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF}, |
| 1995 | { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, |
| 1996 | { 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00}, |
| 1997 | { 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00}, |
| 1998 | { 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00} }; |
| 1999 | SkImageInfo imageInfo = SkImageInfo::MakeA8(8, 8); |
| 2000 | SkBitmap bitmap; |
| 2001 | bitmap.installPixels(imageInfo, (void*) pixels, sizeof(pixels[0])); |
| 2002 | SkPaint paint; |
| 2003 | paint.setColor(SK_ColorRED); |
| 2004 | canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), SkRect::MakeWH(32, 32), &paint); |
| 2005 | size_t offset = imageInfo.computeOffset(2, 3, sizeof(pixels[0])); |
| 2006 | pixels[0][offset] = 0x7F; |
| 2007 | offset = imageInfo.computeOffset(5, 3, sizeof(pixels[0])); |
| 2008 | pixels[0][offset] = 0x7F; |
| 2009 | bitmap.installPixels(imageInfo, (void*) pixels, sizeof(pixels[0])); |
| 2010 | canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), SkRect::MakeWH(128, 128), &paint); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2011 | ## |
| 2012 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2013 | #SeeAlso height width minRowBytes computeByteSize |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2014 | |
| 2015 | #Method ## |
| 2016 | |
| 2017 | # ------------------------------------------------------------------------------ |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 2018 | #Subtopic Operator |
| 2019 | #Populate |
| 2020 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2021 | |
| 2022 | #Method bool operator==(const SkImageInfo& other)_const |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2023 | #Line # compares Image_Info for equality ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2024 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2025 | Compares Image_Info with other, and returns true if width, height, Color_Type, |
| 2026 | Alpha_Type, and Color_Space are equivalent. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2027 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2028 | #Param other Image_Info to compare ## |
| 2029 | |
| 2030 | #Return true if Image_Info equals other ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2031 | |
| 2032 | #Example |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2033 | SkImageInfo info1 = SkImageInfo::Make(10, 20, kGray_8_SkColorType, kPremul_SkAlphaType);
|
| 2034 | SkImageInfo info2 = SkImageInfo::Make(20, 10, kAlpha_8_SkColorType, kUnpremul_SkAlphaType);
|
| 2035 | SkDebugf("info1 %c= info2\n", info1 == info2 ? '=' : '!');
|
| 2036 | info2 = info2.makeWH(10, 20);
|
| 2037 | SkDebugf("info1 %c= info2\n", info1 == info2 ? '=' : '!');
|
| 2038 | info2 = info2.makeColorType(kGray_8_SkColorType);
|
| 2039 | SkDebugf("info1 %c= info2\n", info1 == info2 ? '=' : '!');
|
| 2040 | info2 = info2.makeAlphaType(kPremul_SkAlphaType);
|
| 2041 | SkDebugf("info1 %c= info2\n", info1 == info2 ? '=' : '!');
|
| 2042 | #StdOut
|
| 2043 | info1 != info2
|
| 2044 | info1 != info2
|
| 2045 | info1 != info2
|
| 2046 | info1 == info2
|
| 2047 | ##
|
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2048 | ## |
| 2049 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2050 | #SeeAlso operator!=(const SkImageInfo& other)_const SkColorSpace::Equals |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2051 | |
| 2052 | #Method ## |
| 2053 | |
| 2054 | # ------------------------------------------------------------------------------ |
| 2055 | |
| 2056 | #Method bool operator!=(const SkImageInfo& other)_const |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2057 | #Line # compares Image_Info for inequality ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2058 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2059 | Compares Image_Info with other, and returns true if width, height, Color_Type, |
| 2060 | Alpha_Type, and Color_Space are equivalent. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2061 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2062 | #Param other Image_Info to compare ## |
| 2063 | |
| 2064 | #Return true if Image_Info is not equal to other ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2065 | |
| 2066 | #Example |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2067 | SkImageInfo info1 = SkImageInfo::Make(10, 20, kGray_8_SkColorType, kPremul_SkAlphaType);
|
| 2068 | SkImageInfo info2 = SkImageInfo::Make(20, 10, kAlpha_8_SkColorType, kUnpremul_SkAlphaType);
|
| 2069 | SkDebugf("info1 %c= info2\n", info1 != info2 ? '!' : '=');
|
| 2070 | info2 = info2.makeWH(10, 20);
|
| 2071 | SkDebugf("info1 %c= info2\n", info1 != info2 ? '!' : '=');
|
| 2072 | info2 = info2.makeColorType(kGray_8_SkColorType);
|
| 2073 | SkDebugf("info1 %c= info2\n", info1 != info2 ? '!' : '=');
|
| 2074 | info2 = info2.makeAlphaType(kPremul_SkAlphaType);
|
| 2075 | SkDebugf("info1 %c= info2\n", info1 != info2 ? '!' : '=');
|
| 2076 | #StdOut
|
| 2077 | info1 != info2
|
| 2078 | info1 != info2
|
| 2079 | info1 != info2
|
| 2080 | info1 == info2
|
| 2081 | ##
|
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2082 | ## |
| 2083 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2084 | #SeeAlso operator==(const SkImageInfo& other)_const SkColorSpace::Equals |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2085 | |
| 2086 | #Method ## |
| 2087 | |
| 2088 | # ------------------------------------------------------------------------------ |
| 2089 | |
| 2090 | #Method size_t computeByteSize(size_t rowBytes) const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 2091 | #In Utility |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2092 | #Line # memory required by pixel buffer with given row bytes ## |
| 2093 | Returns storage required by pixel array, given Image_Info dimensions, Color_Type, |
| 2094 | and rowBytes. rowBytes is assumed to be at least as large as minRowBytes(). |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2095 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2096 | Returns zero if height is zero. |
| 2097 | Returns SK_MaxSizeT if answer exceeds the range of size_t. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2098 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2099 | #Param rowBytes size of pixel row or larger ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2100 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2101 | #Return memory required by pixel buffer ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2102 | |
| 2103 | #Example |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2104 | #Height 130 |
| 2105 | SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);
|
| 2106 | const size_t size = info.computeByteSize(100000);
|
| 2107 | SkAutoTMalloc<SkPMColor> storage(size);
|
| 2108 | SkPMColor* pixels = storage.get();
|
| 2109 | SkBitmap bitmap;
|
| 2110 | bitmap.setInfo(info);
|
| 2111 | bitmap.setPixels(pixels);
|
| 2112 | bitmap.eraseColor(SK_ColorRED);
|
| 2113 | canvas->scale(50, 50);
|
| 2114 | canvas->rotate(8);
|
| 2115 | canvas->drawBitmap(bitmap, 2, 0); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2116 | ## |
| 2117 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2118 | #SeeAlso computeMinByteSize validRowBytes |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2119 | |
| 2120 | #Method ## |
| 2121 | |
| 2122 | # ------------------------------------------------------------------------------ |
| 2123 | |
| 2124 | #Method size_t computeMinByteSize() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 2125 | #In Utility |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2126 | #Line # least memory required by pixel buffer ## |
| 2127 | Returns storage required by pixel array, given Image_Info dimensions, and |
| 2128 | Color_Type. Uses minRowBytes() to compute bytes for pixel row. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2129 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2130 | Returns zero if height is zero. |
| 2131 | Returns SK_MaxSizeT if answer exceeds the range of size_t. |
| 2132 | |
| 2133 | #Return least memory required by pixel buffer ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2134 | |
| 2135 | #Example |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2136 | #Height 130 |
| 2137 | SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);
|
| 2138 | const size_t size = info.computeMinByteSize();
|
| 2139 | SkAutoTMalloc<SkPMColor> storage(size);
|
| 2140 | SkPMColor* pixels = storage.get();
|
| 2141 | SkBitmap bitmap;
|
| 2142 | bitmap.setInfo(info);
|
| 2143 | bitmap.setPixels(pixels);
|
| 2144 | bitmap.eraseColor(SK_ColorRED);
|
| 2145 | canvas->scale(50, 50);
|
| 2146 | canvas->rotate(8);
|
| 2147 | canvas->drawBitmap(bitmap, 2, 0); |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2148 | ## |
| 2149 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2150 | #SeeAlso computeByteSize validRowBytes |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2151 | |
| 2152 | #Method ## |
| 2153 | |
| 2154 | # ------------------------------------------------------------------------------ |
| 2155 | |
| 2156 | #Method static bool ByteSizeOverflowed(size_t byteSize) |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 2157 | #In Utility |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2158 | #Line # checks result of computeByteSize and computeMinByteSize ## |
| 2159 | Returns true if byteSize equals SK_MaxSizeT. computeByteSize and |
| 2160 | computeMinByteSize return SK_MaxSizeT if size_t can not hold buffer size. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2161 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2162 | #Param byteSize result of computeByteSize or computeMinByteSize ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2163 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2164 | #Return true if computeByteSize or computeMinByteSize result exceeds size_t ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2165 | |
| 2166 | #Example |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2167 | SkImageInfo info = SkImageInfo::MakeN32Premul(2, 1000000000);
|
| 2168 | for (size_t rowBytes = 100000000; rowBytes < 10000000000000LL; rowBytes *= 10) {
|
| 2169 | const size_t size = info.computeByteSize(rowBytes);
|
| 2170 | SkDebugf("rowBytes:%llu size:%llu overflowed:%s\n", rowBytes, size,
|
| 2171 | SkImageInfo::ByteSizeOverflowed(size) ? "true" : "false");
|
| 2172 | }
|
| 2173 | #StdOut
|
| 2174 | rowBytes:100000000 size:99999999900000008 overflowed:false
|
| 2175 | rowBytes:1000000000 size:999999999000000008 overflowed:false
|
| 2176 | rowBytes:10000000000 size:9999999990000000008 overflowed:false
|
| 2177 | rowBytes:100000000000 size:18446744073709551615 overflowed:true
|
| 2178 | rowBytes:1000000000000 size:18446744073709551615 overflowed:true
|
| 2179 | ##
|
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2180 | ## |
| 2181 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2182 | #SeeAlso computeByteSize computeMinByteSize validRowBytes |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2183 | |
| 2184 | #Method ## |
| 2185 | |
| 2186 | # ------------------------------------------------------------------------------ |
| 2187 | |
| 2188 | #Method bool validRowBytes(size_t rowBytes) const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 2189 | #In Utility |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2190 | #Line # checks if row bytes is large enough to contain pixel row ## |
| 2191 | Returns true if rowBytes is smaller than width times pixel size. |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2192 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2193 | #Param rowBytes size of pixel row or larger ## |
| 2194 | |
| 2195 | #Return true if rowBytes is large enough to contain pixel row ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2196 | |
| 2197 | #Example |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2198 | SkImageInfo info = SkImageInfo::MakeN32Premul(16, 8);
|
| 2199 | for (size_t rowBytes = 60; rowBytes < 72; rowBytes += sizeof(SkPMColor)) {
|
| 2200 | SkDebugf("validRowBytes(%llu): %s\n", rowBytes, info.validRowBytes(rowBytes) ?
|
| 2201 | "true" : "false");
|
| 2202 | }
|
| 2203 | #StdOut
|
| 2204 | validRowBytes(60): false
|
| 2205 | validRowBytes(64): true
|
| 2206 | validRowBytes(68): true
|
| 2207 | ##
|
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2208 | ## |
| 2209 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2210 | #SeeAlso ByteSizeOverflowed computeByteSize computeMinByteSize |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2211 | |
| 2212 | #Method ## |
| 2213 | |
| 2214 | # ------------------------------------------------------------------------------ |
| 2215 | |
| 2216 | #Method void reset() |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 2217 | #In Constructor |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2218 | #Line # sets zero dimensions, kUnknown_SkColorType, kUnknown_SkAlphaType ## |
| 2219 | Creates an empty Image_Info with kUnknown_SkColorType, kUnknown_SkAlphaType, |
| 2220 | a width and height of zero, and no Color_Space. |
| 2221 | |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2222 | #Example |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2223 | SkImageInfo info = SkImageInfo::MakeN32Premul(16, 8);
|
| 2224 | SkImageInfo copy = info;
|
| 2225 | SkDebugf("info %c= copy\n", info == copy ? '=' : '!');
|
| 2226 | copy.reset();
|
| 2227 | SkDebugf("info %c= reset copy\n", info == copy ? '=' : '!');
|
| 2228 | SkDebugf("SkImageInfo() %c= reset copy\n", SkImageInfo() == copy ? '=' : '!');
|
| 2229 | #StdOut
|
| 2230 | info == copy
|
| 2231 | info != reset copy
|
| 2232 | SkImageInfo() == reset copy
|
| 2233 | ##
|
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2234 | ## |
| 2235 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2236 | #SeeAlso SkImageInfo() |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2237 | |
| 2238 | #Method ## |
| 2239 | |
| 2240 | # ------------------------------------------------------------------------------ |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 2241 | #Subtopic Utility |
| 2242 | #Populate |
| 2243 | #Line # rarely called management functions ## |
| 2244 | ## |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2245 | |
| 2246 | #Method void validate() const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 2247 | #In Utility |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2248 | #Line # asserts if Image_Info is invalid (debug only) ## |
| 2249 | Asserts if internal values are illegal or inconsistent. Only available if |
| 2250 | SK_DEBUG is defined at compile time. |
| 2251 | |
| 2252 | #NoExample |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2253 | ## |
| 2254 | |
Cary Clark | 06c20f3 | 2018-03-20 15:53:27 -0400 | [diff] [blame] | 2255 | #SeeAlso validRowBytes SkBitmap::validate |
Cary Clark | 2dc84ad | 2018-01-26 12:56:22 -0500 | [diff] [blame] | 2256 | |
| 2257 | #Method ## |
| 2258 | |
| 2259 | #Struct SkImageInfo ## |
| 2260 | |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 2261 | #Topic Image_Info ## |