blob: de866ee1e0a57b8e270b9f560792353e2c259ef1 [file] [log] [blame]
Cary Clark2dc84ad2018-01-26 12:56:22 -05001#Topic Image_Info
Cary Clark137b8742018-05-30 09:21:49 -04002#Alias Image_Info_Reference ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05003
Cary Clarkf895a422018-02-27 09:54:21 -05004Image_Info specifies the dimensions and encoding of the pixels in a Bitmap.
5The dimensions are integral width and height. The encoding is how pixel
6bits describe Color_Alpha, transparency; Color components red, blue,
7and green; and Color_Space, the range and linearity of colors.
8
9Image_Info describes an uncompressed raster pixels. In contrast, Image
10additionally describes compressed pixels like PNG, and Surface describes
11destinations on the GPU. Image and Surface may be specified by Image_Info,
12but Image and Surface may not contain Image_Info.
13
Cary Clark08895c42018-02-01 09:37:32 -050014#Subtopic Overview
Cary Clark682c58d2018-05-16 07:07:07 -040015#Populate
Cary Clark2dc84ad2018-01-26 12:56:22 -050016##
17
Cary Clark4855f782018-02-06 09:41:53 -050018#Subtopic Constant
Cary Clark08895c42018-02-01 09:37:32 -050019#Populate
20##
Cary Clark2dc84ad2018-01-26 12:56:22 -050021
22# ------------------------------------------------------------------------------
Cary Clark08895c42018-02-01 09:37:32 -050023#Subtopic Alpha_Type
Cary Clarkf895a422018-02-27 09:54:21 -050024#Line # encoding for pixel transparency ##
Cary Clark137b8742018-05-30 09:21:49 -040025#Alias Alpha_Type ##
26#Alias Alpha_Types ##
Cary Clarkf895a422018-02-27 09:54:21 -050027
Cary Clark681287e2018-03-16 11:34:15 -040028#PhraseDef list_of_alpha_types
29kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
30kUnpremul_SkAlphaType
31##
32
Cary Clark2dc84ad2018-01-26 12:56:22 -050033#Enum SkAlphaType
Cary Clarkf895a422018-02-27 09:54:21 -050034#Line # encoding for pixel transparency ##
Cary Clark2dc84ad2018-01-26 12:56:22 -050035
36#Code
37 enum SkAlphaType {
38 kUnknown_SkAlphaType,
39 kOpaque_SkAlphaType,
40 kPremul_SkAlphaType,
41 kUnpremul_SkAlphaType,
42 kLastEnum_SkAlphaType = kUnpremul_SkAlphaType,
43 };
44##
45
Cary Clarkf895a422018-02-27 09:54:21 -050046Describes how to interpret the alpha component of a pixel. A pixel may
47be opaque, or Color_Alpha, describing multiple levels of transparency.
48
49In simple blending, Color_Alpha weights the draw color and the destination
50color to create a new color. If alpha describes a weight from zero to one:
51
Cary Clark682c58d2018-05-16 07:07:07 -040052#Code
Cary Clarkf895a422018-02-27 09:54:21 -050053 new color = draw color * alpha + destination color * (1 - alpha)
54##
55
56In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.
57
Cary Clarkffb3d682018-05-17 12:17:28 -040058RGB may have Color_Alpha included in each component value; the stored
59value is the original RGB multiplied by Color_Alpha. Premultiplied color
Cary Clarkf895a422018-02-27 09:54:21 -050060components improve performance.
Cary Clark2dc84ad2018-01-26 12:56:22 -050061
62#Const kUnknown_SkAlphaType 0
Cary Clark682c58d2018-05-16 07:07:07 -040063#Line # uninitialized ##
64 Alpha_Type is uninitialized.
Cary Clark2dc84ad2018-01-26 12:56:22 -050065##
66#Const kOpaque_SkAlphaType 1
Cary Clark682c58d2018-05-16 07:07:07 -040067#Line # pixel is opaque ##
68#Details Opaque
69 Pixels are opaque. The Color_Type must have no explicit alpha
70 component, or all alpha components must be set to their maximum value.
Cary Clark2dc84ad2018-01-26 12:56:22 -050071##
72#Const kPremul_SkAlphaType 2
Cary Clark682c58d2018-05-16 07:07:07 -040073#Line # pixel components are Premultiplied by Alpha ##
74#Details Premul
75 Pixels have Alpha Premultiplied into color components.
76 Surface pixels must be Premultiplied.
Cary Clark2dc84ad2018-01-26 12:56:22 -050077##
78#Const kUnpremul_SkAlphaType 3
Cary Clark682c58d2018-05-16 07:07:07 -040079#Line # pixel components are independent of Alpha ##
80#Details Unpremul
81 Pixel color component values are independent of alpha value.
82 Images generated from encoded data like PNG do not Premultiply pixel color
83 components. kUnpremul_SkAlphaType is supported for Image pixels, but not for
84 Surface pixels.
85##
86#Const kLastEnum_SkAlphaType 3
87#Line # last valid value ##
88 Used by tests to iterate through all valid values.
Cary Clark2dc84ad2018-01-26 12:56:22 -050089##
90
Cary Clarkf895a422018-02-27 09:54:21 -050091#NoExample
Cary Clark2dc84ad2018-01-26 12:56:22 -050092##
93
Cary Clarkf895a422018-02-27 09:54:21 -050094#SeeAlso SkColorType SkColorSpace
Cary Clark2dc84ad2018-01-26 12:56:22 -050095
96#Enum SkAlphaType ##
Cary Clarkf895a422018-02-27 09:54:21 -050097
98#Subtopic Opaque
Cary Clark682c58d2018-05-16 07:07:07 -040099#Line # hints all pixels are opaque ##
100Use kOpaque_SkAlphaType as a hint to optimize drawing when Alpha component
Cary Clarkf895a422018-02-27 09:54:21 -0500101of all pixel is set to its maximum value of 1.0; all alpha component bits are set.
Cary Clark682c58d2018-05-16 07:07:07 -0400102If Image_Info is set to kOpaque_SkAlphaType but all alpha values are not 1.0,
103results are undefined.
Cary Clarkf895a422018-02-27 09:54:21 -0500104
105#Example
106#Height 64
107#Description
108SkPreMultiplyARGB parameter a is set to 255, its maximum value, and is interpreted
109as Color_Alpha of 1.0. kOpaque_SkAlphaType may be set to improve performance.
Cary Clark682c58d2018-05-16 07:07:07 -0400110If SkPreMultiplyARGB parameter a is set to a value smaller than 255,
Cary Clarkf895a422018-02-27 09:54:21 -0500111kPremul_SkAlphaType must be used instead to avoid undefined results.
112The four displayed values are the original component values, though not necessarily
113in the same order.
114##
115 SkPMColor color = SkPreMultiplyARGB(255, 50, 100, 150);
116 SkString s;
117 s.printf("%u %u %u %u", SkColorGetA(color), SkColorGetR(color),
118 SkColorGetG(color), SkColorGetB(color));
119 SkPaint paint;
120 paint.setAntiAlias(true);
121 canvas->drawString(s, 10, 62, paint);
122 canvas->scale(50, 50);
123 SkBitmap bitmap;
124 SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kOpaque_SkAlphaType);
125 if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {
126 canvas->drawBitmap(bitmap, 0, 0);
127 }
128##
129
130#Subtopic Opaque ##
131
132#Subtopic Premul
Cary Clark682c58d2018-05-16 07:07:07 -0400133#Line # stores components scaled by Alpha ##
134Use kPremul_SkAlphaType when stored color components are the original color
135multiplied by the alpha component. The alpha component range of 0.0 to 1.0 is
136achieved by dividing the integer bit value by the maximum bit value.
Cary Clarkf895a422018-02-27 09:54:21 -0500137
Cary Clark682c58d2018-05-16 07:07:07 -0400138#Code
Cary Clarkf895a422018-02-27 09:54:21 -0500139stored color = original color * alpha / max alpha
140##
141
142The color component must be equal to or smaller than the alpha component,
143or the results are undefined.
144
145#Example
146#Description
147SkPreMultiplyARGB parameter a is set to 150, less than its maximum value, and is
148interpreted as Color_Alpha of about 0.6. kPremul_SkAlphaType must be set, since
Cary Clark682c58d2018-05-16 07:07:07 -0400149SkPreMultiplyARGB parameter a is set to a value smaller than 255,
Cary Clarkf895a422018-02-27 09:54:21 -0500150to avoid undefined results.
151The four displayed values reflect that the alpha component has been multiplied
152by the original color.
153##
154#Height 64
155 SkPMColor color = SkPreMultiplyARGB(150, 50, 100, 150);
156 SkString s;
157 s.printf("%u %u %u %u", SkColorGetA(color), SkColorGetR(color),
158 SkColorGetG(color), SkColorGetB(color));
159 SkPaint paint;
160 paint.setAntiAlias(true);
161 canvas->drawString(s, 10, 62, paint);
162 canvas->scale(50, 50);
163 SkBitmap bitmap;
164 SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kPremul_SkAlphaType);
165 if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {
166 canvas->drawBitmap(bitmap, 0, 0);
167 }
168##
169
170#Subtopic Premul ##
171
172#Subtopic Unpremul
Cary Clark682c58d2018-05-16 07:07:07 -0400173#Line # stores components without Alpha scaling ##
174Use kUnpremul_SkAlphaType if stored color components are not divided by the
175alpha component. Some drawing destinations may not support
176kUnpremul_SkAlphaType.
Cary Clarkf895a422018-02-27 09:54:21 -0500177
178#Bug 7079
179#Example
Cary Clark681287e2018-03-16 11:34:15 -0400180#Height 64
Cary Clarkf895a422018-02-27 09:54:21 -0500181#Description
182SkColorSetARGB parameter a is set to 150, less than its maximum value, and is
Cary Clark682c58d2018-05-16 07:07:07 -0400183interpreted as Color_Alpha of about 0.6. color is not Premultiplied;
Cary Clarkf895a422018-02-27 09:54:21 -0500184color components may have values greater than color alpha.
185The four displayed values are the original component values, though not necessarily
186in the same order.
187##
188 SkColor color = SkColorSetARGB(150, 50, 100, 255);
189 SkString s;
190 s.printf("%u %u %u %u", SkColorGetA(color), SkColorGetR(color),
191 SkColorGetG(color), SkColorGetB(color));
192 SkPaint paint;
193 paint.setAntiAlias(true);
194 canvas->drawString(s, 10, 62, paint);
195 canvas->scale(50, 50);
196 SkBitmap bitmap;
197 SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kUnpremul_SkAlphaType);
198 if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {
199 canvas->drawBitmap(bitmap, 0, 0);
200 }
201##
202
203#Subtopic Unpremul ##
204
Cary Clark06c20f32018-03-20 15:53:27 -0400205#Method static inline bool SkAlphaTypeIsOpaque(SkAlphaType at)
206#In Property
207#Line # returns if Alpha_Type equals kOpaque_SkAlphaType ##
208
Cary Clarka4f581a2018-04-03 15:31:59 -0400209Returns true if Alpha_Type equals kOpaque_SkAlphaType. kOpaque_SkAlphaType is a
210hint that the Color_Type is opaque, or that all Color_Alpha values are set to
211their 1.0 equivalent. If Alpha_Type is kOpaque_SkAlphaType, and Color_Type is not
212opaque, then the result of drawing any pixel with a Color_Alpha value less than
2131.0 is undefined.
214
Cary Clark06c20f32018-03-20 15:53:27 -0400215#Param at one of: #list_of_alpha_types#
216##
217#Return true if at equals kOpaque_SkAlphaType ##
218#NoExample
219##
220##
221
Cary Clark08895c42018-02-01 09:37:32 -0500222#Subtopic Alpha_Type ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500223
224# ------------------------------------------------------------------------------
Cary Clark08895c42018-02-01 09:37:32 -0500225#Subtopic Color_Type
Cary Clarkf895a422018-02-27 09:54:21 -0500226#Line # encoding for pixel color ##
Cary Clark137b8742018-05-30 09:21:49 -0400227#Alias Color_Type ##
228#Alias Color_Types ##
Cary Clark2a8c48b2018-02-15 17:31:24 -0500229
Cary Clark1a8d7622018-03-05 13:26:16 -0500230#PhraseDef list_of_color_types
231kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
232kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
233kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
234kGray_8_SkColorType, kRGBA_F16_SkColorType
235##
236
Cary Clark2dc84ad2018-01-26 12:56:22 -0500237#Enum SkColorType
Cary Clarkf895a422018-02-27 09:54:21 -0500238#Line # encoding for pixel color ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500239
240#Code
241 enum SkColorType {
242 kUnknown_SkColorType,
243 kAlpha_8_SkColorType,
244 kRGB_565_SkColorType,
245 kARGB_4444_SkColorType,
246 kRGBA_8888_SkColorType,
Cary Clark4855f782018-02-06 09:41:53 -0500247 kRGB_888x_SkColorType,
Cary Clark2dc84ad2018-01-26 12:56:22 -0500248 kBGRA_8888_SkColorType,
Cary Clark4855f782018-02-06 09:41:53 -0500249 kRGBA_1010102_SkColorType,
250 kRGB_101010x_SkColorType,
Cary Clark2dc84ad2018-01-26 12:56:22 -0500251 kGray_8_SkColorType,
252 kRGBA_F16_SkColorType,
Cary Clark224c7002018-06-27 11:00:21 -0400253 kRGBA_F32_SkColorType,
254 kLastEnum_SkColorType = kRGBA_F32_SkColorType,
Cary Clark186d08f2018-04-03 08:43:27 -0400255###$
Cary Clark06c20f32018-03-20 15:53:27 -0400256 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
Cary Clark2dc84ad2018-01-26 12:56:22 -0500257 kN32_SkColorType = kBGRA_8888_SkColorType,
Cary Clark06c20f32018-03-20 15:53:27 -0400258 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
Cary Clark2dc84ad2018-01-26 12:56:22 -0500259 kN32_SkColorType = kRGBA_8888_SkColorType,
Cary Clark06c20f32018-03-20 15:53:27 -0400260 #else
261 #error "SK_*32_SHIFT values must correspond to BGRA or RGBA byte order"
262 #endif
Cary Clark06c20f32018-03-20 15:53:27 -0400263$$$#
Cary Clark186d08f2018-04-03 08:43:27 -0400264 };
265#Code ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500266
Cary Clarkf895a422018-02-27 09:54:21 -0500267Describes how pixel bits encode color. A pixel may be an alpha mask, a
Cary Clark137b8742018-05-30 09:21:49 -0400268Grayscale, RGB, or ARGB.
Cary Clark4855f782018-02-06 09:41:53 -0500269
Cary Clarkffb3d682018-05-17 12:17:28 -0400270kN32_SkColorType selects the native 32-bit ARGB format. On Little_Endian
271processors, pixels containing 8-bit ARGB components pack into 32-bit
Cary Clark4855f782018-02-06 09:41:53 -0500272kBGRA_8888_SkColorType. On Big_Endian processors, pixels pack into 32-bit
273kRGBA_8888_SkColorType.
Cary Clark2dc84ad2018-01-26 12:56:22 -0500274
275#Const kUnknown_SkColorType 0
Cary Clark682c58d2018-05-16 07:07:07 -0400276#Line # uninitialized ##
277 Color_Type is set to kUnknown_SkColorType by default. If set,
278 encoding format and size is unknown.
Cary Clarkab2621d2018-01-30 10:08:57 -0500279##
Cary Clarkf895a422018-02-27 09:54:21 -0500280
Cary Clark682c58d2018-05-16 07:07:07 -0400281#Const kAlpha_8_SkColorType 1
282#Line # pixel with Alpha in 8-bit byte ##
283#Details Alpha_8
284 Stores 8-bit byte pixel encoding that represents transparency. Value of zero
285 is completely transparent; a value of 255 is completely opaque.
286##
287
288#Const kRGB_565_SkColorType 2
289#Line # pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word ##
290#Details RGB_565
291 Stores 16-bit word pixel encoding that contains five bits of blue,
292 six bits of green, and five bits of red.
293##
294
295#Const kARGB_4444_SkColorType 3
296#Line # pixel with 4 bits for alpha, red, green, blue; in 16-bit word ##
297#Details ARGB_4444
298 Stores 16-bit word pixel encoding that contains four bits of alpha,
299 four bits of blue, four bits of green, and four bits of red.
300##
301
302#Const kRGBA_8888_SkColorType 4
303#Line # pixel with 8 bits for red, green, blue, alpha; in 32-bit word ##
304#Details RGBA_8888
305 Stores 32-bit word pixel encoding that contains eight bits of red,
306 eight bits of green, eight bits of blue, and eight bits of alpha.
307##
308
309#Const kRGB_888x_SkColorType 5
310#Line # pixel with 8 bits each for red, green, blue; in 32-bit word ##
311#Details RGB_888
312 Stores 32-bit word pixel encoding that contains eight bits of red,
313 eight bits of green, eight bits of blue, and eight unused bits.
314##
315
316#Const kBGRA_8888_SkColorType 6
317#Line # pixel with 8 bits for blue, green, red, alpha; in 32-bit word ##
318#Details BGRA_8888
319 Stores 32-bit word pixel encoding that contains eight bits of blue,
320 eight bits of green, eight bits of red, and eight bits of alpha.
321##
322
323#Const kRGBA_1010102_SkColorType 7
324#Line # 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word ##
325#Details RGBA_1010102
326 Stores 32-bit word pixel encoding that contains ten bits of red,
327 ten bits of green, ten bits of blue, and two bits of alpha.
328##
329
330#Const kRGB_101010x_SkColorType 8
331#Line # pixel with 10 bits each for red, green, blue; in 32-bit word ##
332#Details RGB_101010
333 Stores 32-bit word pixel encoding that contains ten bits of red,
334 ten bits of green, ten bits of blue, and two unused bits.
335##
336
337#Const kGray_8_SkColorType 9
Cary Clark137b8742018-05-30 09:21:49 -0400338#Line # pixel with Grayscale level in 8-bit byte ##
Cary Clark682c58d2018-05-16 07:07:07 -0400339#Details Gray_8
340 Stores 8-bit byte pixel encoding that equivalent to equal values for red,
341 blue, and green, representing colors from black to white.
342##
343
344#Const kRGBA_F16_SkColorType 10
345#Line # pixel with half floats for red, green, blue, alpha; in 64-bit word ##
346#Details RGBA_F16
347 Stores 64-bit word pixel encoding that contains 16 bits of blue,
Cary Clark224c7002018-06-27 11:00:21 -0400348 16 bits of green, 16 bits of red, and 16 bits of alpha. Each component
349 is encoded as a half float.
Cary Clark682c58d2018-05-16 07:07:07 -0400350##
351
Cary Clark224c7002018-06-27 11:00:21 -0400352#Const kRGBA_F32_SkColorType 11
353#Line # pixel using C float for red, green, blue, alpha; in 128-bit word ##
354#Details RGBA_F32
355 Stores 128-bit word pixel encoding that contains 32 bits of blue,
356 32 bits of green, 32 bits of red, and 32 bits of alpha. Each component
357 is encoded as a single precision float.
358##
359
360#Const kLastEnum_SkColorType 11
Cary Clark682c58d2018-05-16 07:07:07 -0400361#NoJustify
362#Line # last valid value ##
363 Used by tests to iterate through all valid values.
364##
365
366#Const kN32_SkColorType 4 or 6
Cary Clark137b8742018-05-30 09:21:49 -0400367#Alias Native_Color_Type ##
Cary Clark682c58d2018-05-16 07:07:07 -0400368#NoJustify
Cary Clarkffb3d682018-05-17 12:17:28 -0400369#Line # native ARGB 32-bit encoding ##
370 Encodes ARGB as either kRGBA_8888_SkColorType or
Cary Clark682c58d2018-05-16 07:07:07 -0400371 kBGRA_8888_SkColorType, whichever is native to the platform.
Cary Clarkf895a422018-02-27 09:54:21 -0500372##
373
374#NoExample
375##
376
377#SeeAlso SkAlphaType SkColorSpace
378
379#Enum SkColorType ##
380
381#Subtopic Alpha_8
Cary Clark682c58d2018-05-16 07:07:07 -0400382#Line # encodes transparency only ##
383 Alpha pixels encode transparency without color information. Value of zero is
384 completely transparent; a value of 255 is completely opaque. Bitmap
385 pixels do not visibly draw, because its pixels have no color information.
386 When SkColorType is set to kAlpha_8_SkColorType, the paired SkAlphaType is
387 ignored.
Cary Clarkf895a422018-02-27 09:54:21 -0500388
Cary Clark682c58d2018-05-16 07:07:07 -0400389 #Example
390 #Description
391 Alpha pixels can modify another draw. orangePaint fills the bounds of bitmap,
392 with its transparency set to alpha8 pixel value.
393 ##
394 #Height 64
395 canvas->scale(16, 16);
396 SkBitmap bitmap;
397 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kAlpha_8_SkColorType, kOpaque_SkAlphaType);
398 bitmap.allocPixels(imageInfo);
399 SkCanvas offscreen(bitmap);
400 offscreen.clear(SK_ColorGREEN);
401 SkPaint orangePaint;
402 orangePaint.setARGB(0xFF, 0xFF, 0xA5, 0x00);
403 canvas->drawBitmap(bitmap, 0, 0, &orangePaint);
404 uint8_t alpha8[] = { 0xFF, 0xBB, 0x77, 0x33 };
405 SkPixmap alphaPixmap(imageInfo, &alpha8, imageInfo.minRowBytes());
406 if (bitmap.writePixels(alphaPixmap, 0, 0)) {
407 canvas->drawBitmap(bitmap, 2, 2, &orangePaint);
408 }
409 ##
Cary Clarkffb3d682018-05-17 12:17:28 -0400410 #SeeAlso Alpha Gray_8
Cary Clarkf895a422018-02-27 09:54:21 -0500411##
412
Cary Clark682c58d2018-05-16 07:07:07 -0400413#Subtopic RGB_565
Cary Clarkffb3d682018-05-17 12:17:28 -0400414#Line # encodes RGB in 16 bits ##
415 kRGB_565_SkColorType encodes RGB to fit in a 16-bit word. Red and blue
Cary Clark682c58d2018-05-16 07:07:07 -0400416 components use five bits describing 32 levels. Green components, more sensitive
417 to the eye, use six bits describing 64 levels. kRGB_565_SkColorType has no
418 bits for Alpha.
419
420 Pixels are fully opaque as if its Color_Alpha was set to one, and should
421 always be paired with kOpaque_SkAlphaType.
Cary Clarkf895a422018-02-27 09:54:21 -0500422
Cary Clark682c58d2018-05-16 07:07:07 -0400423 #Illustration
Cary Clarkf895a422018-02-27 09:54:21 -0500424
Cary Clark682c58d2018-05-16 07:07:07 -0400425 #Example
426 #Height 96
427 canvas->scale(16, 16);
428 SkBitmap bitmap;
429 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_565_SkColorType, kOpaque_SkAlphaType);
430 bitmap.allocPixels(imageInfo);
431 SkCanvas offscreen(bitmap);
432 offscreen.clear(SK_ColorGREEN);
433 canvas->drawBitmap(bitmap, 0, 0);
434 auto pack565 = [](unsigned r, unsigned g, unsigned b) -> uint16_t {
435 return (b << 0) | (g << 5) | (r << 11);
436 };
437 uint16_t red565[] = { pack565(0x1F, 0x00, 0x00), pack565(0x17, 0x00, 0x00),
438 pack565(0x0F, 0x00, 0x00), pack565(0x07, 0x00, 0x00) };
439 uint16_t blue565[] = { pack565(0x00, 0x00, 0x1F), pack565(0x00, 0x00, 0x17),
440 pack565(0x00, 0x00, 0x0F), pack565(0x00, 0x00, 0x07) };
441 SkPixmap redPixmap(imageInfo, &red565, imageInfo.minRowBytes());
442 if (bitmap.writePixels(redPixmap, 0, 0)) {
443 canvas->drawBitmap(bitmap, 2, 2);
444 }
445 SkPixmap bluePixmap(imageInfo, &blue565, imageInfo.minRowBytes());
446 if (bitmap.writePixels(bluePixmap, 0, 0)) {
447 canvas->drawBitmap(bitmap, 4, 4);
448 }
449 ##
Cary Clarkffb3d682018-05-17 12:17:28 -0400450 #SeeAlso ARGB_4444 RGBA_8888
Cary Clarkf895a422018-02-27 09:54:21 -0500451##
452
Cary Clark682c58d2018-05-16 07:07:07 -0400453#Subtopic ARGB_4444
Cary Clarkffb3d682018-05-17 12:17:28 -0400454#Line # encodes ARGB in 16 bits ##
455 kARGB_4444_SkColorType encodes ARGB to fit in 16-bit word. Each
Cary Clark682c58d2018-05-16 07:07:07 -0400456 component: alpha, blue, green, and red; use four bits, describing 16 levels.
457 Note that kARGB_4444_SkColorType is misnamed; the acronym does not
458 describe the actual component order.
Cary Clarkf895a422018-02-27 09:54:21 -0500459
Cary Clark682c58d2018-05-16 07:07:07 -0400460 #Illustration
Cary Clarkf895a422018-02-27 09:54:21 -0500461
Cary Clark682c58d2018-05-16 07:07:07 -0400462 If paired with kPremul_SkAlphaType: blue, green, and red components are
463 Premultiplied by the alpha value. If blue, green, or red is greater than alpha,
464 the drawn result is undefined.
Cary Clarkf895a422018-02-27 09:54:21 -0500465
Cary Clark682c58d2018-05-16 07:07:07 -0400466 If paired with kUnpremul_SkAlphaType: alpha, blue, green, and red components
467 may have any value. There may be a performance penalty with Unpremultipled
468 pixels.
Cary Clarkf895a422018-02-27 09:54:21 -0500469
Cary Clark682c58d2018-05-16 07:07:07 -0400470 If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum;
471 blue, green, and red components are fully opaque. If any alpha component is
472 less than 15, the drawn result is undefined.
Cary Clarkf895a422018-02-27 09:54:21 -0500473
Cary Clark682c58d2018-05-16 07:07:07 -0400474 #Bug 7648
Cary Clarkf895a422018-02-27 09:54:21 -0500475
Cary Clark682c58d2018-05-16 07:07:07 -0400476 #Example
477 #Height 96
478 canvas->scale(16, 16);
479 SkBitmap bitmap;
480 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kARGB_4444_SkColorType, kPremul_SkAlphaType);
481 bitmap.allocPixels(imageInfo);
482 SkCanvas offscreen(bitmap);
483 offscreen.clear(SK_ColorGREEN);
484 canvas->drawBitmap(bitmap, 0, 0);
485 auto pack4444 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint16_t {
486 return (a << 0) | (b << 4) | (g << 8) | (r << 12);
487 };
488 uint16_t red4444[] = { pack4444(0xF, 0xF, 0x0, 0x0), pack4444(0xF, 0xb, 0x0, 0x0),
489 pack4444(0xF, 0x7, 0x0, 0x0), pack4444(0xF, 0x3, 0x0, 0x0) };
490 uint16_t blue4444[] = { pack4444(0xF, 0x0, 0x0, 0xF), pack4444(0xF, 0x0, 0x0, 0xb),
491 pack4444(0xF, 0x0, 0x0, 0x7), pack4444(0xF, 0x0, 0x0, 0x3) };
492 SkPixmap redPixmap(imageInfo, &red4444, imageInfo.minRowBytes());
493 if (bitmap.writePixels(redPixmap, 0, 0)) {
494 canvas->drawBitmap(bitmap, 2, 2);
495 }
496 SkPixmap bluePixmap(imageInfo, &blue4444, imageInfo.minRowBytes());
497 if (bitmap.writePixels(bluePixmap, 0, 0)) {
498 canvas->drawBitmap(bitmap, 4, 4);
499 }
500 ##
Cary Clarkffb3d682018-05-17 12:17:28 -0400501 #SeeAlso RGBA_8888
Cary Clarkf895a422018-02-27 09:54:21 -0500502##
503
504#Subtopic RGBA_8888
Cary Clarkffb3d682018-05-17 12:17:28 -0400505#Line # encodes ARGB Big_Endian in 32 bits ##
506 kRGBA_8888_SkColorType encodes ARGB into a 32-bit word. Each component:
Cary Clark682c58d2018-05-16 07:07:07 -0400507 red, green, blue, alpha; use eight bits, describing 256 levels.
Cary Clarkf895a422018-02-27 09:54:21 -0500508
Cary Clark682c58d2018-05-16 07:07:07 -0400509 #Illustration
Cary Clarkf895a422018-02-27 09:54:21 -0500510
Cary Clark682c58d2018-05-16 07:07:07 -0400511 If paired with kPremul_SkAlphaType: red, green, and blue components are
512 Premultiplied by the alpha value. If red, green, or blue is greater than alpha,
513 the drawn result is undefined.
Cary Clarkf895a422018-02-27 09:54:21 -0500514
Cary Clark682c58d2018-05-16 07:07:07 -0400515 If paired with kUnpremul_SkAlphaType: alpha, red, green, and blue components
516 may have any value. There may be a performance penalty with Unpremultipled
517 pixels.
Cary Clarkf895a422018-02-27 09:54:21 -0500518
Cary Clark682c58d2018-05-16 07:07:07 -0400519 If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum;
520 red, green, and blue components are fully opaque. If any alpha component is
521 less than 255, the drawn result is undefined.
Cary Clarkf895a422018-02-27 09:54:21 -0500522
Cary Clark682c58d2018-05-16 07:07:07 -0400523 On Big_Endian platforms, kRGBA_8888_SkColorType is the native Color_Type, and
524 will have the best performance. Use kN32_SkColorType to choose the best
525 Color_Type for the platform at compile time.
Cary Clarkf895a422018-02-27 09:54:21 -0500526
Cary Clark682c58d2018-05-16 07:07:07 -0400527 #Example
528 #Height 96
529 canvas->scale(16, 16);
530 SkBitmap bitmap;
531 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
532 bitmap.allocPixels(imageInfo);
533 SkCanvas offscreen(bitmap);
534 offscreen.clear(SK_ColorGREEN);
535 canvas->drawBitmap(bitmap, 0, 0);
536 auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t {
537 return (r << 0) | (g << 8) | (b << 16) | (a << 24);
538 };
539 uint32_t red8888[] = { pack8888(0xFF, 0xFF, 0x0, 0x0), pack8888(0xFF, 0xbb, 0x0, 0x0),
540 pack8888(0xFF, 0x77, 0x0, 0x0), pack8888(0xFF, 0x33, 0x0, 0x0) };
541 uint32_t blue8888[] = { pack8888(0xFF, 0x0, 0x0, 0x0FF), pack8888(0xFF, 0x0, 0x0, 0x0bb),
542 pack8888(0xFF, 0x0, 0x0, 0x077), pack8888(0xFF, 0x0, 0x0, 0x033) };
543 SkPixmap redPixmap(imageInfo, &red8888, imageInfo.minRowBytes());
544 if (bitmap.writePixels(redPixmap, 0, 0)) {
545 canvas->drawBitmap(bitmap, 2, 2);
546 }
547 SkPixmap bluePixmap(imageInfo, &blue8888, imageInfo.minRowBytes());
548 if (bitmap.writePixels(bluePixmap, 0, 0)) {
549 canvas->drawBitmap(bitmap, 4, 4);
550 }
551 ##
Cary Clarkffb3d682018-05-17 12:17:28 -0400552 #SeeAlso RGB_888 BGRA_8888
Cary Clarkf895a422018-02-27 09:54:21 -0500553##
554
Cary Clark682c58d2018-05-16 07:07:07 -0400555#Subtopic RGB_888
Cary Clarkffb3d682018-05-17 12:17:28 -0400556#Line # encodes RGB in 32 bits ##
557 kRGB_888x_SkColorType encodes RGB into a 32-bit word. Each component:
Cary Clark682c58d2018-05-16 07:07:07 -0400558 red, green, blue; use eight bits, describing 256 levels. Eight bits are
559 unused. Pixels described by kRGB_888x_SkColorType are fully opaque as if
560 their Color_Alpha was set to one, and should always be paired with
561 kOpaque_SkAlphaType.
Cary Clarkf895a422018-02-27 09:54:21 -0500562
Cary Clark682c58d2018-05-16 07:07:07 -0400563 #Illustration
Cary Clarkf895a422018-02-27 09:54:21 -0500564
Cary Clark682c58d2018-05-16 07:07:07 -0400565 #Example
566 #Bug 7645
567 #Height 96
568 #Platform cpu
569 canvas->scale(16, 16);
570 SkBitmap bitmap;
571 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_888x_SkColorType, kOpaque_SkAlphaType);
572 bitmap.allocPixels(imageInfo);
573 SkCanvas offscreen(bitmap);
574 offscreen.clear(SK_ColorGREEN);
575 canvas->drawBitmap(bitmap, 0, 0);
576 auto pack888 = [](unsigned r, unsigned g, unsigned b) -> uint32_t {
577 return (r << 0) | (g << 8) | (b << 16);
578 };
579 uint32_t red888[] = { pack888(0xFF, 0x00, 0x00), pack888(0xbb, 0x00, 0x00),
580 pack888(0x77, 0x00, 0x00), pack888(0x33, 0x00, 0x00) };
581 uint32_t blue888[] = { pack888(0x00, 0x00, 0xFF), pack888(0x00, 0x00, 0xbb),
582 pack888(0x00, 0x00, 0x77), pack888(0x00, 0x00, 0x33) };
583 if (bitmap.installPixels(imageInfo, (void*) red888, imageInfo.minRowBytes())) {
584 canvas->drawBitmap(bitmap, 2, 2);
585 }
586 if (bitmap.installPixels(imageInfo, (void*) blue888, imageInfo.minRowBytes())) {
587 canvas->drawBitmap(bitmap, 4, 4);
588 }
589 ##
Cary Clarkffb3d682018-05-17 12:17:28 -0400590 #SeeAlso RGBA_8888 BGRA_8888
Cary Clarkf895a422018-02-27 09:54:21 -0500591##
592
593#Subtopic BGRA_8888
Cary Clarkffb3d682018-05-17 12:17:28 -0400594#Line # encodes ARGB Little_Endian in 32 bits ##
595 kBGRA_8888_SkColorType encodes ARGB into a 32-bit word. Each component:
Cary Clark682c58d2018-05-16 07:07:07 -0400596 blue, green, red, and alpha; use eight bits, describing 256 levels.
Cary Clarkf895a422018-02-27 09:54:21 -0500597
Cary Clark682c58d2018-05-16 07:07:07 -0400598 #Illustration
Cary Clarkf895a422018-02-27 09:54:21 -0500599
Cary Clark682c58d2018-05-16 07:07:07 -0400600 If paired with kPremul_SkAlphaType: blue, green, and red components are
601 Premultiplied by the alpha value. If blue, green, or red is greater than alpha,
602 the drawn result is undefined.
Cary Clarkf895a422018-02-27 09:54:21 -0500603
Cary Clark682c58d2018-05-16 07:07:07 -0400604 If paired with kUnpremul_SkAlphaType: blue, green, red, and alpha components
605 may have any value. There may be a performance penalty with Unpremultiplied
606 pixels.
Cary Clarkf895a422018-02-27 09:54:21 -0500607
Cary Clark682c58d2018-05-16 07:07:07 -0400608 If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum;
609 blue, green, and red components are fully opaque. If any alpha component is
610 less than 255, the drawn result is undefined.
Cary Clarkf895a422018-02-27 09:54:21 -0500611
Cary Clark682c58d2018-05-16 07:07:07 -0400612 On Little_Endian platforms, kBGRA_8888_SkColorType is the native Color_Type,
613 and will have the best performance. Use kN32_SkColorType to choose the best
614 Color_Type for the platform at compile time.
Cary Clarkf895a422018-02-27 09:54:21 -0500615
Cary Clark682c58d2018-05-16 07:07:07 -0400616 #Example
617 #Height 96
618 canvas->scale(16, 16);
619 SkBitmap bitmap;
620 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
621 bitmap.allocPixels(imageInfo);
622 SkCanvas offscreen(bitmap);
623 offscreen.clear(SK_ColorGREEN);
624 canvas->drawBitmap(bitmap, 0, 0);
625 auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t {
626 return (b << 0) | (g << 8) | (r << 16) | (a << 24);
627 };
628 uint32_t red8888[] = { pack8888(0xFF, 0xFF, 0x0, 0x0), pack8888(0xFF, 0xbb, 0x0, 0x0),
629 pack8888(0xFF, 0x99, 0x0, 0x0), pack8888(0xFF, 0x55, 0x0, 0x0) };
630 uint32_t blue8888[] = { pack8888(0xFF, 0x0, 0x0, 0x0FF), pack8888(0xFF, 0x0, 0x0, 0x0bb),
631 pack8888(0xFF, 0x0, 0x0, 0x099), pack8888(0xFF, 0x0, 0x0, 0x055) };
632 SkPixmap redPixmap(imageInfo, &red8888, imageInfo.minRowBytes());
633 if (bitmap.writePixels(redPixmap, 0, 0)) {
634 canvas->drawBitmap(bitmap, 2, 2);
635 }
636 SkPixmap bluePixmap(imageInfo, &blue8888, imageInfo.minRowBytes());
637 if (bitmap.writePixels(bluePixmap, 0, 0)) {
638 canvas->drawBitmap(bitmap, 4, 4);
639 }
640 ##
641 #SeeAlso RGBA_8888
Cary Clarkf895a422018-02-27 09:54:21 -0500642##
643
644#Subtopic RGBA_1010102
Cary Clarkffb3d682018-05-17 12:17:28 -0400645#Line # encodes ARGB ten bits per color component ##
646 kRGBA_1010102_SkColorType encodes ARGB into a 32-bit word. Each
Cary Clark682c58d2018-05-16 07:07:07 -0400647 Color component: red, green, and blue; use ten bits, describing 1024 levels.
648 Two bits contain alpha, describing four levels. Possible alpha
649 values are zero: fully transparent; one: 33% opaque; two: 67% opaque;
650 three: fully opaque.
Cary Clarkf895a422018-02-27 09:54:21 -0500651
Cary Clark682c58d2018-05-16 07:07:07 -0400652 At present, Color in Paint does not provide enough precision to
653 draw all colors possible to a kRGBA_1010102_SkColorType Surface.
Cary Clarkf895a422018-02-27 09:54:21 -0500654
Cary Clark682c58d2018-05-16 07:07:07 -0400655 #Illustration
Cary Clarkf895a422018-02-27 09:54:21 -0500656
Cary Clark682c58d2018-05-16 07:07:07 -0400657 If paired with kPremul_SkAlphaType: red, green, and blue components are
658 Premultiplied by the alpha value. If red, green, or blue is greater than the
659 alpha replicated to ten bits, the drawn result is undefined.
Cary Clarkf895a422018-02-27 09:54:21 -0500660
Cary Clark682c58d2018-05-16 07:07:07 -0400661 If paired with kUnpremul_SkAlphaType: alpha, red, green, and blue components
662 may have any value. There may be a performance penalty with Unpremultiplied
663 pixels.
Cary Clarkf895a422018-02-27 09:54:21 -0500664
Cary Clark682c58d2018-05-16 07:07:07 -0400665 If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum;
666 red, green, and blue components are fully opaque. If any alpha component is
667 less than three, the drawn result is undefined.
Cary Clarkf895a422018-02-27 09:54:21 -0500668
Cary Clark682c58d2018-05-16 07:07:07 -0400669 #Example
670 #Bug 7645
671 #Height 96
672 #Platform cpu
673 canvas->scale(16, 16);
674 SkBitmap bitmap;
675 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_1010102_SkColorType, kOpaque_SkAlphaType);
676 bitmap.allocPixels(imageInfo);
677 SkCanvas offscreen(bitmap);
678 offscreen.clear(SK_ColorGREEN);
679 canvas->drawBitmap(bitmap, 0, 0);
680 auto pack1010102 = [](unsigned r, unsigned g, unsigned b, unsigned a) -> uint32_t {
681 return (r << 0) | (g << 10) | (b << 20) | (a << 30);
682 };
683 uint32_t redBits[] = { pack1010102(0x3FF, 0x000, 0x000, 0x3),
684 pack1010102(0x2ff, 0x000, 0x000, 0x3),
685 pack1010102(0x1ff, 0x000, 0x000, 0x3),
686 pack1010102(0x0ff, 0x000, 0x000, 0x3) };
687 uint32_t blueBits[] = { pack1010102(0x000, 0x000, 0x3FF, 0x3),
688 pack1010102(0x000, 0x000, 0x2ff, 0x3),
689 pack1010102(0x000, 0x000, 0x1ff, 0x3),
690 pack1010102(0x000, 0x000, 0x0ff, 0x3) };
691 if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) {
692 canvas->drawBitmap(bitmap, 2, 2);
693 }
694 SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes());
695 if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) {
696 canvas->drawBitmap(bitmap, 4, 4);
697 }
698 ##
Cary Clarkffb3d682018-05-17 12:17:28 -0400699 #SeeAlso RGB_101010 RGBA_8888
Cary Clarkf895a422018-02-27 09:54:21 -0500700##
701
Cary Clark682c58d2018-05-16 07:07:07 -0400702#Subtopic RGB_101010
Cary Clarkffb3d682018-05-17 12:17:28 -0400703#Line # encodes RGB ten bits per color component ##
704 kRGB_101010x_SkColorType encodes RGB into a 32-bit word. Each
Cary Clark682c58d2018-05-16 07:07:07 -0400705 Color component: red, green, and blue; use ten bits, describing 1024 levels.
706 Two bits are unused. Pixels described by kRGB_101010x_SkColorType are fully
707 opaque as if its Color_Alpha was set to one, and should always be paired
708 with kOpaque_SkAlphaType.
Cary Clarkf895a422018-02-27 09:54:21 -0500709
Cary Clark682c58d2018-05-16 07:07:07 -0400710 At present, Color in Paint does not provide enough precision to
711 draw all colors possible to a kRGB_101010x_SkColorType Surface.
Cary Clark681287e2018-03-16 11:34:15 -0400712
Cary Clark682c58d2018-05-16 07:07:07 -0400713 #Illustration
Cary Clarkf895a422018-02-27 09:54:21 -0500714
Cary Clark682c58d2018-05-16 07:07:07 -0400715 #Example
716 #Bug 7645
717 #Height 96
718 #Platform cpu
719 canvas->scale(16, 16);
720 SkBitmap bitmap;
721 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_101010x_SkColorType, kOpaque_SkAlphaType);
722 bitmap.allocPixels(imageInfo);
723 SkCanvas offscreen(bitmap);
724 offscreen.clear(SK_ColorGREEN);
725 canvas->drawBitmap(bitmap, 0, 0);
726 auto pack101010x = [](unsigned r, unsigned g, unsigned b) -> uint32_t {
727 return (r << 0) | (g << 10) | (b << 20);
728 };
729 uint32_t redBits[] = { pack101010x(0x3FF, 0x000, 0x000), pack101010x(0x2ff, 0x000, 0x000),
730 pack101010x(0x1ff, 0x000, 0x000), pack101010x(0x0ff, 0x000, 0x000) };
731 uint32_t blueBits[] = { pack101010x(0x000, 0x000, 0x3FF), pack101010x(0x000, 0x000, 0x2ff),
732 pack101010x(0x000, 0x000, 0x1ff), pack101010x(0x000, 0x000, 0x0ff) };
733 if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) {
734 canvas->drawBitmap(bitmap, 2, 2);
735 }
736 SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes());
737 if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) {
738 canvas->drawBitmap(bitmap, 4, 4);
739 }
740 ##
Cary Clarkffb3d682018-05-17 12:17:28 -0400741 #SeeAlso RGBA_1010102
Cary Clarkf895a422018-02-27 09:54:21 -0500742##
743
744#Subtopic Gray_8
Cary Clark137b8742018-05-30 09:21:49 -0400745#Line # encodes level of Grayscale in 8 bits ##
746 kGray_8_SkColorType encodes Grayscale level in eight bits that is equivalent
Cary Clark682c58d2018-05-16 07:07:07 -0400747 to equal values for red, blue, and green, representing colors from black to
748 white. Pixels described by kGray_8_SkColorType are fully
749 opaque as if its Color_Alpha was set to one, and should always be paired with
750 kOpaque_SkAlphaType.
Cary Clarkf895a422018-02-27 09:54:21 -0500751
Cary Clark682c58d2018-05-16 07:07:07 -0400752 #Example
753 #Height 64
754 canvas->scale(16, 16);
755 SkBitmap bitmap;
756 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kGray_8_SkColorType, kOpaque_SkAlphaType);
757 bitmap.allocPixels(imageInfo);
758 SkCanvas offscreen(bitmap);
759 offscreen.clear(SK_ColorGREEN);
760 canvas->drawBitmap(bitmap, 0, 0);
761 uint8_t gray8[] = { 0xFF, 0xBB, 0x77, 0x33 };
762 SkPixmap grayPixmap(imageInfo, &gray8, imageInfo.minRowBytes());
763 if (bitmap.writePixels(grayPixmap, 0, 0)) {
764 canvas->drawBitmap(bitmap, 2, 2);
765 }
766 ##
Cary Clarkffb3d682018-05-17 12:17:28 -0400767 #SeeAlso Alpha_8
Cary Clarkf895a422018-02-27 09:54:21 -0500768##
769
770#Subtopic RGBA_F16
Cary Clarkffb3d682018-05-17 12:17:28 -0400771#Line # encodes ARGB as half floats ##
772 kRGBA_F16_SkColorType encodes ARGB into a 64-bit word. Each component:
Cary Clark224c7002018-06-27 11:00:21 -0400773 blue, green, red, and alpha; use 16 bits, describing a floating point value,
Cary Clark929e4362018-06-19 09:07:28 -0400774 from -65500 to 65000 with 3.31 decimal digits of precision.
Cary Clarkf895a422018-02-27 09:54:21 -0500775
Cary Clark682c58d2018-05-16 07:07:07 -0400776 At present, Color in Paint does not provide enough precision or range to
777 draw all colors possible to a kRGBA_F16_SkColorType Surface.
Cary Clark681287e2018-03-16 11:34:15 -0400778
Cary Clark682c58d2018-05-16 07:07:07 -0400779 Each component encodes a floating point value using
780 #A Half floats # https://www.khronos.org/opengl/wiki/Small_Float_Formats ##
781 . Meaningful colors are represented by the range 0.0 to 1.0, although smaller
782 and larger values may be useful when used in combination with Transfer_Mode.
Cary Clark681287e2018-03-16 11:34:15 -0400783
Cary Clark682c58d2018-05-16 07:07:07 -0400784 #Illustration
Cary Clarkf895a422018-02-27 09:54:21 -0500785
Cary Clark682c58d2018-05-16 07:07:07 -0400786 If paired with kPremul_SkAlphaType: blue, green, and red components are
787 Premultiplied by the alpha value. If blue, green, or red is greater than alpha,
788 the drawn result is undefined.
Cary Clark681287e2018-03-16 11:34:15 -0400789
Cary Clark682c58d2018-05-16 07:07:07 -0400790 If paired with kUnpremul_SkAlphaType: blue, green, red, and alpha components
791 may have any value. There may be a performance penalty with Unpremultiplied
792 pixels.
Cary Clark681287e2018-03-16 11:34:15 -0400793
Cary Clark682c58d2018-05-16 07:07:07 -0400794 If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum;
795 blue, green, and red components are fully opaque. If any alpha component is
Cary Clark224c7002018-06-27 11:00:21 -0400796 less than one, the drawn result is undefined.
Cary Clark681287e2018-03-16 11:34:15 -0400797
Cary Clark682c58d2018-05-16 07:07:07 -0400798 #ToDo
799 FloatToHalf should be replaced with SkFloatToHalf if/when that's made public
800 ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500801
Cary Clark682c58d2018-05-16 07:07:07 -0400802 #Example
803 #Height 96
804 #Function
805 union FloatUIntUnion {
806 uint32_t fUInt;
807 float fFloat;
Cary Clarkf895a422018-02-27 09:54:21 -0500808 };
Cary Clark682c58d2018-05-16 07:07:07 -0400809
810 uint16_t FloatToHalf(float f) {
811 static const FloatUIntUnion magic = { 15 << 23 };
812 static const uint32_t round_mask = ~0xfffu;
813 FloatUIntUnion floatUnion;
814 floatUnion.fFloat = f;
815 uint32_t sign = floatUnion.fUInt & 0x80000000u;
816 floatUnion.fUInt ^= sign;
817 floatUnion.fUInt &= round_mask;
818 floatUnion.fFloat *= magic.fFloat;
819 floatUnion.fUInt -= round_mask;
820 return (floatUnion.fUInt >> 13) | (sign >> 16);
Cary Clarkf895a422018-02-27 09:54:21 -0500821 }
Cary Clark682c58d2018-05-16 07:07:07 -0400822 ##
823
824 void draw(SkCanvas* canvas) {
825 canvas->scale(16, 16);
826 SkBitmap bitmap;
827 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_F16_SkColorType, kPremul_SkAlphaType);
828 bitmap.allocPixels(imageInfo);
829 SkCanvas offscreen(bitmap);
830 offscreen.clear(SK_ColorGREEN);
831 canvas->drawBitmap(bitmap, 0, 0);
832 auto H = [](float c) -> uint16_t {
833 return FloatToHalf(c);
834 };
835 // R G B A
Cary Clark224c7002018-06-27 11:00:21 -0400836 uint16_t red_f16[][4] = { { H(1.0), H(0.0), H(0.0), H(1.0) },
837 { H(.75), H(0.0), H(0.0), H(1.0) },
838 { H(.50), H(0.0), H(0.0), H(1.0) },
839 { H(.25), H(0.0), H(0.0), H(1.0) } };
840 uint16_t blue_f16[][4] = { { H(0.0), H(0.0), H(1.0), H(1.0) },
841 { H(0.0), H(0.0), H(.75), H(1.0) },
842 { H(0.0), H(0.0), H(.50), H(1.0) },
843 { H(0.0), H(0.0), H(.25), H(1.0) } };
Cary Clark682c58d2018-05-16 07:07:07 -0400844 SkPixmap redPixmap(imageInfo, red_f16, imageInfo.minRowBytes());
845 if (bitmap.writePixels(redPixmap, 0, 0)) {
846 canvas->drawBitmap(bitmap, 2, 2);
847 }
848 SkPixmap bluePixmap(imageInfo, blue_f16, imageInfo.minRowBytes());
849 if (bitmap.writePixels(bluePixmap, 0, 0)) {
850 canvas->drawBitmap(bitmap, 4, 4);
851 }
Cary Clarkf895a422018-02-27 09:54:21 -0500852 }
Cary Clark682c58d2018-05-16 07:07:07 -0400853 ##
Cary Clarkffb3d682018-05-17 12:17:28 -0400854 #SeeAlso SkColor4f
Cary Clarkf895a422018-02-27 09:54:21 -0500855##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500856
Cary Clark224c7002018-06-27 11:00:21 -0400857#Subtopic RGBA_F32
858#Line # encodes ARGB as single precision floats ##
859 kRGBA_F32_SkColorType encodes ARGB into a 128-bit word. Each component:
860 blue, green, red, and alpha; use 32 bits, describing a floating point value,
861 from -3.402823e+38 to 3.402823e+38 with 7.225 decimal digits of precision.
862
863 At present, Color in Paint does not provide enough precision or range to
864 draw all colors possible to a kRGBA_F32_SkColorType Surface.
865
866 Each component encodes a floating point value using
867 #A single-precision floats # https://en.wikipedia.org/wiki/Single-precision_floating-point_format ##
868 . Meaningful colors are represented by the range 0.0 to 1.0, although smaller
869 and larger values may be useful when used in combination with Transfer_Mode.
870
871 #Illustration
872
873 If paired with kPremul_SkAlphaType: blue, green, and red components are
874 Premultiplied by the alpha value. If blue, green, or red is greater than alpha,
875 the drawn result is undefined.
876
877 If paired with kUnpremul_SkAlphaType: blue, green, red, and alpha components
878 may have any value. There may be a performance penalty with Unpremultiplied
879 pixels.
880
881 If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum;
882 blue, green, and red components are fully opaque. If any alpha component is
883 less than one, the drawn result is undefined.
884
885 #NoExample
886 canvas->scale(16, 16);
887 SkBitmap bitmap;
888 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_F32_SkColorType, kPremul_SkAlphaType);
889 bitmap.allocPixels(imageInfo);
890 SkCanvas offscreen(bitmap);
891 offscreen.clear(SK_ColorGREEN);
892 canvas->drawBitmap(bitmap, 0, 0);
893 // R G B A
894 float red_f32[][4] = { { 1.0, 0.0, 0.0, 1.0 },
895 { .75, 0.0, 0.0, 1.0 },
896 { .50, 0.0, 0.0, 1.0 },
897 { .25, 0.0, 0.0, 1.0 } };
898 float blue_f32[][4] = { { 0.0, 0.0, 1.0, 1.0 },
899 { 0.0, 0.0, .75, 1.0 },
900 { 0.0, 0.0, .50, 1.0 },
901 { 0.0, 0.0, .25, 1.0 } };
902 SkPixmap redPixmap(imageInfo, red_f32, imageInfo.minRowBytes());
903 if (bitmap.writePixels(redPixmap, 0, 0)) {
904 canvas->drawBitmap(bitmap, 2, 2);
905 }
906 SkPixmap bluePixmap(imageInfo, blue_f32, imageInfo.minRowBytes());
907 if (bitmap.writePixels(bluePixmap, 0, 0)) {
908 canvas->drawBitmap(bitmap, 4, 4);
909 }
910 ##
911 #SeeAlso SkColor4f
912##
913
914
Cary Clark08895c42018-02-01 09:37:32 -0500915#Subtopic Color_Type ##
Cary Clark2dc84ad2018-01-26 12:56:22 -0500916
917# ------------------------------------------------------------------------------
Cary Clark681287e2018-03-16 11:34:15 -0400918
919#Method int SkColorTypeBytesPerPixel(SkColorType ct)
920#In Property
921#Line # returns Color_Type byte size ##
922
923Returns the number of bytes required to store a pixel, including unused padding.
924Returns zero if ct is kUnknown_SkColorType or invalid.
925
926#Param ct one of: #list_of_color_types#
927##
928
929#Return bytes per pixel ##
930
931#Example
932#Height 192
933 const char* colors[] = { "Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
934 "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16" };
935 SkPaint paint;
936 paint.setTypeface(SkTypeface::MakeFromName("monospace", SkFontStyle()));
937 paint.setAntiAlias(true);
938 paint.setTextSize(10);
939 int y = 15;
940 canvas->drawString(" colorType bytes", 10, y, paint);
941 for (SkColorType colorType : { #list_of_color_types#
942 } ) {
943 int result = SkColorTypeBytesPerPixel(colorType);
944 SkString string;
945 string.printf("%13s %4d", colors[(int) colorType], result);
946 canvas->drawString(string, 10, y += 14, paint);
947 }
948##
949#SeeAlso SkImageInfo::bytesPerPixel
950##
951
952# ------------------------------------------------------------------------------
953
954#Method bool SkColorTypeIsAlwaysOpaque(SkColorType ct)
955#In Property
956#Line # returns if Color_Type includes Color_Alpha ##
957
958Returns true if Color_Type always decodes Color_Alpha to 1.0, making the pixel
959fully opaque. If true, Color_Type does not reserve bits to encode Color_Alpha.
960
961#Param ct one of: #list_of_color_types#
962##
963
964#Return true if Color_Alpha is always set to 1.0 ##
965
966#Example
967#Height 192
968 const char* colors[] = { "Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
969 "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16" };
970 SkPaint paint;
971 paint.setTypeface(SkTypeface::MakeFromName("monospace", SkFontStyle()));
972 paint.setAntiAlias(true);
973 paint.setTextSize(10);
974 int y = 15;
975 canvas->drawString(" colorType bytes", 10, y, paint);
976 for (SkColorType colorType : { #list_of_color_types#
977 } ) {
978 bool result = SkColorTypeIsAlwaysOpaque(colorType);
979 SkString string;
980 string.printf("%13s %6s", colors[(int) colorType], result ? "true" : "false");
981 canvas->drawString(string, 10, y += 14, paint);
982 }
983##
984#SeeAlso SkColorTypeValidateAlphaType
985##
986
987# ------------------------------------------------------------------------------
988
989#Method bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType,
990 SkAlphaType* canonical = nullptr)
991#In Property
992#Line # returns if Alpha_Type is valid ##
993
994Returns true if canonical can be set to a valid Alpha_Type for colorType. If
995there is more than one valid canonical Alpha_Type, set to alphaType, if valid.
996If true is returned and canonical is not nullptr, store valid Alpha_Type.
997
998Returns false only if alphaType is kUnknown_SkAlphaType, color type is not
999kUnknown_SkColorType, and Color_Type is not always opaque. If false is returned,
1000canonical is ignored.
1001
1002For kUnknown_SkColorType: set canonical to kUnknown_SkAlphaType and return true.
Cary Clark682c58d2018-05-16 07:07:07 -04001003For kAlpha_8_SkColorType: set canonical to kPremul_SkAlphaType or
Cary Clark681287e2018-03-16 11:34:15 -04001004kOpaque_SkAlphaType and return true if alphaType is not kUnknown_SkAlphaType.
1005For kRGB_565_SkColorType, kRGB_888x_SkColorType, kRGB_101010x_SkColorType, and
1006kGray_8_SkColorType: set canonical to kOpaque_SkAlphaType and return true.
1007For kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kBGRA_8888_SkColorType,
1008kRGBA_1010102_SkColorType, and kRGBA_F16_SkColorType: set canonical to alphaType
1009and return true if alphaType is not kUnknown_SkAlphaType.
1010
1011#Param colorType one of: #list_of_color_types#
1012##
1013#Param alphaType one of: #list_of_alpha_types#
1014##
1015#Param canonical storage for Alpha_Type ##
1016
1017#Return true if valid Alpha_Type can be associated with colorType ##
1018
1019#Example
1020#Height 640
1021 const char* colors[] = { "Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
1022 "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16" };
1023 const char* alphas[] = {"Unknown ", "Opaque ", "Premul ", "Unpremul"};
1024 SkAlphaType alphaTypes[] = { #list_of_alpha_types#
1025 };
1026 SkPaint paint;
1027 paint.setTypeface(SkTypeface::MakeFromName("monospace", SkFontStyle()));
1028 paint.setAntiAlias(true);
1029 paint.setTextSize(10);
1030 int y = 15;
1031 canvas->drawString(" colorType alphaType canonical", 10, y, paint);
1032 for (SkColorType colorType : { #list_of_color_types#
1033 } ) {
1034 for (SkAlphaType alphaType : alphaTypes) {
1035 SkAlphaType canonicalAlphaType = kUnknown_SkAlphaType;
1036 bool result = SkColorTypeValidateAlphaType(colorType, alphaType, &canonicalAlphaType);
1037 SkString string;
1038 string.printf("%13s %10s %10s", colors[(int) colorType], alphas[(int) alphaType],
1039 result ? alphas[(int) canonicalAlphaType] : "------ ");
1040 canvas->drawString(string, 10, y += 14, paint);
1041 }
1042 }
1043##
1044#SeeAlso SkColorTypeIsAlwaysOpaque
1045##
1046
1047# ------------------------------------------------------------------------------
Cary Clark772953472018-02-12 09:38:08 -05001048#Subtopic YUV_ColorSpace
Cary Clark682c58d2018-05-16 07:07:07 -04001049#Line # color range of YUV pixels ##
Cary Clark137b8742018-05-30 09:21:49 -04001050#Alias YUV_ColorSpace ##
1051
Cary Clark2dc84ad2018-01-26 12:56:22 -05001052#Enum SkYUVColorSpace
Cary Clark06c20f32018-03-20 15:53:27 -04001053#Line # color range of YUV pixels ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001054
1055#Code
1056 enum SkYUVColorSpace {
1057 kJPEG_SkYUVColorSpace,
1058 kRec601_SkYUVColorSpace,
1059 kRec709_SkYUVColorSpace,
1060 kLastEnum_SkYUVColorSpace = kRec709_SkYUVColorSpace,
1061 };
1062##
1063
Cary Clark06c20f32018-03-20 15:53:27 -04001064Describes color range of YUV pixels. The color mapping from YUV to RGB varies
1065depending on the source. YUV pixels may be generated by JPEG images, standard
1066video streams, or high definition video streams. Each has its own mapping from
1067YUV and RGB.
1068
1069JPEG YUV values encode the full range of 0 to 255 for all three components.
1070Video YUV values range from 16 to 235 for all three components. Details of
Cary Clark682c58d2018-05-16 07:07:07 -04001071encoding and conversion to RGB are described in
Cary Clark06c20f32018-03-20 15:53:27 -04001072#A YCbCr color space # https://en.wikipedia.org/wiki/YCbCr ##
1073.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001074
1075#Const kJPEG_SkYUVColorSpace 0
Cary Clark682c58d2018-05-16 07:07:07 -04001076#Line # describes full range ##
1077Describes standard JPEG color space;
Cary Clark06c20f32018-03-20 15:53:27 -04001078#A CCIR 601 # https://en.wikipedia.org/wiki/Rec._601 ##
1079with full range of 0 to 255 for components.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001080##
1081#Const kRec601_SkYUVColorSpace 1
Cary Clark682c58d2018-05-16 07:07:07 -04001082#Line # describes SDTV range ##
1083Describes standard used by standard definition television;
Cary Clark06c20f32018-03-20 15:53:27 -04001084#A CCIR 601 # https://en.wikipedia.org/wiki/Rec._601 ##
1085with studio range of 16 to 235 range for components.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001086##
1087#Const kRec709_SkYUVColorSpace 2
Cary Clark682c58d2018-05-16 07:07:07 -04001088#Line # describes HDTV range ##
1089Describes standard used by high definition television;
1090#A Rec. 709 # https://en.wikipedia.org/wiki/Rec._709 ##
Cary Clark06c20f32018-03-20 15:53:27 -04001091with studio range of 16 to 235 range for components.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001092##
Cary Clark682c58d2018-05-16 07:07:07 -04001093#Const kLastEnum_SkYUVColorSpace 2
1094#Line # last valid value ##
1095 Used by tests to iterate through all valid values.
1096##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001097
Cary Clark06c20f32018-03-20 15:53:27 -04001098#NoExample
Cary Clark2dc84ad2018-01-26 12:56:22 -05001099##
1100
Cary Clark06c20f32018-03-20 15:53:27 -04001101#SeeAlso SkImage::MakeFromYUVTexturesCopy SkImage::MakeFromNV12TexturesCopy
Cary Clark2dc84ad2018-01-26 12:56:22 -05001102
1103#Enum SkYUVColorSpace ##
Cary Clark772953472018-02-12 09:38:08 -05001104#Subtopic YUV_ColorSpace ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001105
1106# ------------------------------------------------------------------------------
Cary Clark2dc84ad2018-01-26 12:56:22 -05001107
1108#Struct SkImageInfo
1109
Cary Clark682c58d2018-05-16 07:07:07 -04001110Describes pixel dimensions and encoding. Bitmap, Image, PixMap, and Surface
Cary Clark1a8d7622018-03-05 13:26:16 -05001111can be created from Image_Info. Image_Info can be retrieved from Bitmap and
1112Pixmap, but not from Image and Surface. For example, Image and Surface
1113implementations may defer pixel depth, so may not completely specify Image_Info.
1114
1115Image_Info contains dimensions, the pixel integral width and height. It encodes
1116how pixel bits describe Color_Alpha, transparency; Color components red, blue,
1117and green; and Color_Space, the range and linearity of colors.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001118
Cary Clark4855f782018-02-06 09:41:53 -05001119#Subtopic Member_Function
Cary Clark08895c42018-02-01 09:37:32 -05001120#Populate
1121##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001122
Cary Clark78de7512018-02-07 07:27:09 -05001123#Subtopic Related_Function
Cary Clark08895c42018-02-01 09:37:32 -05001124#Populate
1125##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001126
1127# ------------------------------------------------------------------------------
Cary Clark78de7512018-02-07 07:27:09 -05001128#Subtopic Constructor
1129#Populate
1130##
1131
Cary Clark2dc84ad2018-01-26 12:56:22 -05001132#Method SkImageInfo()
1133
Cary Clark4855f782018-02-06 09:41:53 -05001134#In Constructor
Cary Clark82f1f742018-06-28 08:50:35 -04001135#Line # creates with zeroed dimensions, kUnknown_SkColorType, kUnknown_SkAlphaType ##
Cary Clark06c20f32018-03-20 15:53:27 -04001136Creates an empty Image_Info with kUnknown_SkColorType, kUnknown_SkAlphaType,
Cary Clark1a8d7622018-03-05 13:26:16 -05001137a width and height of zero, and no Color_Space.
1138
1139#Return empty Image_Info ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001140
1141#Example
Cary Clark1a8d7622018-03-05 13:26:16 -05001142#Height 32
1143#Description
1144An empty Image_Info may be passed to SkCanvas::accessTopLayerPixels as storage
1145for the Canvas actual Image_Info.
1146##
1147 SkImageInfo imageInfo;
1148 size_t rowBytes;
1149 SkIPoint origin;
Cary Clark681287e2018-03-16 11:34:15 -04001150 (void) canvas->accessTopLayerPixels(&imageInfo, &rowBytes, &origin);
Cary Clark1a8d7622018-03-05 13:26:16 -05001151 const char* alphaType[] = { "Unknown", "Opaque", "Premul", "Unpremul" };
1152 SkString string;
1153 string.printf("k%s_SkAlphaType", alphaType[(int) imageInfo.alphaType()]);
1154 SkPaint paint;
1155 canvas->drawString(string, 20, 20, paint);
Cary Clark2dc84ad2018-01-26 12:56:22 -05001156##
1157
Cary Clark1a8d7622018-03-05 13:26:16 -05001158#SeeAlso Make MakeN32 MakeS32 MakeA8
Cary Clark2dc84ad2018-01-26 12:56:22 -05001159
1160#Method ##
1161
1162# ------------------------------------------------------------------------------
1163
1164#Method static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
1165 sk_sp<SkColorSpace> cs = nullptr)
Cary Clark4855f782018-02-06 09:41:53 -05001166#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001167#Line # creates Image_Info from dimensions, Color_Type, Alpha_Type, Color_Space ##
Cary Clark1a8d7622018-03-05 13:26:16 -05001168Creates Image_Info from integral dimensions width and height, Color_Type ct,
1169Alpha_Type at, and optionally Color_Space cs.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001170
Cary Clark1a8d7622018-03-05 13:26:16 -05001171If Color_Space cs is nullptr and Image_Info is part of drawing source: Color_Space
1172defaults to sRGB, mapping into Surface Color_Space.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001173
Cary Clark1a8d7622018-03-05 13:26:16 -05001174Parameters are not validated to see if their values are legal, or that the
1175combination is supported.
1176
1177#Param width pixel column count; must be zero or greater ##
1178#Param height pixel row count; must be zero or greater ##
1179#Param ct one of: #list_of_color_types#
1180##
Cary Clark681287e2018-03-16 11:34:15 -04001181#Param at one of: #list_of_alpha_types#
Cary Clark1a8d7622018-03-05 13:26:16 -05001182##
1183#Param cs range of colors; may be nullptr ##
1184
1185#Return created Image_Info ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001186
1187#Example
Cary Clark1a8d7622018-03-05 13:26:16 -05001188#Height 48
1189 uint8_t storage[][5] = {{ 0xCA, 0xDA, 0xCA, 0xC9, 0xA3 },
1190 { 0xAC, 0xA8, 0x89, 0xA7, 0x87 },
1191 { 0x9B, 0xB5, 0xE5, 0x95, 0x46 },
1192 { 0x90, 0x81, 0xC5, 0x71, 0x33 },
1193 { 0x75, 0x55, 0x44, 0x40, 0x30 }};
1194 SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kOpaque_SkAlphaType);
1195 SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5);
1196 SkBitmap bitmap;
1197 bitmap.installPixels(pixmap);
1198 canvas->scale(8, 8);
1199 canvas->drawBitmap(bitmap, 0, 0);
Cary Clark2dc84ad2018-01-26 12:56:22 -05001200##
1201
Cary Clark1a8d7622018-03-05 13:26:16 -05001202#SeeAlso MakeN32 MakeN32Premul MakeS32 MakeA8
Cary Clark2dc84ad2018-01-26 12:56:22 -05001203
1204#Method ##
1205
1206# ------------------------------------------------------------------------------
1207
1208#Method static SkImageInfo MakeN32(int width, int height, SkAlphaType at,
1209 sk_sp<SkColorSpace> cs = nullptr)
Cary Clark4855f782018-02-06 09:41:53 -05001210#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001211#Line # creates Image_Info with Native_Color_Type ##
Cary Clark1a8d7622018-03-05 13:26:16 -05001212Creates Image_Info from integral dimensions width and height, kN32_SkColorType,
1213Alpha_Type at, and optionally Color_Space cs. kN32_SkColorType will equal either
1214kBGRA_8888_SkColorType or kRGBA_8888_SkColorType, whichever is optimal.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001215
Cary Clark1a8d7622018-03-05 13:26:16 -05001216If Color_Space cs is nullptr and Image_Info is part of drawing source: Color_Space
1217defaults to sRGB, mapping into Surface Color_Space.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001218
Cary Clark1a8d7622018-03-05 13:26:16 -05001219Parameters are not validated to see if their values are legal, or that the
1220combination is supported.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001221
Cary Clark1a8d7622018-03-05 13:26:16 -05001222#Param width pixel column count; must be zero or greater ##
1223#Param height pixel row count; must be zero or greater ##
Cary Clark681287e2018-03-16 11:34:15 -04001224#Param at one of: #list_of_alpha_types#
Cary Clark1a8d7622018-03-05 13:26:16 -05001225##
1226#Param cs range of colors; may be nullptr ##
1227
1228#Return created Image_Info ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001229
1230#Example
Cary Clark1a8d7622018-03-05 13:26:16 -05001231#Height 128
1232 SkBitmap bitmap;
1233 bitmap.allocPixels(SkImageInfo::MakeN32(16, 16, kPremul_SkAlphaType));
1234 SkCanvas offscreen(bitmap);
1235 offscreen.clear(SK_ColorWHITE);
1236 SkPaint paint;
1237 offscreen.drawString("g", 0, 10, paint);
1238 canvas->scale(8, 8);
1239 canvas->drawBitmap(bitmap, 0, 0);
Cary Clark2dc84ad2018-01-26 12:56:22 -05001240##
1241
Cary Clark1a8d7622018-03-05 13:26:16 -05001242#SeeAlso Make MakeN32Premul MakeS32 MakeA8
Cary Clark2dc84ad2018-01-26 12:56:22 -05001243
1244#Method ##
1245
1246# ------------------------------------------------------------------------------
1247
1248#Method static SkImageInfo MakeS32(int width, int height, SkAlphaType at)
1249
Cary Clark4855f782018-02-06 09:41:53 -05001250#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001251#Line # creates Image_Info with Native_Color_Type, sRGB Color_Space ##
Cary Clark1a8d7622018-03-05 13:26:16 -05001252Creates Image_Info from integral dimensions width and height, kN32_SkColorType,
1253Alpha_Type at, with sRGB Color_Space.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001254
Cary Clark1a8d7622018-03-05 13:26:16 -05001255Parameters are not validated to see if their values are legal, or that the
1256combination is supported.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001257
Cary Clark1a8d7622018-03-05 13:26:16 -05001258#Param width pixel column count; must be zero or greater ##
1259#Param height pixel row count; must be zero or greater ##
Cary Clark681287e2018-03-16 11:34:15 -04001260#Param at one of: #list_of_alpha_types#
Cary Clark2dc84ad2018-01-26 12:56:22 -05001261##
1262
Cary Clark1a8d7622018-03-05 13:26:16 -05001263#Return created Image_Info ##
1264
1265#Example
1266#Set sRGB
1267#Height 128
1268#Description
Cary Clark682c58d2018-05-16 07:07:07 -04001269Top gradient is drawn to offScreen without Color_Space. It is darker than middle
1270gradient, drawn to offScreen with sRGB Color_Space. Bottom gradient shares bits
Cary Clark1a8d7622018-03-05 13:26:16 -05001271with middle, but does not specify the Color_Space in noColorSpaceBitmap. A source
1272without Color_Space is treated as sRGB; the bottom gradient is identical to the
1273middle gradient.
1274##
1275 const int width = 256;
1276 const int height = 32;
1277 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
1278 SkColor gradColors[] = { 0xFFAA0055, 0xFF11CC88 };
1279 SkPoint gradPoints[] = { { 0, 0 }, { width, 0 } };
1280 SkPaint gradPaint;
1281 gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,
1282 SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode));
1283 SkBitmap bitmap;
1284 bitmap.allocPixels(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType));
Cary Clark682c58d2018-05-16 07:07:07 -04001285 SkCanvas offScreen(bitmap);
1286 offScreen.drawRect(SkRect::MakeWH(width, height), gradPaint);
Cary Clark1a8d7622018-03-05 13:26:16 -05001287 canvas->drawBitmap(bitmap, 0, 0);
1288 bitmap.allocPixels(SkImageInfo::MakeS32(width, height, kPremul_SkAlphaType));
1289 SkCanvas sRGBOffscreen(bitmap);
1290 sRGBOffscreen.drawRect(SkRect::MakeWH(width, height), gradPaint);
1291 canvas->drawBitmap(bitmap, 0, 48);
1292 SkBitmap noColorSpaceBitmap;
1293 noColorSpaceBitmap.setInfo(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType));
1294 noColorSpaceBitmap.setPixels(bitmap.getAddr(0, 0));
1295 canvas->drawBitmap(noColorSpaceBitmap, 0, 96);
1296##
1297
1298#SeeAlso Make MakeN32 MakeN32Premul MakeA8
Cary Clark2dc84ad2018-01-26 12:56:22 -05001299
1300#Method ##
1301
1302# ------------------------------------------------------------------------------
1303
1304#Method static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs = nullptr)
1305
Cary Clark4855f782018-02-06 09:41:53 -05001306#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001307#Line # creates Image_Info with Native_Color_Type, kPremul_SkAlphaType ##
Cary Clark1a8d7622018-03-05 13:26:16 -05001308Creates Image_Info from integral dimensions width and height, kN32_SkColorType,
1309kPremul_SkAlphaType, with optional Color_Space.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001310
Cary Clark1a8d7622018-03-05 13:26:16 -05001311If Color_Space cs is nullptr and Image_Info is part of drawing source: Color_Space
1312defaults to sRGB, mapping into Surface Color_Space.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001313
Cary Clark1a8d7622018-03-05 13:26:16 -05001314Parameters are not validated to see if their values are legal, or that the
1315combination is supported.
1316
1317#Param width pixel column count; must be zero or greater ##
1318#Param height pixel row count; must be zero or greater ##
1319#Param cs range of colors; may be nullptr ##
1320
1321#Return created Image_Info ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001322
1323#Example
Cary Clark06c20f32018-03-20 15:53:27 -04001324#Height 128
Cary Clark1a8d7622018-03-05 13:26:16 -05001325 SkBitmap bitmap;
1326 bitmap.allocPixels(SkImageInfo::MakeN32Premul(18, 18));
1327 SkCanvas offscreen(bitmap);
1328 offscreen.clear(SK_ColorWHITE);
1329 SkPaint paint;
1330 paint.setAntiAlias(true);
1331 paint.setTextSize(15);
1332 offscreen.drawString("\xF0\x9F\x98\xB8", 1, 15, paint);
1333 canvas->scale(6, 6);
1334 canvas->drawBitmap(bitmap, 0, 0);
Cary Clark2dc84ad2018-01-26 12:56:22 -05001335##
1336
Cary Clark1a8d7622018-03-05 13:26:16 -05001337#SeeAlso MakeN32 MakeS32 MakeA8 Make
Cary Clark2dc84ad2018-01-26 12:56:22 -05001338
1339#Method ##
1340
1341# ------------------------------------------------------------------------------
1342
1343#Method static SkImageInfo MakeN32Premul(const SkISize& size)
1344
Cary Clark4855f782018-02-06 09:41:53 -05001345#In Constructor
Cary Clark1a8d7622018-03-05 13:26:16 -05001346Creates Image_Info from integral dimensions width and height, kN32_SkColorType,
1347kPremul_SkAlphaType, with Color_Space set to nullptr.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001348
Cary Clark1a8d7622018-03-05 13:26:16 -05001349If Image_Info is part of drawing source: Color_Space defaults to sRGB, mapping
1350into Surface Color_Space.
1351
1352Parameters are not validated to see if their values are legal, or that the
1353combination is supported.
1354
1355#Param size width and height, each must be zero or greater ##
1356
1357#Return created Image_Info ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001358
1359#Example
Cary Clark06c20f32018-03-20 15:53:27 -04001360#Height 128
Cary Clark1a8d7622018-03-05 13:26:16 -05001361 SkBitmap bitmap;
1362 bitmap.allocPixels(SkImageInfo::MakeN32Premul({18, 18}));
1363 SkCanvas offscreen(bitmap);
1364 offscreen.clear(SK_ColorWHITE);
1365 SkPaint paint;
1366 paint.setAntiAlias(true);
1367 paint.setTextSize(15);
1368 offscreen.drawString("\xF0\x9F\x98\xB9", 1, 15, paint);
1369 canvas->scale(6, 6);
1370 canvas->drawBitmap(bitmap, 0, 0);
Cary Clark2dc84ad2018-01-26 12:56:22 -05001371##
1372
Cary Clark682c58d2018-05-16 07:07:07 -04001373#SeeAlso MakeN32 MakeS32 MakeA8 Make
Cary Clark2dc84ad2018-01-26 12:56:22 -05001374
1375#Method ##
1376
1377# ------------------------------------------------------------------------------
1378
1379#Method static SkImageInfo MakeA8(int width, int height)
1380
Cary Clark4855f782018-02-06 09:41:53 -05001381#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001382#Line # creates Image_Info with kAlpha_8_SkColorType, kPremul_SkAlphaType ##
Cary Clark1a8d7622018-03-05 13:26:16 -05001383Creates Image_Info from integral dimensions width and height, kAlpha_8_SkColorType,
1384kPremul_SkAlphaType, with Color_Space set to nullptr.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001385
Cary Clark1a8d7622018-03-05 13:26:16 -05001386#Param width pixel column count; must be zero or greater ##
1387#Param height pixel row count; must be zero or greater ##
1388
1389#Return created Image_Info ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001390
1391#Example
Cary Clark681287e2018-03-16 11:34:15 -04001392#Height 64
1393 uint8_t pixels[][8] = { { 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00},
1394 { 0x00, 0x7f, 0xff, 0x3f, 0x3f, 0x7f, 0x3f, 0x00},
1395 { 0x3f, 0xff, 0x7f, 0x00, 0x7f, 0xff, 0x7f, 0x00},
1396 { 0x00, 0x3f, 0x00, 0x00, 0x3f, 0x7f, 0x3f, 0x00},
1397 { 0x3f, 0x7f, 0x7f, 0x3f, 0x00, 0x00, 0x00, 0x00},
1398 { 0x7f, 0xff, 0xff, 0x7f, 0x00, 0x3f, 0x7f, 0x3f},
1399 { 0x7f, 0xff, 0xff, 0x7f, 0x00, 0x7f, 0xff, 0x7f},
1400 { 0x3f, 0x7f, 0x7f, 0x3f, 0x00, 0x3f, 0x7f, 0x3f} };
1401 SkBitmap bitmap;
1402 bitmap.installPixels(SkImageInfo::MakeA8(8, 8),
1403 (void*) pixels, sizeof(pixels[0]));
1404 SkPaint paint;
1405 canvas->scale(4, 4);
1406 for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xFF007F00} ) {
1407 paint.setColor(color);
1408 canvas->drawBitmap(bitmap, 0, 0, &paint);
1409 canvas->translate(12, 0);
1410 }
Cary Clark2dc84ad2018-01-26 12:56:22 -05001411##
1412
Cary Clark1a8d7622018-03-05 13:26:16 -05001413#SeeAlso MakeN32 MakeS32 Make
Cary Clark2dc84ad2018-01-26 12:56:22 -05001414
1415#Method ##
1416
1417# ------------------------------------------------------------------------------
1418
1419#Method static SkImageInfo MakeUnknown(int width, int height)
1420
Cary Clark4855f782018-02-06 09:41:53 -05001421#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001422#Line # creates Image_Info with kUnknown_SkColorType, kUnknown_SkAlphaType ##
Cary Clark1a8d7622018-03-05 13:26:16 -05001423Creates Image_Info from integral dimensions width and height, kUnknown_SkColorType,
1424kUnknown_SkAlphaType, with Color_Space set to nullptr.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001425
Cary Clark1a8d7622018-03-05 13:26:16 -05001426Returned Image_Info as part of source does not draw, and as part of destination
1427can not be drawn to.
1428
1429#Param width pixel column count; must be zero or greater ##
1430#Param height pixel row count; must be zero or greater ##
1431
1432#Return created Image_Info ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001433
1434#Example
Cary Clark1a8d7622018-03-05 13:26:16 -05001435#Height 32
1436#Width 384
1437SkImageInfo info; // default constructor
1438SkString string;
1439string.printf("SkImageInfo() %c= SkImageInfo::MakeUnknown(0, 0)",
1440 info == SkImageInfo::MakeUnknown(0, 0) ? '=' : '!');
1441SkPaint paint;
1442canvas->drawString(string, 0, 12, paint);
Cary Clark2dc84ad2018-01-26 12:56:22 -05001443##
1444
Cary Clark1a8d7622018-03-05 13:26:16 -05001445#SeeAlso SkImageInfo() MakeN32 MakeS32 Make
Cary Clark2dc84ad2018-01-26 12:56:22 -05001446
1447#Method ##
1448
1449# ------------------------------------------------------------------------------
1450
1451#Method static SkImageInfo MakeUnknown()
1452
Cary Clark4855f782018-02-06 09:41:53 -05001453#In Constructor
Cary Clark1a8d7622018-03-05 13:26:16 -05001454Creates Image_Info from integral dimensions width and height set to zero,
1455kUnknown_SkColorType, kUnknown_SkAlphaType, with Color_Space set to nullptr.
1456
1457Returned Image_Info as part of source does not draw, and as part of destination
1458can not be drawn to.
1459
1460#Return created Image_Info ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001461
1462#Example
Cary Clark1a8d7622018-03-05 13:26:16 -05001463#Height 32
1464#Width 384
1465SkImageInfo info; // default constructor
1466SkString string;
1467string.printf("SkImageInfo() %c= SkImageInfo::MakeUnknown()",
1468 info == SkImageInfo::MakeUnknown() ? '=' : '!');
1469SkPaint paint;
1470canvas->drawString(string, 0, 12, paint);
Cary Clark2dc84ad2018-01-26 12:56:22 -05001471##
1472
Cary Clark1a8d7622018-03-05 13:26:16 -05001473#SeeAlso SkImageInfo() MakeN32 MakeS32 Make
Cary Clark2dc84ad2018-01-26 12:56:22 -05001474
1475#Method ##
1476
Cary Clark2dc84ad2018-01-26 12:56:22 -05001477
1478# ------------------------------------------------------------------------------
Cary Clark78de7512018-02-07 07:27:09 -05001479#Subtopic Property
1480#Populate
1481#Line # metrics and attributes ##
1482##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001483
1484#Method int width() const
Cary Clark78de7512018-02-07 07:27:09 -05001485#In Property
Cary Clark1a8d7622018-03-05 13:26:16 -05001486#Line # returns pixel column count ##
1487Returns pixel count in each row.
1488
1489#Return pixel width ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001490
1491#Example
Cary Clark1a8d7622018-03-05 13:26:16 -05001492#Image 4
1493#Height 96
1494 canvas->translate(10, 10);
1495 canvas->drawBitmap(source, 0, 0);
1496 SkImageInfo imageInfo = source.info();
1497 canvas->translate(0, imageInfo.height());
1498 SkPaint paint;
1499 paint.setTextAlign(SkPaint::kCenter_Align);
1500 canvas->drawLine(0, 10, imageInfo.width(), 10, paint);
1501 canvas->drawString("width", imageInfo.width() / 2, 25, paint);
Cary Clark2dc84ad2018-01-26 12:56:22 -05001502##
1503
Cary Clark1a8d7622018-03-05 13:26:16 -05001504#SeeAlso height SkBitmap::width SkPixelRef::width SkImage::width SkSurface::width
Cary Clark2dc84ad2018-01-26 12:56:22 -05001505
1506#Method ##
1507
1508# ------------------------------------------------------------------------------
1509
1510#Method int height() const
Cary Clark78de7512018-02-07 07:27:09 -05001511#In Property
Cary Clark1a8d7622018-03-05 13:26:16 -05001512#Line # returns pixel row count ##
1513Returns pixel row count.
1514
1515#Return pixel height ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001516
1517#Example
Cary Clark1a8d7622018-03-05 13:26:16 -05001518#Image 4
1519#Height 96
1520 canvas->translate(10, 20);
1521 canvas->drawBitmap(source, 0, 0);
1522 SkImageInfo imageInfo = source.info();
1523 SkPaint paint;
1524 paint.setTextAlign(SkPaint::kCenter_Align);
1525 paint.setVerticalText(true);
1526 canvas->drawLine(imageInfo.width() + 10, 0, imageInfo.width() + 10, imageInfo.height(), paint);
1527 canvas->drawString("height", imageInfo.width() + 25, imageInfo.height() / 2, paint);
Cary Clark2dc84ad2018-01-26 12:56:22 -05001528##
1529
Cary Clark1a8d7622018-03-05 13:26:16 -05001530#SeeAlso width SkBitmap::height SkPixelRef::height SkImage::height SkSurface::height
Cary Clark2dc84ad2018-01-26 12:56:22 -05001531
1532#Method ##
1533
1534# ------------------------------------------------------------------------------
1535
1536#Method SkColorType colorType() const
Cary Clark78de7512018-02-07 07:27:09 -05001537#In Property
Cary Clark681287e2018-03-16 11:34:15 -04001538#Line # returns Color_Type ##
Cary Clark1a8d7622018-03-05 13:26:16 -05001539Returns Color_Type, one of: #list_of_color_types#.
1540
1541#Return Color_Type ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001542
1543#Example
Cary Clark681287e2018-03-16 11:34:15 -04001544 const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
1545 "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"};
1546 SkImageInfo info = SkImageInfo::MakeA8(16, 32);
1547 SkDebugf("color type: k" "%s" "_SkColorType\n", colors[info.colorType()]);
1548#StdOut
1549color type: kAlpha_8_SkColorType
1550##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001551##
1552
Cary Clark681287e2018-03-16 11:34:15 -04001553#SeeAlso alphaType SkPixmap::colorType SkBitmap::colorType
Cary Clark2dc84ad2018-01-26 12:56:22 -05001554
1555#Method ##
1556
1557# ------------------------------------------------------------------------------
1558
1559#Method SkAlphaType alphaType() const
Cary Clark78de7512018-02-07 07:27:09 -05001560#In Property
Cary Clark682c58d2018-05-16 07:07:07 -04001561#Line # returns Alpha_Type ##
Cary Clark681287e2018-03-16 11:34:15 -04001562Returns Alpha_Type, one of: #list_of_alpha_types#.
1563
1564#Return Alpha_Type ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001565
1566#Example
Cary Clark681287e2018-03-16 11:34:15 -04001567 const char* alphas[] = {"Unknown", "Opaque", "Premul", "Unpremul"};
1568 SkImageInfo info = SkImageInfo::MakeA8(16, 32);
1569 SkDebugf("alpha type: k" "%s" "_SkAlphaType\n", alphas[info.alphaType()]);
1570#StdOut
1571alpha type: kPremul_SkAlphaType
1572##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001573##
1574
Cary Clark681287e2018-03-16 11:34:15 -04001575#SeeAlso colorType SkPixmap::alphaType SkBitmap::alphaType
Cary Clark2dc84ad2018-01-26 12:56:22 -05001576
1577#Method ##
1578
1579# ------------------------------------------------------------------------------
1580
1581#Method SkColorSpace* colorSpace() const
Cary Clark78de7512018-02-07 07:27:09 -05001582#In Property
Cary Clark681287e2018-03-16 11:34:15 -04001583#Line # returns Color_Space ##
1584Returns Color_Space, the range of colors. The reference count of
1585Color_Space is unchanged. The returned Color_Space is immutable.
1586
1587#Return Color_Space, or nullptr ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001588
1589#Example
Cary Clark681287e2018-03-16 11:34:15 -04001590#Description
1591SkColorSpace::MakeSRGBLinear creates Color_Space with linear gamma
1592and an sRGB gamut. This Color_Space gamma is not close to sRGB gamma.
1593##
Cary Clark682c58d2018-05-16 07:07:07 -04001594 SkImageInfo info = SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType,
Cary Clark681287e2018-03-16 11:34:15 -04001595 SkColorSpace::MakeSRGBLinear());
1596 SkColorSpace* colorSpace = info.colorSpace();
1597 SkDebugf("gammaCloseToSRGB: %s gammaIsLinear: %s isSRGB: %s\n",
1598 colorSpace->gammaCloseToSRGB() ? "true" : "false",
1599 colorSpace->gammaIsLinear() ? "true" : "false",
1600 colorSpace->isSRGB() ? "true" : "false");
1601#StdOut
1602gammaCloseToSRGB: false gammaIsLinear: true isSRGB: false
1603##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001604##
1605
Cary Clark681287e2018-03-16 11:34:15 -04001606#SeeAlso Color_Space SkPixmap::colorSpace SkBitmap::colorSpace
Cary Clark2dc84ad2018-01-26 12:56:22 -05001607
1608#Method ##
1609
1610# ------------------------------------------------------------------------------
1611
1612#Method sk_sp<SkColorSpace> refColorSpace() const
Cary Clark78de7512018-02-07 07:27:09 -05001613#In Property
Cary Clark681287e2018-03-16 11:34:15 -04001614#Line # returns Color_Space ##
Cary Clark682c58d2018-05-16 07:07:07 -04001615Returns smart pointer to Color_Space, the range of colors. The smart pointer
Cary Clark681287e2018-03-16 11:34:15 -04001616tracks the number of objects sharing this Color_Space reference so the memory
1617is released when the owners destruct.
1618
1619The returned Color_Space is immutable.
1620
1621#Return Color_Space wrapped in a smart pointer ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001622
1623#Example
Cary Clark682c58d2018-05-16 07:07:07 -04001624 SkImageInfo info1 = SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType,
Cary Clark681287e2018-03-16 11:34:15 -04001625 SkColorSpace::MakeSRGBLinear());
1626 SkImageInfo info2 = SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType,
1627 info1.refColorSpace());
1628 SkColorSpace* colorSpace = info2.colorSpace();
1629 SkDebugf("gammaCloseToSRGB: %s gammaIsLinear: %s isSRGB: %s\n",
1630 colorSpace->gammaCloseToSRGB() ? "true" : "false",
1631 colorSpace->gammaIsLinear() ? "true" : "false",
1632 colorSpace->isSRGB() ? "true" : "false");
Cary Clark2dc84ad2018-01-26 12:56:22 -05001633##
1634
Cary Clark681287e2018-03-16 11:34:15 -04001635#SeeAlso Color_Space SkBitmap::refColorSpace
Cary Clark2dc84ad2018-01-26 12:56:22 -05001636
1637#Method ##
1638
1639# ------------------------------------------------------------------------------
1640
1641#Method bool isEmpty() const
Cary Clark78de7512018-02-07 07:27:09 -05001642#In Property
Cary Clark681287e2018-03-16 11:34:15 -04001643#Line # returns if dimensions contain pixels ##
1644
1645Returns if Image_Info describes an empty area of pixels by checking if either
1646width or height is zero or smaller.
1647
1648#Return true if either dimension is zero or smaller ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001649
1650#Example
Cary Clark681287e2018-03-16 11:34:15 -04001651 for (int width : { 0, 2 } ) {
1652 for (int height : { 0, 2 } ) {
1653 SkImageInfo imageInfo= SkImageInfo::MakeA8(width, height);
1654 SkDebugf("width: %d height: %d empty: %s\n", width, height,
1655 imageInfo.isEmpty() ? "true" : "false");
1656 }
1657 }
1658#StdOut
1659width: 0 height: 0 empty: true
1660width: 0 height: 2 empty: true
1661width: 2 height: 0 empty: true
1662width: 2 height: 2 empty: false
1663##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001664##
1665
Cary Clark681287e2018-03-16 11:34:15 -04001666#SeeAlso dimensions bounds SkBitmap::empty SkPixmap::bounds
Cary Clark2dc84ad2018-01-26 12:56:22 -05001667
1668#Method ##
1669
1670# ------------------------------------------------------------------------------
1671
1672#Method bool isOpaque() const
Cary Clark78de7512018-02-07 07:27:09 -05001673#In Property
Cary Clark681287e2018-03-16 11:34:15 -04001674#Line # returns if Alpha_Type is kOpaque_SkAlphaType ##
1675
1676Returns true if Alpha_Type is set to hint that all pixels are opaque; their
1677Color_Alpha value is implicitly or explicitly 1.0. If true, and all pixels are
Cary Clark682c58d2018-05-16 07:07:07 -04001678not opaque, Skia may draw incorrectly.
Cary Clark681287e2018-03-16 11:34:15 -04001679
1680Does not check if Color_Type allows Alpha, or if any pixel value has
1681transparency.
1682
1683#Return true if Alpha_Type is kOpaque_SkAlphaType ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001684
1685#Example
Cary Clark681287e2018-03-16 11:34:15 -04001686 const int height = 2;
1687 const int width = 2;
1688 SkBitmap bitmap;
1689 SkImageInfo imageInfo = SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
1690 bitmap.setInfo(imageInfo);
1691 for (int index = 0; index < 2; ++index) {
1692 bitmap.allocPixels();
1693 bitmap.eraseColor(0x00000000);
1694 SkDebugf("isOpaque: %s\n", imageInfo.isOpaque() ? "true" : "false");
1695 bitmap.eraseColor(0xFFFFFFFF);
1696 SkDebugf("isOpaque: %s\n", imageInfo.isOpaque() ? "true" : "false");
1697 imageInfo = imageInfo.makeAlphaType(kOpaque_SkAlphaType);
1698 bitmap.setInfo(imageInfo);
1699 }
1700#StdOut
1701isOpaque: false
1702isOpaque: false
1703isOpaque: true
1704isOpaque: true
1705##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001706##
1707
Cary Clark681287e2018-03-16 11:34:15 -04001708#SeeAlso Color_Alpha SkColorTypeValidateAlphaType SkBitmap::isOpaque SkImage::isOpaque SkPixmap::isOpaque
Cary Clark2dc84ad2018-01-26 12:56:22 -05001709
1710#Method ##
1711
1712# ------------------------------------------------------------------------------
1713
1714#Method SkISize dimensions() const
Cary Clark78de7512018-02-07 07:27:09 -05001715#In Property
Cary Clark681287e2018-03-16 11:34:15 -04001716#Line # returns width() and height() ##
1717
1718Returns ISize { width(), height() }.
1719
1720#Return integral size of width() and height() ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001721
1722#Example
Cary Clark681287e2018-03-16 11:34:15 -04001723 const int height = 2;
1724 const int width = 2;
1725 SkImageInfo imageInfo = SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
1726 SkISize dimensions = imageInfo.dimensions();
1727 SkIRect bounds = imageInfo.bounds();
1728 SkIRect dimensionsAsBounds = SkIRect::MakeSize(dimensions);
1729 SkDebugf("dimensionsAsBounds %c= bounds\n", dimensionsAsBounds == bounds ? '=' : '!');
1730#StdOut
1731dimensionsAsBounds == bounds
1732##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001733##
1734
Cary Clark681287e2018-03-16 11:34:15 -04001735#SeeAlso width height bounds SkBitmap::dimensions
Cary Clark2dc84ad2018-01-26 12:56:22 -05001736
1737#Method ##
1738
1739# ------------------------------------------------------------------------------
1740
1741#Method SkIRect bounds() const
Cary Clark78de7512018-02-07 07:27:09 -05001742#In Property
Cary Clark681287e2018-03-16 11:34:15 -04001743#Line # returns width() and height() as Rectangle ##
1744Returns IRect { 0, 0, width(), height() }.
1745
1746#Return integral rectangle from origin to width() and height() ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001747
1748#Example
Cary Clark681287e2018-03-16 11:34:15 -04001749#Height 64
1750#Image 4
1751 canvas->scale(.5f, .5f);
1752 SkImageInfo imageInfo = source.info();
1753 SkIRect bounds = imageInfo.bounds();
1754 for (int x : { 0, bounds.width() } ) {
1755 for (int y : { 0, bounds.height() } ) {
1756 canvas->drawBitmap(source, x, y);
1757 }
1758 }
Cary Clark2dc84ad2018-01-26 12:56:22 -05001759##
1760
Cary Clark681287e2018-03-16 11:34:15 -04001761#SeeAlso width height dimensions
Cary Clark2dc84ad2018-01-26 12:56:22 -05001762
1763#Method ##
1764
1765# ------------------------------------------------------------------------------
1766
1767#Method bool gammaCloseToSRGB() const
Cary Clark78de7512018-02-07 07:27:09 -05001768#In Property
Cary Clark682c58d2018-05-16 07:07:07 -04001769#Line # returns if Color_Space gamma is approximately the same as sRGB ##
Cary Clark681287e2018-03-16 11:34:15 -04001770
1771Returns true if associated Color_Space is not nullptr, and Color_Space gamma
Cary Clark682c58d2018-05-16 07:07:07 -04001772is approximately the same as sRGB.
1773This includes the
Cary Clark681287e2018-03-16 11:34:15 -04001774###$
1775$A sRGB transfer function $ https://en.wikipedia.org/wiki/SRGB#The_sRGB_transfer_function_(%22gamma%22) $$
1776$$$#
1777as well as a gamma curve described by a 2.2 exponent.
1778
1779#Return true if Color_Space gamma is approximately the same as sRGB ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001780
1781#Example
Cary Clark681287e2018-03-16 11:34:15 -04001782#Height 144
1783 const int width = 256;
1784 const int height = 64;
1785 auto drawLabel = [=](const char* what, bool closeToSRGB) -> void {
1786 SkString string;
1787 string.printf("%s gamma is %s" "close to sRGB", what, closeToSRGB ? "" : "not ");
1788 SkPaint paint;
1789 paint.setAntiAlias(true);
1790 paint.setTextAlign(SkPaint::kCenter_Align);
1791 canvas->drawString(string, width / 2, 56, paint);
1792 };
1793 SkColor gradColors[] = { 0xFFFF7F00, 0xFF00FF7F, 0xFF0000FF, 0xFF7F7FFF };
1794 SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } };
1795 SkPaint gradPaint;
1796 gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,
1797 SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode));
1798 canvas->drawRect(SkRect::MakeWH(width, height), gradPaint);
1799 drawLabel("canvas", canvas->imageInfo().gammaCloseToSRGB());
1800 SkBitmap bitmap;
1801 SkImageInfo offscreenInfo = SkImageInfo::MakeS32(width, height, kPremul_SkAlphaType);
1802 bitmap.allocPixels(offscreenInfo);
1803 SkCanvas sRGBOffscreen(bitmap);
1804 sRGBOffscreen.drawRect(SkRect::MakeWH(width, height), gradPaint);
1805 canvas->translate(0, 80);
1806 canvas->drawBitmap(bitmap, 0, 0);
1807 drawLabel("offscreen", offscreenInfo.gammaCloseToSRGB());
Cary Clark2dc84ad2018-01-26 12:56:22 -05001808##
1809
Cary Clark681287e2018-03-16 11:34:15 -04001810#SeeAlso SkColorSpace::gammaCloseToSRGB
Cary Clark2dc84ad2018-01-26 12:56:22 -05001811
1812#Method ##
1813
1814# ------------------------------------------------------------------------------
1815
1816#Method SkImageInfo makeWH(int newWidth, int newHeight) const
Cary Clark78de7512018-02-07 07:27:09 -05001817#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001818#Line # creates Image_Info with changed dimensions ##
Cary Clark681287e2018-03-16 11:34:15 -04001819Creates Image_Info with the same Color_Type, Color_Space, and Alpha_Type,
1820with dimensions set to width and height.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001821
Cary Clark681287e2018-03-16 11:34:15 -04001822#Param newWidth pixel column count; must be zero or greater ##
1823#Param newHeight pixel row count; must be zero or greater ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001824
Cary Clark681287e2018-03-16 11:34:15 -04001825#Return created Image_Info ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001826
1827#Example
Cary Clark681287e2018-03-16 11:34:15 -04001828#Height 144
1829#Image 3
1830 SkImageInfo canvasImageInfo = canvas->imageInfo();
1831 SkRect canvasBounds = SkRect::Make(canvasImageInfo.bounds());
1832 canvas->drawBitmapRect(source, source.bounds(), canvasBounds, nullptr);
Cary Clark682c58d2018-05-16 07:07:07 -04001833 SkImageInfo insetImageInfo =
Cary Clark681287e2018-03-16 11:34:15 -04001834 canvasImageInfo.makeWH(canvasBounds.width() / 2, canvasBounds.height() / 2);
1835 SkBitmap inset;
1836 inset.allocPixels(insetImageInfo);
1837 SkCanvas offscreen(inset);
1838 offscreen.drawBitmapRect(source, source.bounds(), SkRect::Make(inset.bounds()), nullptr);
1839 canvas->drawBitmap(inset, canvasBounds.width() / 4, canvasBounds.height() / 4);
Cary Clark2dc84ad2018-01-26 12:56:22 -05001840##
1841
Cary Clark682c58d2018-05-16 07:07:07 -04001842#SeeAlso Make makeAlphaType makeColorSpace makeColorType
Cary Clark2dc84ad2018-01-26 12:56:22 -05001843
1844#Method ##
1845
1846# ------------------------------------------------------------------------------
1847
1848#Method SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
Cary Clark78de7512018-02-07 07:27:09 -05001849#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001850#Line # creates Image_Info with changed Alpha_Type ##
Cary Clark681287e2018-03-16 11:34:15 -04001851Creates Image_Info with same Color_Type, Color_Space, width, and height,
Cary Clark682c58d2018-05-16 07:07:07 -04001852with Alpha_Type set to newAlphaType.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001853
Cary Clark681287e2018-03-16 11:34:15 -04001854Created Image_Info contains newAlphaType even if it is incompatible with
1855Color_Type, in which case Alpha_Type in Image_Info is ignored.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001856
Cary Clark681287e2018-03-16 11:34:15 -04001857#Param newAlphaType one of: #list_of_alpha_types#
Cary Clark2dc84ad2018-01-26 12:56:22 -05001858##
1859
Cary Clark681287e2018-03-16 11:34:15 -04001860#Return created Image_Info ##
1861
1862#Example
1863#Image 3
1864 const int width = 256;
1865 const int height = 128;
1866 SkColor pixels[height][width];
1867 for (int y = 0; y < height; ++y) {
1868 for (int x = 0; x < width; ++x) {
Cary Clark682c58d2018-05-16 07:07:07 -04001869 int red = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 4 + y) * 0.03f)));
1870 int blue = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 3 + y) * 0.04f)));
Cary Clark681287e2018-03-16 11:34:15 -04001871 int green = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 2 + y) * 0.05f)));
1872 int alpha = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 1 + y) * 0.006f)));
Cary Clark682c58d2018-05-16 07:07:07 -04001873 pixels[y][x] =
Cary Clark681287e2018-03-16 11:34:15 -04001874 SkColorSetARGB(alpha, red * alpha / 255, green * alpha / 255, blue * alpha / 255);
1875 }
1876 }
1877 SkBitmap bitmap;
1878 SkImageInfo info = SkImageInfo::Make(width, height, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
1879 bitmap.installPixels(info, (void*) pixels, sizeof(SkColor) * width);
1880 canvas->drawBitmap(source, 0, 0);
1881 canvas->drawBitmap(bitmap, 0, 0);
1882 SkImageInfo unpremulInfo = info.makeAlphaType(kUnpremul_SkAlphaType);
1883 bitmap.installPixels(unpremulInfo, (void*) pixels, sizeof(SkColor) * width);
1884 canvas->drawBitmap(bitmap, 0, 128);
1885##
1886
1887#SeeAlso Make MakeA8 makeColorType makeColorSpace
Cary Clark2dc84ad2018-01-26 12:56:22 -05001888
1889#Method ##
1890
1891# ------------------------------------------------------------------------------
1892
1893#Method SkImageInfo makeColorType(SkColorType newColorType) const
Cary Clark78de7512018-02-07 07:27:09 -05001894#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001895#Line # creates Image_Info with changed Color_Type ##
Cary Clark681287e2018-03-16 11:34:15 -04001896Creates Image_Info with same Alpha_Type, Color_Space, width, and height,
1897with Color_Type set to newColorType.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001898
Cary Clark681287e2018-03-16 11:34:15 -04001899#Param newColorType one of: #list_of_color_types#
Cary Clark2dc84ad2018-01-26 12:56:22 -05001900##
1901
Cary Clark681287e2018-03-16 11:34:15 -04001902#Return created Image_Info ##
1903
1904#Example
1905 const int width = 256;
1906 const int height = 128;
1907 SkColor pixels[height][width];
1908 for (int y = 0; y < height; ++y) {
1909 for (int x = 0; x < width; ++x) {
Cary Clark682c58d2018-05-16 07:07:07 -04001910 int red = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 4 + y) * 0.03f)));
1911 int blue = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 3 + y) * 0.04f)));
Cary Clark681287e2018-03-16 11:34:15 -04001912 int green = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarSin((x * 2 + y) * 0.05f)));
1913 int alpha = SkScalarRoundToInt(255 * SkScalarAbs(SkScalarCos((x * 1 + y) * 0.006f)));
Cary Clark682c58d2018-05-16 07:07:07 -04001914 pixels[y][x] =
Cary Clark681287e2018-03-16 11:34:15 -04001915 SkColorSetARGB(alpha, red * alpha / 255, green * alpha / 255, blue * alpha / 255);
1916 }
1917 }
1918 SkBitmap bitmap;
1919 SkImageInfo info = SkImageInfo::Make(width, height, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
1920 bitmap.installPixels(info, (void*) pixels, sizeof(SkColor) * width);
1921 canvas->drawBitmap(source, 0, 0);
1922 canvas->drawBitmap(bitmap, 0, 0);
1923 SkImageInfo rgbaInfo = info.makeColorType(kRGBA_8888_SkColorType);
1924 bitmap.installPixels(rgbaInfo, (void*) pixels, sizeof(SkColor) * width);
1925 canvas->drawBitmap(bitmap, 0, 128);
1926##
1927
1928#SeeAlso Make makeAlphaType makeColorSpace
Cary Clark2dc84ad2018-01-26 12:56:22 -05001929
1930#Method ##
1931
1932# ------------------------------------------------------------------------------
1933
1934#Method SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const
Cary Clark78de7512018-02-07 07:27:09 -05001935#In Constructor
Cary Clarkab2621d2018-01-30 10:08:57 -05001936#Line # creates Image_Info with changed Color_Space ##
Cary Clark681287e2018-03-16 11:34:15 -04001937Creates Image_Info with same Alpha_Type, Color_Type, width, and height,
1938with Color_Space set to cs.
Cary Clark2dc84ad2018-01-26 12:56:22 -05001939
Cary Clark681287e2018-03-16 11:34:15 -04001940#Param cs range of colors; may be nullptr ##
1941
1942#Return created Image_Info ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001943
1944#Example
Cary Clark681287e2018-03-16 11:34:15 -04001945#Height 224
1946 const int width = 256;
1947 const int height = 64;
1948 auto drawLabel = [=](const char* what, bool closeToSRGB) -> void {
1949 SkString string;
1950 string.printf("%s gamma is %s" "close to sRGB", what, closeToSRGB ? "" : "not ");
1951 SkPaint paint;
1952 paint.setAntiAlias(true);
1953 paint.setTextAlign(SkPaint::kCenter_Align);
1954 canvas->drawString(string, width / 2, 56, paint);
1955 };
1956 SkColor gradColors[] = { 0xFFFF7F00, 0xFF00FF7F, 0xFF0000FF, 0xFF7F7FFF };
1957 SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } };
1958 SkPaint gradPaint;
1959 gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,
1960 SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode));
1961 canvas->drawRect(SkRect::MakeWH(width, height), gradPaint);
1962 drawLabel("canvas", canvas->imageInfo().gammaCloseToSRGB());
1963 SkBitmap bitmap;
1964 SkImageInfo offscreenInfo = SkImageInfo::MakeS32(width, height, kPremul_SkAlphaType);
1965 bitmap.allocPixels(offscreenInfo);
1966 SkCanvas sRGBOffscreen(bitmap);
1967 sRGBOffscreen.drawRect(SkRect::MakeWH(width, height), gradPaint);
1968 canvas->translate(0, 80);
1969 canvas->drawBitmap(bitmap, 0, 0);
1970 drawLabel("offscreen", offscreenInfo.gammaCloseToSRGB());
1971 SkImageInfo linearGamma =
1972 offscreenInfo.makeColorSpace(offscreenInfo.colorSpace()->makeLinearGamma());
1973 bitmap.allocPixels(linearGamma);
1974 SkCanvas lgOffscreen(bitmap);
1975 lgOffscreen.drawRect(SkRect::MakeWH(width, height), gradPaint);
1976 canvas->translate(0, 80);
1977 canvas->drawBitmap(bitmap, 0, 0);
1978 drawLabel("linear", linearGamma.gammaCloseToSRGB());
Cary Clark2dc84ad2018-01-26 12:56:22 -05001979##
1980
Cary Clark681287e2018-03-16 11:34:15 -04001981#SeeAlso Make MakeS32 makeAlphaType makeColorType
Cary Clark2dc84ad2018-01-26 12:56:22 -05001982
1983#Method ##
1984
1985# ------------------------------------------------------------------------------
1986
1987#Method int bytesPerPixel() const
Cary Clark78de7512018-02-07 07:27:09 -05001988#In Property
Cary Clark681287e2018-03-16 11:34:15 -04001989#Line # returns number of bytes in pixel based on Color_Type ##
1990Returns number of bytes per pixel required by Color_Type.
1991Returns zero if colorType( is kUnknown_SkColorType.
1992
1993#Return bytes in pixel ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05001994
1995#Example
Cary Clark681287e2018-03-16 11:34:15 -04001996 const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
1997 "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"};
1998 for (SkColorType colorType : { #list_of_color_types#
1999 } ) {
2000 SkImageInfo info = SkImageInfo::Make(1, 1, colorType, kOpaque_SkAlphaType);
2001 SkDebugf("color: k" "%s" "_SkColorType" "%*s" "bytesPerPixel: %d\n",
2002 colors[colorType], 13 - strlen(colors[colorType]), " ",
2003 info.bytesPerPixel());
2004 }
2005#StdOut
2006color: kUnknown_SkColorType bytesPerPixel: 0
2007color: kAlpha_8_SkColorType bytesPerPixel: 1
2008color: kRGB_565_SkColorType bytesPerPixel: 2
2009color: kARGB_4444_SkColorType bytesPerPixel: 2
2010color: kRGBA_8888_SkColorType bytesPerPixel: 4
2011color: kRGB_888x_SkColorType bytesPerPixel: 4
2012color: kBGRA_8888_SkColorType bytesPerPixel: 4
2013color: kRGBA_1010102_SkColorType bytesPerPixel: 4
2014color: kRGB_101010x_SkColorType bytesPerPixel: 4
2015color: kGray_8_SkColorType bytesPerPixel: 1
2016color: kRGBA_F16_SkColorType bytesPerPixel: 8
2017##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002018##
2019
Cary Clark681287e2018-03-16 11:34:15 -04002020#SeeAlso width shiftPerPixel SkBitmap::bytesPerPixel
Cary Clark2dc84ad2018-01-26 12:56:22 -05002021
2022#Method ##
2023
2024# ------------------------------------------------------------------------------
2025
2026#Method int shiftPerPixel() const
Cary Clark78de7512018-02-07 07:27:09 -05002027#In Property
Cary Clark681287e2018-03-16 11:34:15 -04002028#Line # returns bit shift from pixels to bytes ##
2029Returns bit shift converting row bytes to row pixels.
2030Returns zero for kUnknown_SkColorType.
2031
2032#Return one of: 0, 1, 2, 3; left shift to convert pixels to bytes ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002033
2034#Example
Cary Clark681287e2018-03-16 11:34:15 -04002035 const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
2036 "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"};
2037 for (SkColorType colorType : { #list_of_color_types#
2038 } ) {
2039 SkImageInfo info = SkImageInfo::Make(1, 1, colorType, kOpaque_SkAlphaType);
2040 SkDebugf("color: k" "%s" "_SkColorType" "%*s" "shiftPerPixel: %d\n",
2041 colors[colorType], 14 - strlen(colors[colorType]), " ",
2042 info.shiftPerPixel());
2043 }
2044#StdOut
2045color: kUnknown_SkColorType shiftPerPixel: 0
2046color: kAlpha_8_SkColorType shiftPerPixel: 0
2047color: kRGB_565_SkColorType shiftPerPixel: 1
2048color: kARGB_4444_SkColorType shiftPerPixel: 1
2049color: kRGBA_8888_SkColorType shiftPerPixel: 2
2050color: kRGB_888x_SkColorType shiftPerPixel: 2
2051color: kBGRA_8888_SkColorType shiftPerPixel: 2
2052color: kRGBA_1010102_SkColorType shiftPerPixel: 2
2053color: kRGB_101010x_SkColorType shiftPerPixel: 2
2054color: kGray_8_SkColorType shiftPerPixel: 0
2055color: kRGBA_F16_SkColorType shiftPerPixel: 3
2056##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002057##
2058
Cary Clark06c20f32018-03-20 15:53:27 -04002059#SeeAlso bytesPerPixel minRowBytes SkBitmap::shiftPerPixel SkPixmap::shiftPerPixel
Cary Clark2dc84ad2018-01-26 12:56:22 -05002060
2061#Method ##
2062
2063# ------------------------------------------------------------------------------
2064
2065#Method uint64_t minRowBytes64() const
Cary Clark78de7512018-02-07 07:27:09 -05002066#In Property
Cary Clark681287e2018-03-16 11:34:15 -04002067#Line # returns width() times bytesPerPixel in 64 bits ##
2068
2069Returns minimum bytes per row, computed from pixel width() and Color_Type, which
Cary Clark682c58d2018-05-16 07:07:07 -04002070specifies bytesPerPixel(). Bitmap maximum value for row bytes must fit
2071in 31 bits.
Cary Clark681287e2018-03-16 11:34:15 -04002072
2073#Return width() times bytesPerPixel as unsigned 64-bit integer ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002074
2075#Example
Cary Clark681287e2018-03-16 11:34:15 -04002076 for (int shift = 24; shift < 32; ++shift) {
2077 int width = 1 << shift;
Cary Clark682c58d2018-05-16 07:07:07 -04002078 SkImageInfo imageInfo =
Cary Clark681287e2018-03-16 11:34:15 -04002079 SkImageInfo::Make(width, 1, kRGBA_F16_SkColorType, kPremul_SkAlphaType);
2080 uint64_t minRowBytes = imageInfo.minRowBytes64();
2081 bool widthTooLarge = (uint64_t) (int32_t) minRowBytes != minRowBytes;
2082 SkDebugf("RGBA_F16 width %d (0x%08x) %s\n",
Cary Clark682c58d2018-05-16 07:07:07 -04002083 width, width, widthTooLarge ? "too large" : "OK");
Cary Clark681287e2018-03-16 11:34:15 -04002084 }
2085#StdOut
2086RGBA_F16 width 16777216 (0x01000000) OK
2087RGBA_F16 width 33554432 (0x02000000) OK
2088RGBA_F16 width 67108864 (0x04000000) OK
2089RGBA_F16 width 134217728 (0x08000000) OK
2090RGBA_F16 width 268435456 (0x10000000) too large
2091RGBA_F16 width 536870912 (0x20000000) too large
2092RGBA_F16 width 1073741824 (0x40000000) too large
2093RGBA_F16 width -2147483648 (0x80000000) too large
2094##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002095##
2096
Cary Clark681287e2018-03-16 11:34:15 -04002097#SeeAlso minRowBytes computeByteSize computeMinByteSize validRowBytes
Cary Clark2dc84ad2018-01-26 12:56:22 -05002098
2099#Method ##
2100
2101# ------------------------------------------------------------------------------
2102
2103#Method size_t minRowBytes() const
Cary Clark78de7512018-02-07 07:27:09 -05002104#In Property
Cary Clark681287e2018-03-16 11:34:15 -04002105#Line # returns width() times bytesPerPixel in 32 bits ##
2106
2107Returns minimum bytes per row, computed from pixel width() and Color_Type, which
Cary Clark682c58d2018-05-16 07:07:07 -04002108specifies bytesPerPixel(). Bitmap maximum value for row bytes must fit
2109in 31 bits.
Cary Clark681287e2018-03-16 11:34:15 -04002110
2111#Return width() times bytesPerPixel as signed 32-bit integer ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002112
2113#Example
Cary Clark681287e2018-03-16 11:34:15 -04002114 for (int shift = 24; shift < 32; ++shift) {
2115 int width = 1 << shift;
Cary Clark682c58d2018-05-16 07:07:07 -04002116 SkImageInfo imageInfo =
Cary Clark681287e2018-03-16 11:34:15 -04002117 SkImageInfo::Make(width, 1, kRGBA_F16_SkColorType, kPremul_SkAlphaType);
2118 size_t minRowBytes = imageInfo.minRowBytes();
2119 bool widthTooLarge = !minRowBytes;
2120 SkDebugf("RGBA_F16 width %d (0x%08x) %s\n",
Cary Clark682c58d2018-05-16 07:07:07 -04002121 width, width, widthTooLarge ? "too large" : "OK");
Cary Clark681287e2018-03-16 11:34:15 -04002122 }
2123#StdOut
2124RGBA_F16 width 16777216 (0x01000000) OK
2125RGBA_F16 width 33554432 (0x02000000) OK
2126RGBA_F16 width 67108864 (0x04000000) OK
2127RGBA_F16 width 134217728 (0x08000000) OK
2128RGBA_F16 width 268435456 (0x10000000) too large
2129RGBA_F16 width 536870912 (0x20000000) too large
2130RGBA_F16 width 1073741824 (0x40000000) too large
2131RGBA_F16 width -2147483648 (0x80000000) too large
2132##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002133##
2134
Cary Clark681287e2018-03-16 11:34:15 -04002135#SeeAlso minRowBytes64 computeByteSize computeMinByteSize validRowBytes
Cary Clark2dc84ad2018-01-26 12:56:22 -05002136
2137#Method ##
2138
2139# ------------------------------------------------------------------------------
2140
2141#Method size_t computeOffset(int x, int y, size_t rowBytes) const
Cary Clark78de7512018-02-07 07:27:09 -05002142#In Utility
Cary Clark681287e2018-03-16 11:34:15 -04002143#Line # returns byte offset within pixel array ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002144
Cary Clark681287e2018-03-16 11:34:15 -04002145Returns byte offset of pixel from pixel base address.
2146
2147Asserts in debug build if x or y is outside of bounds. Does not assert if
2148rowBytes is smaller than minRowBytes, even though result may be incorrect.
2149
2150#Param x column index, zero or greater, and less than width() ##
2151#Param y row index, zero or greater, and less than height() ##
2152#Param rowBytes size of pixel row or larger ##
2153
2154#Return offset within pixel array ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002155
2156#Example
Cary Clark06c20f32018-03-20 15:53:27 -04002157#Height 128
Cary Clark681287e2018-03-16 11:34:15 -04002158 uint8_t pixels[][12] = { { 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00},
2159 { 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00},
2160 { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00},
2161 { 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF},
2162 { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
2163 { 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00},
2164 { 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00},
2165 { 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00} };
2166 SkImageInfo imageInfo = SkImageInfo::MakeA8(8, 8);
2167 SkBitmap bitmap;
2168 bitmap.installPixels(imageInfo, (void*) pixels, sizeof(pixels[0]));
2169 SkPaint paint;
2170 paint.setColor(SK_ColorRED);
2171 canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), SkRect::MakeWH(32, 32), &paint);
2172 size_t offset = imageInfo.computeOffset(2, 3, sizeof(pixels[0]));
2173 pixels[0][offset] = 0x7F;
2174 offset = imageInfo.computeOffset(5, 3, sizeof(pixels[0]));
2175 pixels[0][offset] = 0x7F;
2176 bitmap.installPixels(imageInfo, (void*) pixels, sizeof(pixels[0]));
2177 canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), SkRect::MakeWH(128, 128), &paint);
Cary Clark2dc84ad2018-01-26 12:56:22 -05002178##
2179
Cary Clark06c20f32018-03-20 15:53:27 -04002180#SeeAlso height width minRowBytes computeByteSize
Cary Clark2dc84ad2018-01-26 12:56:22 -05002181
2182#Method ##
2183
2184# ------------------------------------------------------------------------------
Cary Clark78de7512018-02-07 07:27:09 -05002185#Subtopic Operator
2186#Populate
2187##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002188
2189#Method bool operator==(const SkImageInfo& other)_const
Cary Clark06c20f32018-03-20 15:53:27 -04002190#Line # compares Image_Info for equality ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002191
Cary Clark06c20f32018-03-20 15:53:27 -04002192Compares Image_Info with other, and returns true if width, height, Color_Type,
2193Alpha_Type, and Color_Space are equivalent.
Cary Clark2dc84ad2018-01-26 12:56:22 -05002194
Cary Clark06c20f32018-03-20 15:53:27 -04002195#Param other Image_Info to compare ##
2196
2197#Return true if Image_Info equals other ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002198
2199#Example
Cary Clark682c58d2018-05-16 07:07:07 -04002200 SkImageInfo info1 = SkImageInfo::Make(10, 20, kGray_8_SkColorType, kPremul_SkAlphaType);
2201 SkImageInfo info2 = SkImageInfo::Make(20, 10, kAlpha_8_SkColorType, kUnpremul_SkAlphaType);
2202 SkDebugf("info1 %c= info2\n", info1 == info2 ? '=' : '!');
2203 info2 = info2.makeWH(10, 20);
2204 SkDebugf("info1 %c= info2\n", info1 == info2 ? '=' : '!');
2205 info2 = info2.makeColorType(kGray_8_SkColorType);
2206 SkDebugf("info1 %c= info2\n", info1 == info2 ? '=' : '!');
2207 info2 = info2.makeAlphaType(kPremul_SkAlphaType);
2208 SkDebugf("info1 %c= info2\n", info1 == info2 ? '=' : '!');
2209#StdOut
2210info1 != info2
2211info1 != info2
2212info1 != info2
2213info1 == info2
2214##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002215##
2216
Cary Clark06c20f32018-03-20 15:53:27 -04002217#SeeAlso operator!=(const SkImageInfo& other)_const SkColorSpace::Equals
Cary Clark2dc84ad2018-01-26 12:56:22 -05002218
2219#Method ##
2220
2221# ------------------------------------------------------------------------------
2222
2223#Method bool operator!=(const SkImageInfo& other)_const
Cary Clark06c20f32018-03-20 15:53:27 -04002224#Line # compares Image_Info for inequality ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002225
Cary Clark06c20f32018-03-20 15:53:27 -04002226Compares Image_Info with other, and returns true if width, height, Color_Type,
Cary Clarkffb3d682018-05-17 12:17:28 -04002227Alpha_Type, and Color_Space are not equivalent.
Cary Clark2dc84ad2018-01-26 12:56:22 -05002228
Cary Clark06c20f32018-03-20 15:53:27 -04002229#Param other Image_Info to compare ##
2230
2231#Return true if Image_Info is not equal to other ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002232
2233#Example
Cary Clark682c58d2018-05-16 07:07:07 -04002234 SkImageInfo info1 = SkImageInfo::Make(10, 20, kGray_8_SkColorType, kPremul_SkAlphaType);
2235 SkImageInfo info2 = SkImageInfo::Make(20, 10, kAlpha_8_SkColorType, kUnpremul_SkAlphaType);
2236 SkDebugf("info1 %c= info2\n", info1 != info2 ? '!' : '=');
2237 info2 = info2.makeWH(10, 20);
2238 SkDebugf("info1 %c= info2\n", info1 != info2 ? '!' : '=');
2239 info2 = info2.makeColorType(kGray_8_SkColorType);
2240 SkDebugf("info1 %c= info2\n", info1 != info2 ? '!' : '=');
2241 info2 = info2.makeAlphaType(kPremul_SkAlphaType);
2242 SkDebugf("info1 %c= info2\n", info1 != info2 ? '!' : '=');
2243#StdOut
2244info1 != info2
2245info1 != info2
2246info1 != info2
2247info1 == info2
2248##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002249##
2250
Cary Clark06c20f32018-03-20 15:53:27 -04002251#SeeAlso operator==(const SkImageInfo& other)_const SkColorSpace::Equals
Cary Clark2dc84ad2018-01-26 12:56:22 -05002252
2253#Method ##
2254
2255# ------------------------------------------------------------------------------
2256
2257#Method size_t computeByteSize(size_t rowBytes) const
Cary Clark78de7512018-02-07 07:27:09 -05002258#In Utility
Cary Clark682c58d2018-05-16 07:07:07 -04002259#Line # returns memory required by pixel buffer with given row bytes ##
Cary Clark06c20f32018-03-20 15:53:27 -04002260Returns storage required by pixel array, given Image_Info dimensions, Color_Type,
2261and rowBytes. rowBytes is assumed to be at least as large as minRowBytes().
Cary Clark2dc84ad2018-01-26 12:56:22 -05002262
Cary Clark06c20f32018-03-20 15:53:27 -04002263Returns zero if height is zero.
Cary Clark63132862018-06-18 07:26:34 -04002264Returns SIZE_MAX if answer exceeds the range of size_t.
Cary Clark2dc84ad2018-01-26 12:56:22 -05002265
Cary Clark06c20f32018-03-20 15:53:27 -04002266#Param rowBytes size of pixel row or larger ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002267
Cary Clark06c20f32018-03-20 15:53:27 -04002268#Return memory required by pixel buffer ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002269
2270#Example
Cary Clark06c20f32018-03-20 15:53:27 -04002271#Height 130
Cary Clark682c58d2018-05-16 07:07:07 -04002272 SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);
2273 const size_t size = info.computeByteSize(100000);
2274 SkAutoTMalloc<SkPMColor> storage(size);
2275 SkPMColor* pixels = storage.get();
2276 SkBitmap bitmap;
2277 bitmap.setInfo(info);
2278 bitmap.setPixels(pixels);
2279 bitmap.eraseColor(SK_ColorRED);
2280 canvas->scale(50, 50);
2281 canvas->rotate(8);
Cary Clark06c20f32018-03-20 15:53:27 -04002282 canvas->drawBitmap(bitmap, 2, 0);
Cary Clark2dc84ad2018-01-26 12:56:22 -05002283##
2284
Cary Clark06c20f32018-03-20 15:53:27 -04002285#SeeAlso computeMinByteSize validRowBytes
Cary Clark2dc84ad2018-01-26 12:56:22 -05002286
2287#Method ##
2288
2289# ------------------------------------------------------------------------------
2290
2291#Method size_t computeMinByteSize() const
Cary Clark78de7512018-02-07 07:27:09 -05002292#In Utility
Cary Clark682c58d2018-05-16 07:07:07 -04002293#Line # returns least memory required by pixel buffer ##
2294Returns storage required by pixel array, given Image_Info dimensions, and
Cary Clark06c20f32018-03-20 15:53:27 -04002295Color_Type. Uses minRowBytes() to compute bytes for pixel row.
Cary Clark2dc84ad2018-01-26 12:56:22 -05002296
Cary Clark06c20f32018-03-20 15:53:27 -04002297Returns zero if height is zero.
Cary Clark63132862018-06-18 07:26:34 -04002298Returns SIZE_MAX if answer exceeds the range of size_t.
Cary Clark06c20f32018-03-20 15:53:27 -04002299
2300#Return least memory required by pixel buffer ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002301
2302#Example
Cary Clark06c20f32018-03-20 15:53:27 -04002303#Height 130
Cary Clark682c58d2018-05-16 07:07:07 -04002304 SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);
2305 const size_t size = info.computeMinByteSize();
2306 SkAutoTMalloc<SkPMColor> storage(size);
2307 SkPMColor* pixels = storage.get();
2308 SkBitmap bitmap;
2309 bitmap.setInfo(info);
2310 bitmap.setPixels(pixels);
2311 bitmap.eraseColor(SK_ColorRED);
2312 canvas->scale(50, 50);
2313 canvas->rotate(8);
Cary Clark06c20f32018-03-20 15:53:27 -04002314 canvas->drawBitmap(bitmap, 2, 0);
Cary Clark2dc84ad2018-01-26 12:56:22 -05002315##
2316
Cary Clark06c20f32018-03-20 15:53:27 -04002317#SeeAlso computeByteSize validRowBytes
Cary Clark2dc84ad2018-01-26 12:56:22 -05002318
2319#Method ##
2320
2321# ------------------------------------------------------------------------------
2322
2323#Method static bool ByteSizeOverflowed(size_t byteSize)
Cary Clark78de7512018-02-07 07:27:09 -05002324#In Utility
Cary Clark06c20f32018-03-20 15:53:27 -04002325#Line # checks result of computeByteSize and computeMinByteSize ##
Cary Clark63132862018-06-18 07:26:34 -04002326Returns true if byteSize equals SIZE_MAX. computeByteSize and
2327computeMinByteSize return SIZE_MAX if size_t can not hold buffer size.
Cary Clark2dc84ad2018-01-26 12:56:22 -05002328
Cary Clark06c20f32018-03-20 15:53:27 -04002329#Param byteSize result of computeByteSize or computeMinByteSize ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002330
Cary Clark06c20f32018-03-20 15:53:27 -04002331#Return true if computeByteSize or computeMinByteSize result exceeds size_t ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002332
2333#Example
Cary Clark682c58d2018-05-16 07:07:07 -04002334 SkImageInfo info = SkImageInfo::MakeN32Premul(2, 1000000000);
2335 for (size_t rowBytes = 100000000; rowBytes < 10000000000000LL; rowBytes *= 10) {
2336 const size_t size = info.computeByteSize(rowBytes);
2337 SkDebugf("rowBytes:%llu size:%llu overflowed:%s\n", rowBytes, size,
2338 SkImageInfo::ByteSizeOverflowed(size) ? "true" : "false");
2339 }
2340#StdOut
2341rowBytes:100000000 size:99999999900000008 overflowed:false
2342rowBytes:1000000000 size:999999999000000008 overflowed:false
2343rowBytes:10000000000 size:9999999990000000008 overflowed:false
2344rowBytes:100000000000 size:18446744073709551615 overflowed:true
2345rowBytes:1000000000000 size:18446744073709551615 overflowed:true
2346##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002347##
2348
Cary Clark06c20f32018-03-20 15:53:27 -04002349#SeeAlso computeByteSize computeMinByteSize validRowBytes
Cary Clark2dc84ad2018-01-26 12:56:22 -05002350
2351#Method ##
2352
2353# ------------------------------------------------------------------------------
2354
2355#Method bool validRowBytes(size_t rowBytes) const
Cary Clark78de7512018-02-07 07:27:09 -05002356#In Utility
Cary Clark06c20f32018-03-20 15:53:27 -04002357#Line # checks if row bytes is large enough to contain pixel row ##
2358Returns true if rowBytes is smaller than width times pixel size.
Cary Clark2dc84ad2018-01-26 12:56:22 -05002359
Cary Clark06c20f32018-03-20 15:53:27 -04002360#Param rowBytes size of pixel row or larger ##
2361
2362#Return true if rowBytes is large enough to contain pixel row ##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002363
2364#Example
Cary Clark682c58d2018-05-16 07:07:07 -04002365 SkImageInfo info = SkImageInfo::MakeN32Premul(16, 8);
2366 for (size_t rowBytes = 60; rowBytes < 72; rowBytes += sizeof(SkPMColor)) {
2367 SkDebugf("validRowBytes(%llu): %s\n", rowBytes, info.validRowBytes(rowBytes) ?
2368 "true" : "false");
2369 }
2370#StdOut
2371validRowBytes(60): false
2372validRowBytes(64): true
2373validRowBytes(68): true
2374##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002375##
2376
Cary Clark06c20f32018-03-20 15:53:27 -04002377#SeeAlso ByteSizeOverflowed computeByteSize computeMinByteSize
Cary Clark2dc84ad2018-01-26 12:56:22 -05002378
2379#Method ##
2380
2381# ------------------------------------------------------------------------------
2382
2383#Method void reset()
Cary Clark78de7512018-02-07 07:27:09 -05002384#In Constructor
Cary Clark06c20f32018-03-20 15:53:27 -04002385#Line # sets zero dimensions, kUnknown_SkColorType, kUnknown_SkAlphaType ##
2386Creates an empty Image_Info with kUnknown_SkColorType, kUnknown_SkAlphaType,
2387a width and height of zero, and no Color_Space.
2388
Cary Clark2dc84ad2018-01-26 12:56:22 -05002389#Example
Cary Clark682c58d2018-05-16 07:07:07 -04002390 SkImageInfo info = SkImageInfo::MakeN32Premul(16, 8);
2391 SkImageInfo copy = info;
2392 SkDebugf("info %c= copy\n", info == copy ? '=' : '!');
2393 copy.reset();
2394 SkDebugf("info %c= reset copy\n", info == copy ? '=' : '!');
2395 SkDebugf("SkImageInfo() %c= reset copy\n", SkImageInfo() == copy ? '=' : '!');
2396#StdOut
2397info == copy
2398info != reset copy
2399SkImageInfo() == reset copy
2400##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002401##
2402
Cary Clark06c20f32018-03-20 15:53:27 -04002403#SeeAlso SkImageInfo()
Cary Clark2dc84ad2018-01-26 12:56:22 -05002404
2405#Method ##
2406
2407# ------------------------------------------------------------------------------
Cary Clark78de7512018-02-07 07:27:09 -05002408#Subtopic Utility
2409#Populate
2410#Line # rarely called management functions ##
2411##
Cary Clark2dc84ad2018-01-26 12:56:22 -05002412
2413#Method void validate() const
Cary Clark78de7512018-02-07 07:27:09 -05002414#In Utility
Cary Clark06c20f32018-03-20 15:53:27 -04002415#Line # asserts if Image_Info is invalid (debug only) ##
Cary Clark682c58d2018-05-16 07:07:07 -04002416Asserts if internal values are illegal or inconsistent. Only available if
Cary Clark06c20f32018-03-20 15:53:27 -04002417SK_DEBUG is defined at compile time.
2418
2419#NoExample
Cary Clark2dc84ad2018-01-26 12:56:22 -05002420##
2421
Cary Clark06c20f32018-03-20 15:53:27 -04002422#SeeAlso validRowBytes SkBitmap::validate
Cary Clark2dc84ad2018-01-26 12:56:22 -05002423
2424#Method ##
2425
2426#Struct SkImageInfo ##
2427
Cary Clark08895c42018-02-01 09:37:32 -05002428#Topic Image_Info ##