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