diff options
author | Cary Clark <caryclark@skia.org> | 2018-02-27 09:54:21 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-27 15:12:59 +0000 |
commit | f895a420c93f18df10dc95da182025847a0e061a (patch) | |
tree | 8108cfdf8afa28275f7abc3df54d428973ae0dda /site/user | |
parent | 0a3b12bbcec77cb7007e0c3421a84affdc27a146 (diff) |
work on skimageinfo
work on skimageinfo
Docs-Preview: https://skia.org/?cl=109081
TBR=caryclark@google.com
Bug: skia:6898
Change-Id: I4d1734647ef1fa879d08b04c64142c7f16abc858
Reviewed-on: https://skia-review.googlesource.com/109081
Commit-Queue: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'site/user')
-rw-r--r-- | site/user/api/SkBitmap_Reference.md | 4 | ||||
-rw-r--r-- | site/user/api/SkImageInfo_Reference.md | 276 | ||||
-rw-r--r-- | site/user/api/SkImage_Reference.md | 33 | ||||
-rw-r--r-- | site/user/api/SkPaint_Reference.md | 2 | ||||
-rw-r--r-- | site/user/api/catalog.htm | 184 | ||||
-rw-r--r-- | site/user/api/undocumented.md | 47 |
6 files changed, 450 insertions, 96 deletions
diff --git a/site/user/api/SkBitmap_Reference.md b/site/user/api/SkBitmap_Reference.md index bd407fe7d1..54a2db3172 100644 --- a/site/user/api/SkBitmap_Reference.md +++ b/site/user/api/SkBitmap_Reference.md @@ -3464,7 +3464,7 @@ bool extractAlpha(SkBitmap* dst, const SkPaint* paint, SkIPoint* offset) const Sets <a href="#SkBitmap_extractAlpha_2_dst">dst</a> to <a href="undocumented#Alpha">Alpha</a> described by pixels. Returns false if <a href="#SkBitmap_extractAlpha_2_dst">dst</a> cannot be written to or <a href="#SkBitmap_extractAlpha_2_dst">dst</a> pixels cannot be allocated. -If <a href="#SkBitmap_extractAlpha_2_paint">paint</a> is not nullptr and contains <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#SkMaskFilter_filterMask">SkMaskFilter::filterMask</a> +If <a href="#SkBitmap_extractAlpha_2_paint">paint</a> is not nullptr and contains <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#SkMaskFilter">SkMaskFilter</a> generates <a href="undocumented#Mask_Alpha">Mask Alpha</a> from <a href="#Bitmap">Bitmap</a>. Uses <a href="#SkBitmap_HeapAllocator">HeapAllocator</a> to reserve memory for <a href="#SkBitmap_extractAlpha_2_dst">dst</a> <a href="undocumented#Pixel_Ref">Pixel Ref</a>. Sets <a href="#SkBitmap_extractAlpha_2_offset">offset</a> to top-left position for <a href="#SkBitmap_extractAlpha_2_dst">dst</a> for alignment with <a href="#Bitmap">Bitmap</a>; (0, 0) unless <a href="undocumented#SkMaskFilter">SkMaskFilter</a> generates mask. @@ -3503,7 +3503,7 @@ bool extractAlpha(SkBitmap* dst, const SkPaint* paint, Allocator* allocator, SkI Sets <a href="#SkBitmap_extractAlpha_3_dst">dst</a> to <a href="undocumented#Alpha">Alpha</a> described by pixels. Returns false if <a href="#SkBitmap_extractAlpha_3_dst">dst</a> cannot be written to or <a href="#SkBitmap_extractAlpha_3_dst">dst</a> pixels cannot be allocated. -If <a href="#SkBitmap_extractAlpha_3_paint">paint</a> is not nullptr and contains <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#SkMaskFilter_filterMask">SkMaskFilter::filterMask</a> +If <a href="#SkBitmap_extractAlpha_3_paint">paint</a> is not nullptr and contains <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#SkMaskFilter">SkMaskFilter</a> generates <a href="undocumented#Mask_Alpha">Mask Alpha</a> from <a href="#Bitmap">Bitmap</a>. <a href="#SkBitmap_extractAlpha_3_allocator">allocator</a> may reference a custom allocation class or be set to nullptr to use <a href="#SkBitmap_HeapAllocator">HeapAllocator</a>. Sets <a href="#SkBitmap_extractAlpha_3_offset">offset</a> to top-left position for <a href="#SkBitmap_extractAlpha_3_dst">dst</a> for alignment with <a href="#Bitmap">Bitmap</a>; (0, 0) unless <a href="undocumented#SkMaskFilter">SkMaskFilter</a> generates diff --git a/site/user/api/SkImageInfo_Reference.md b/site/user/api/SkImageInfo_Reference.md index c71dbab526..2584d0ecd8 100644 --- a/site/user/api/SkImageInfo_Reference.md +++ b/site/user/api/SkImageInfo_Reference.md @@ -2,6 +2,15 @@ SkImageInfo Reference === # <a name="Image_Info"></a> Image Info +<a href="#Image_Info">Image Info</a> specifies the dimensions and encoding of the pixels in a <a href="SkBitmap_Reference#Bitmap">Bitmap</a>. +The dimensions are integral width and height. The encoding is how pixel +bits describe <a href="undocumented#Alpha">Color Alpha</a>, transparency; <a href="undocumented#Color">Color</a> components red, blue, +and green; and <a href="undocumented#Color_Space">Color Space</a>, the range and linearity of colors. + +<a href="#Image_Info">Image Info</a> describes an uncompressed raster pixels. In contrast, <a href="SkImage_Reference#Image">Image</a> +additionally describes compressed pixels like PNG, and <a href="SkSurface_Reference#Surface">Surface</a> describes +destinations on the GPU. <a href="SkImage_Reference#Image">Image</a> and <a href="SkSurface_Reference#Surface">Surface</a> may be specified by <a href="#Image_Info">Image Info</a>, +but <a href="SkImage_Reference#Image">Image</a> and <a href="SkSurface_Reference#Surface">Surface</a> may not contain <a href="#Image_Info">Image Info</a>. ## <a name="Overview"></a> Overview @@ -32,38 +41,92 @@ enum <a href="#SkAlphaType">SkAlphaType</a> { kLastEnum_SkAlphaType = <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a>, };</pre> -Describes how to interpret the alpha component of a pixel. +Describes how to interpret the alpha component of a pixel. A pixel may +be opaque, or <a href="undocumented#Alpha">Color Alpha</a>, describing multiple levels of transparency. + +In simple blending, <a href="undocumented#Alpha">Color Alpha</a> weights the draw color and the destination +color to create a new color. If alpha describes a weight from zero to one: + +new color = draw color * alpha + destination color * (1 - alpha)In practice alpha is encoded in two or more bits, where 1.0 equals all bits set. + +<a href="undocumented#RGB">Color RGB</a> may have <a href="undocumented#Alpha">Color Alpha</a> included in each component value; the stored +value is the original <a href="undocumented#RGB">Color RGB</a> multiplied by <a href="undocumented#Alpha">Color Alpha</a>. <a href="undocumented#Premultiply">Premultiplied</a> color +components improve performance. ### Constants <table> <tr> - <td><a name="kUnknown_SkAlphaType"> <code><strong>kUnknown_SkAlphaType </strong></code> </a></td><td>0</td><td></td> + <td><a name="kUnknown_SkAlphaType"> <code><strong>kUnknown_SkAlphaType </strong></code> </a></td><td>0</td><td><a href="#Alpha_Type">Alpha Type</a> is uninitialized.</td> </tr> <tr> - <td><a name="kOpaque_SkAlphaType"> <code><strong>kOpaque_SkAlphaType </strong></code> </a></td><td>1</td><td>All pixels are stored as opaque.</td> + <td><a name="kOpaque_SkAlphaType"> <code><strong>kOpaque_SkAlphaType </strong></code> </a></td><td>1</td><td>Pixels are opaque. The <a href="#Color_Type">Color Type</a> must have no explicit alpha +component, or all alpha components must be set to their maximum value.</td> </tr> <tr> - <td><a name="kPremul_SkAlphaType"> <code><strong>kPremul_SkAlphaType </strong></code> </a></td><td>2</td><td>All pixels have their alpha premultiplied in their color components. -This is the natural format for the rendering target pixels.</td> + <td><a name="kPremul_SkAlphaType"> <code><strong>kPremul_SkAlphaType </strong></code> </a></td><td>2</td><td>Pixels have alpha premultiplied into color components. +<a href="SkSurface_Reference#Surface">Surface</a> pixels must be premultiplied.</td> </tr> <tr> - <td><a name="kUnpremul_SkAlphaType"> <code><strong>kUnpremul_SkAlphaType </strong></code> </a></td><td>3</td><td>All pixels have their color components stored without any regard to the -alpha. e.g. this is the default configuration for PNG images. -<a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a> is supported only for input images. Rendering cannot -generate this on output.</td> + <td><a name="kUnpremul_SkAlphaType"> <code><strong>kUnpremul_SkAlphaType </strong></code> </a></td><td>3</td><td><a href="undocumented#Pixel">Pixel</a> color component values are independent of alpha value. +Images generated from encoded data like PNG do not premultiply pixel color +components. <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a> is supported for <a href="SkImage_Reference#Image">Image</a> pixels, but not for +<a href="SkSurface_Reference#Surface">Surface</a> pixels.</td> </tr> </table> +### See Also + +<a href="#SkColorType">SkColorType</a> <a href="undocumented#SkColorSpace">SkColorSpace</a> + + + +## <a name="Alpha_Type_Opaque"></a> Alpha Type Opaque + +Use <a href="#Alpha_Type_Opaque">Opaque</a> as a hint to optimize drawing when alpha component +of all pixel is set to its maximum value of 1.0; all alpha component bits are set. +If <a href="#Image_Info">Image Info</a> is set to <a href="#Alpha_Type_Opaque">Opaque</a> but all alpha values are not 1.0, results are +undefined. + ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="79146a1a41d58d22582fdc567c6ffe4e"><div><a href="undocumented#SkPreMultiplyARGB">SkPreMultiplyARGB</a> parameter a is set to 255, its maximum value, and is interpreted +as <a href="undocumented#Alpha">Color Alpha</a> of 1.0. <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a> may be set to improve performance. +If <a href="undocumented#SkPreMultiplyARGB">SkPreMultiplyARGB</a> parameter a is set to a value smaller than 255, +<a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a> must be used instead to avoid undefined results. +The four displayed values are the original component values, though not necessarily +in the same order.</div></fiddle-embed></div> -### See Also +## <a name="Alpha_Type_Premul"></a> Alpha Type Premul -incomplete +Use <a href="#Alpha_Type_Premul">Premul</a> when stored color components are the original color multiplied by the +alpha component. The alpha component range of 0.0 to 1.0 is achieved by dividing +the integer bit value by the maximum bit value. + +stored color = original color * alpha / max alphaThe color component must be equal to or smaller than the alpha component, +or the results are undefined. + +### Example + +<div><fiddle-embed name="ad696b39c915803d566e96896ec3a36c"><div><a href="undocumented#SkPreMultiplyARGB">SkPreMultiplyARGB</a> parameter a is set to 150, less than its maximum value, and is +interpreted as <a href="undocumented#Alpha">Color Alpha</a> of about 0.6. <a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a> must be set, since +<a href="undocumented#SkPreMultiplyARGB">SkPreMultiplyARGB</a> parameter a is set to a value smaller than 255, +to avoid undefined results. +The four displayed values reflect that the alpha component has been multiplied +by the original color.</div></fiddle-embed></div> +## <a name="Alpha_Type_Unpremul"></a> Alpha Type Unpremul +Use <a href="#Alpha_Type_Unpremul">Unpremul</a> if stored color components are not divided by the alpha component. +Some drawing destinations may not support <a href="#Alpha_Type_Unpremul">Unpremul</a>. + +### Example + +<div><fiddle-embed name="46e528e0c6b3f3e296d0d0930d638629"><div><a href="undocumented#SkColorSetARGB">SkColorSetARGB</a> parameter a is set to 150, less than its maximum value, and is +interpreted as <a href="undocumented#Alpha">Color Alpha</a> of about 0.6. color is not premultiplied; +color components may have values greater than color alpha. +The four displayed values are the original component values, though not necessarily +in the same order.</div></fiddle-embed></div> ## <a name="Color_Type"></a> Color Type @@ -89,7 +152,8 @@ kLastEnum_SkColorType = <a href="#kRGBA_F16_SkColorType">kRGBA_F16_SkColorType</ <a href="#kN32_SkColorType">kN32_SkColorType</a> = <a href="#kRGBA_8888_SkColorType">kRGBA_8888_SkColorType</a>, };</pre> -Describes how to interpret the components of a pixel. +Describes how pixel bits encode color. A pixel may be an alpha mask, a +gray level, <a href="undocumented#RGB">Color RGB</a>, or <a href="undocumented#ARGB">Color ARGB</a>. <a href="#kN32_SkColorType">kN32_SkColorType</a> selects the native 32-bit <a href="undocumented#ARGB">Color ARGB</a> format. On Little_Endian processors, pixels containing 8-bit <a href="undocumented#ARGB">Color ARGB</a> components pack into 32-bit @@ -103,34 +167,34 @@ processors, pixels containing 8-bit <a href="undocumented#ARGB">Color ARGB</a> c <td><a name="kUnknown_SkColorType"> <code><strong>kUnknown_SkColorType </strong></code> </a></td><td>0</td><td></td> </tr> <tr> - <td><a name="kAlpha_8_SkColorType"> <code><strong>kAlpha_8_SkColorType </strong></code> </a></td><td>1</td><td></td> + <td><a name="kAlpha_8_SkColorType"> <code><strong>kAlpha_8_SkColorType </strong></code> </a></td><td>1</td><td>Encodes <a href="undocumented#Alpha">Color Alpha</a> as <a href="#Color_Type_Alpha_8">Alpha 8</a> pixel in an 8-bit byte.</td> </tr> <tr> - <td><a name="kRGB_565_SkColorType"> <code><strong>kRGB_565_SkColorType </strong></code> </a></td><td>2</td><td></td> + <td><a name="kRGB_565_SkColorType"> <code><strong>kRGB_565_SkColorType </strong></code> </a></td><td>2</td><td>Encodes <a href="undocumented#RGB">Color RGB</a> as <a href="#Color_Type_BGR_565">BGR 565</a> pixel in a 16-bit word.</td> </tr> <tr> - <td><a name="kARGB_4444_SkColorType"> <code><strong>kARGB_4444_SkColorType </strong></code> </a></td><td>3</td><td></td> + <td><a name="kARGB_4444_SkColorType"> <code><strong>kARGB_4444_SkColorType </strong></code> </a></td><td>3</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as <a href="#Color_Type_ABGR_4444">ABGR 4444</a> pixel in a 16-bit word.</td> </tr> <tr> - <td><a name="kRGBA_8888_SkColorType"> <code><strong>kRGBA_8888_SkColorType </strong></code> </a></td><td>4</td><td></td> + <td><a name="kRGBA_8888_SkColorType"> <code><strong>kRGBA_8888_SkColorType </strong></code> </a></td><td>4</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as <a href="#Color_Type_RGBA_8888">RGBA 8888</a> pixel in a 32-bit word.</td> </tr> <tr> - <td><a name="kRGB_888x_SkColorType"> <code><strong>kRGB_888x_SkColorType </strong></code> </a></td><td>5</td><td></td> + <td><a name="kRGB_888x_SkColorType"> <code><strong>kRGB_888x_SkColorType </strong></code> </a></td><td>5</td><td>Encodes <a href="undocumented#RGB">Color RGB</a> as <a href="#Color_Type_RGB_888x">RGB 888x</a> pixel in a 32-bit word.</td> </tr> <tr> - <td><a name="kBGRA_8888_SkColorType"> <code><strong>kBGRA_8888_SkColorType </strong></code> </a></td><td>6</td><td></td> + <td><a name="kBGRA_8888_SkColorType"> <code><strong>kBGRA_8888_SkColorType </strong></code> </a></td><td>6</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as <a href="#Color_Type_BGRA_8888">BGRA 8888</a> pixel in a 32-bit word.</td> </tr> <tr> - <td><a name="kRGBA_1010102_SkColorType"> <code><strong>kRGBA_1010102_SkColorType </strong></code> </a></td><td>7</td><td></td> + <td><a name="kRGBA_1010102_SkColorType"> <code><strong>kRGBA_1010102_SkColorType </strong></code> </a></td><td>7</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as <a href="#Color_Type_RGBA_1010102">RGBA 1010102</a> pixel in a 32-bit word.</td> </tr> <tr> - <td><a name="kRGB_101010x_SkColorType"> <code><strong>kRGB_101010x_SkColorType </strong></code> </a></td><td>8</td><td></td> + <td><a name="kRGB_101010x_SkColorType"> <code><strong>kRGB_101010x_SkColorType </strong></code> </a></td><td>8</td><td>Encodes <a href="undocumented#RGB">Color RGB</a> as <a href="#Color_Type_RGB_101010x">RGB 101010x</a> pixel in a 32-bit word.</td> </tr> <tr> - <td><a name="kGray_8_SkColorType"> <code><strong>kGray_8_SkColorType </strong></code> </a></td><td>9</td><td></td> + <td><a name="kGray_8_SkColorType"> <code><strong>kGray_8_SkColorType </strong></code> </a></td><td>9</td><td>Encodes <a href="undocumented#Gray">Color Gray</a> as <a href="#Color_Type_Gray_8">Gray 8</a> in an 8-bit byte.</td> </tr> <tr> - <td><a name="kRGBA_F16_SkColorType"> <code><strong>kRGBA_F16_SkColorType </strong></code> </a></td><td>10</td><td></td> + <td><a name="kRGBA_F16_SkColorType"> <code><strong>kRGBA_F16_SkColorType </strong></code> </a></td><td>10</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as <a href="#Color_Type_RGBA_F16">RGBA F16</a> in a 64-bit word.</td> </tr> </table> @@ -138,19 +202,177 @@ processors, pixels containing 8-bit <a href="undocumented#ARGB">Color ARGB</a> c <table> <tr> - <td><a name="kN32_SkColorType"> <code><strong>kN32_SkColorType </strong></code> </a></td><td>4</td><td></td> + <td><a name="kN32_SkColorType"> <code><strong>kN32_SkColorType </strong></code> </a></td><td>4</td><td>Encodes <a href="undocumented#ARGB">Color ARGB</a> as either <a href="#Color_Type_RGBA_8888">RGBA 8888</a> or <a href="#Color_Type_BGRA_8888">BGRA 8888</a>, whichever +is native to the platform.</td> </tr> </table> +### See Also + +<a href="#SkAlphaType">SkAlphaType</a> <a href="undocumented#SkColorSpace">SkColorSpace</a> + + + +## <a name="Color_Type_Alpha_8"></a> Color Type Alpha 8 + +<a href="#Color_Type_Alpha_8">Alpha 8</a> is an 8-bit byte pixel encoding that represents transparency. A value of zero is +completely transparent; a value of 255 is completely opaque. <a href="SkBitmap_Reference#Bitmap">Bitmap</a> with <a href="#Color_Type_Alpha_8">Alpha 8</a> +pixels does not visibly draw, because its pixels have no color information. +The paired <a href="#SkAlphaType">SkAlphaType</a> is ignored. + ### Example -<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div> +<div><fiddle-embed name="21ae21e4ce53d2018e042dd457997300"><div><a href="#Color_Type_Alpha_8">Alpha 8</a> pixels can modify another draw. orangePaint fills the bounds of bitmap, +with its transparency set to alpha8 pixel value.</div></fiddle-embed></div> -### See Also +## <a name="Color_Type_BGR_565"></a> Color Type BGR 565 -incomplete +<a href="#Color_Type_BGR_565">BGR 565</a> is a 16-bit word pixel encoding that contains five bits of blue, +six bits of green, and five bits of red. <a href="#Color_Type_BGR_565">BGR 565</a> is fully opaque as if its +<a href="undocumented#Alpha">Color Alpha</a> was set to one, and should always be paired with <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>. + +![Color_Type_BGR_565](https://fiddle.skia.org/i/b674a54eb4188d5ce66c04cebdb61089_raster.png "") + +### Example + +<div><fiddle-embed name="54e4c690d64d73ba028c5b250c0d09f0"></fiddle-embed></div> + +## <a name="Color_Type_ABGR_4444"></a> Color Type ABGR 4444 + +<a href="#Color_Type_ABGR_4444">ABGR 4444</a> is a 16-bit word pixel encoding that contains four bits of alpha, +four bits of blue, four bits of green, and four bits of red. + +![Color_Type_ABGR_4444](https://fiddle.skia.org/i/0441bdba65a19aa72b75b7fa62d22121_raster.png "") + +If paired with <a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a>: blue, green, and red components are +premultiplied by the alpha value. If blue, green, or red is greater than alpha, +the drawn result is undefined. + +If paired with <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a>: alpha, blue, green, and red components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>: all alpha component values are at the maximum; +blue, green, and red components are fully opaque. If any alpha component is +less than 15, the drawn result is undefined. + +### Example + +<div><fiddle-embed name="f89e8200d225ccb839e50a1481db48e9"></fiddle-embed></div> + +## <a name="Color_Type_RGBA_8888"></a> Color Type RGBA 8888 + +<a href="#Color_Type_RGBA_8888">RGBA 8888</a> is a 32-bit word pixel encoding that contains eight bits of red, +eight bits of green, eight bits of blue, and eight bits of alpha. +![Color_Type_RGBA_8888](https://fiddle.skia.org/i/4ccd35f27fe73dce8cce8c75e18df23c_raster.png "") + +If paired with <a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a>: red, green, and blue components are +premultiplied by the alpha value. If red, green, or blue is greater than alpha, +the drawn result is undefined. + +If paired with <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a>: alpha, red, green, and blue components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>: all alpha component values are at the maximum; +red, green, and blue components are fully opaque. If any alpha component is +less than 255, the drawn result is undefined. + +On Big_Endian platforms, <a href="#Color_Type_RGBA_8888">RGBA 8888</a> is the native <a href="#Color_Type">Color Type</a>, and will have +the best performance. Use <a href="#kN32_SkColorType">kN32_SkColorType</a> to choose the best <a href="#Color_Type">Color Type</a> for +the platform at compile time. + +### Example + +<div><fiddle-embed name="f3b9effa700b1b95ce10caf422b020cd"></fiddle-embed></div> + +## <a name="Color_Type_RGB_888x"></a> Color Type RGB 888x + +<a href="#Color_Type_RGB_888x">RGB 888x</a> is a 32-bit word pixel encoding that contains eight bits of red, +eight bits of green, eight bits of blue, and eight unused bits. <a href="#Color_Type_RGB_888x">RGB 888x</a> is fully +opaque as if its <a href="undocumented#Alpha">Color Alpha</a> was set to one, and should always be paired with +<a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>. + +![Color_Type_RGB_888x](https://fiddle.skia.org/i/fecfe58c25cfc1b1e411e5eb50f7d8d1_raster.png "") + +### Example + +<div><fiddle-embed name="1e236c4c9ce0597c22186589fee9dc1e"></fiddle-embed></div> + +## <a name="Color_Type_BGRA_8888"></a> Color Type BGRA 8888 + +<a href="#Color_Type_BGRA_8888">BGRA 8888</a> is a 32-bit word pixel encoding that contains eight bits of blue, +eight bits of green, eight bits of red, and eight bits of alpha. + +![Color_Type_BGRA_8888](https://fiddle.skia.org/i/babd0e12db21a88c74d4e88aa40268ab_raster.png "") + +If paired with <a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a>: blue, green, and red components are +premultiplied by the alpha value. If blue, green, or red is greater than alpha, +the drawn result is undefined. + +If paired with <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a>: blue, green, red, and alpha components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>: all alpha component values are at the maximum; +blue, green, and red components are fully opaque. If any alpha component is +less than 255, the drawn result is undefined. + +On Little_Endian platforms, <a href="#Color_Type_BGRA_8888">BGRA 8888</a> is the native <a href="#Color_Type">Color Type</a>, and will have +the best performance. Use <a href="#kN32_SkColorType">kN32_SkColorType</a> to choose the best <a href="#Color_Type">Color Type</a> for +the platform at compile time. + +### Example + +<div><fiddle-embed name="fcadba68a4fe7253b1726487e12b1eeb"></fiddle-embed></div> + +## <a name="Color_Type_RGBA_1010102"></a> Color Type RGBA 1010102 + +<a href="#Color_Type_RGBA_1010102">RGBA 1010102</a> is a 32-bit word pixel encoding that contains ten bits of red, +ten bits of green, ten bits of blue, and two bits of alpha. Possible alpha +values are zero: fully transparent; one: 33% opaque; two: 67% opaque; +three: fully opaque. + +![Color_Type_RGBA_1010102](https://fiddle.skia.org/i/6c470410001ad8f1ee9f58204c66f1bb_raster.png "") + +If paired with <a href="#kPremul_SkAlphaType">kPremul_SkAlphaType</a>: red, green, and blue components are +premultiplied by the alpha value. If red, green, or blue is greater than the +alpha replicated to ten bits, the drawn result is undefined. + +If paired with <a href="#kUnpremul_SkAlphaType">kUnpremul_SkAlphaType</a>: alpha, red, green, and blue components +may have any value. There may be a performance penalty with unpremultipled +pixels. + +If paired with <a href="#kOpaque_SkAlphaType">kOpaque_SkAlphaType</a>: all alpha component values are at the maximum; +red, green, and blue components are fully opaque. If any alpha component is +less than 3, the drawn result is undefined. + +### Example + +<div><fiddle-embed name="1bf1a6f087b4f2f93962960902061a7a"></fiddle-embed></div> + +## <a name="Color_Type_RGB_101010x"></a> Color Type RGB 101010x + +![Color_Type_RGB_101010x](https://fiddle.skia.org/i/c22477b11dabaa3e3a0b5bb33a7733cd_raster.png "") + +### Example + +<div><fiddle-embed name="d975ec17354b1297841e4a31d3f6a5d5"></fiddle-embed></div> + +## <a name="Color_Type_Gray_8"></a> Color Type Gray 8 + +### Example + +<div><fiddle-embed name="93da0eb0b6722a4f33dc7dae094abf0b"></fiddle-embed></div> + +## <a name="Color_Type_RGBA_F16"></a> Color Type RGBA F16 + +![Color_Type_RGBA_F16](https://fiddle.skia.org/i/9344796c059ff5e4f057595e781905b3_raster.png "") + +### Example +<div><fiddle-embed name="1795410dffea303b08ba98ee78dc1556"></fiddle-embed></div> ## <a name="YUV_ColorSpace"></a> YUV ColorSpace diff --git a/site/user/api/SkImage_Reference.md b/site/user/api/SkImage_Reference.md index 9888b75790..78105422cc 100644 --- a/site/user/api/SkImage_Reference.md +++ b/site/user/api/SkImage_Reference.md @@ -73,6 +73,7 @@ drawing. | <a href="#SkImage_MakeCrossContextFromEncoded">MakeCrossContextFromEncoded</a> | creates <a href="#Image">Image</a> from encoded data, and uploads to GPU | | <a href="#SkImage_MakeCrossContextFromPixmap">MakeCrossContextFromPixmap</a> | creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a>, and uploads to GPU | | <a href="#SkImage_MakeFromAHardwareBuffer">MakeFromAHardwareBuffer</a> | creates <a href="#Image">Image</a> from Android hardware buffer | +| <a href="#SkImage_MakeFromAdoptedTexture_2">MakeFromAdoptedTexture 2</a> | creates <a href="#Image">Image</a> from <a href="undocumented#GPU_Texture">GPU Texture</a>, managed internally | | <a href="#SkImage_MakeFromBitmap">MakeFromBitmap</a> | creates <a href="#Image">Image</a> from <a href="SkBitmap_Reference#Bitmap">Bitmap</a>, sharing or copying pixels | | <a href="#SkImage_MakeFromEncoded">MakeFromEncoded</a> | creates <a href="#Image">Image</a> from encoded data | | <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> | creates <a href="#Image">Image</a> from a stream of data | @@ -81,6 +82,8 @@ drawing. | | <a href="#SkImage_MakeFromNV12TexturesCopy_2">MakeFromNV12TexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendTexture nv12TextureHandles[2], const SkISize nv12Sizes[2], GrSurfaceOrigin surfaceOrigin, sk sp<SkColorSpace> colorSpace = nullptr)</a> | | <a href="#SkImage_MakeFromPicture">MakeFromPicture</a> | creates <a href="#Image">Image</a> from <a href="undocumented#Picture">Picture</a> | | <a href="#SkImage_MakeFromRaster">MakeFromRaster</a> | creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a>, with release | +| <a href="#SkImage_MakeFromTexture_3">MakeFromTexture 3</a> | creates <a href="#Image">Image</a> from <a href="undocumented#GPU_Texture">GPU Texture</a> | +| | static <a href="undocumented#sk_sp">sk sp</a><<a href="#SkImage">SkImage</a>> <a href="#SkImage_MakeFromTexture_3">MakeFromTexture(GrContext* context, const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk sp<SkColorSpace> colorSpace)</a> | | <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy</a> | creates <a href="#Image">Image</a> from <a href="SkImageInfo_Reference#YUV_ColorSpace">YUV ColorSpace</a> data in three planes | | | <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendObject yuvTextureHandles[3], const SkISize yuvSizes[3], GrSurfaceOrigin surfaceOrigin, sk sp<SkColorSpace> colorSpace = nullptr)</a> | | | <a href="#SkImage_MakeFromYUVTexturesCopy_2">MakeFromYUVTexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendTexture yuvTextureHandles[3], const SkISize yuvSizes[3], GrSurfaceOrigin surfaceOrigin, sk sp<SkColorSpace> colorSpace = nullptr)</a> | @@ -105,12 +108,14 @@ drawing. | <a href="#SkImage_MakeCrossContextFromEncoded">MakeCrossContextFromEncoded</a> | creates <a href="#Image">Image</a> from encoded data, and uploads to GPU | | <a href="#SkImage_MakeCrossContextFromPixmap">MakeCrossContextFromPixmap</a> | creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a>, and uploads to GPU | | <a href="#SkImage_MakeFromAHardwareBuffer">MakeFromAHardwareBuffer</a> | creates <a href="#Image">Image</a> from Android hardware buffer | +| <a href="#SkImage_MakeFromAdoptedTexture_2">MakeFromAdoptedTexture 2</a> | creates <a href="#Image">Image</a> from <a href="undocumented#GPU_Texture">GPU Texture</a>, managed internally | | <a href="#SkImage_MakeFromBitmap">MakeFromBitmap</a> | creates <a href="#Image">Image</a> from <a href="SkBitmap_Reference#Bitmap">Bitmap</a>, sharing or copying pixels | | <a href="#SkImage_MakeFromEncoded">MakeFromEncoded</a> | creates <a href="#Image">Image</a> from encoded data | | <a href="#SkImage_MakeFromGenerator">MakeFromGenerator</a> | creates <a href="#Image">Image</a> from a stream of data | | <a href="#SkImage_MakeFromNV12TexturesCopy">MakeFromNV12TexturesCopy</a> | creates <a href="#Image">Image</a> from <a href="SkImageInfo_Reference#YUV_ColorSpace">YUV ColorSpace</a> data in two planes | | <a href="#SkImage_MakeFromPicture">MakeFromPicture</a> | creates <a href="#Image">Image</a> from <a href="undocumented#Picture">Picture</a> | | <a href="#SkImage_MakeFromRaster">MakeFromRaster</a> | creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a>, with release | +| <a href="#SkImage_MakeFromTexture_3">MakeFromTexture 3</a> | creates <a href="#Image">Image</a> from <a href="undocumented#GPU_Texture">GPU Texture</a> | | <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy</a> | creates <a href="#Image">Image</a> from <a href="SkImageInfo_Reference#YUV_ColorSpace">YUV ColorSpace</a> data in three planes | | <a href="#SkImage_MakeRasterCopy">MakeRasterCopy</a> | creates <a href="#Image">Image</a> from <a href="SkPixmap_Reference#Pixmap">Pixmap</a> and copied pixels | | <a href="#SkImage_MakeRasterData">MakeRasterData</a> | creates <a href="#Image">Image</a> from <a href="SkImageInfo_Reference#Image_Info">Image Info</a> and shared pixels | @@ -416,7 +421,6 @@ created <a href="#Image">Image</a>, or nullptr --- <a name="SkImage_MakeFromTexture"></a> -## MakeFromTexture <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> static sk_sp<SkImage> MakeFromTexture(GrContext* context, const GrBackendTexture& backendTexture, @@ -439,6 +443,7 @@ static sk_sp<SkImage> MakeFromTexture(GrContext* context, const GrBackendT --- <a name="SkImage_MakeFromTexture_3"></a> +## MakeFromTexture_3 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> static sk_sp<SkImage> MakeFromTexture(GrContext* context, const GrBackendTexture& backendTexture, @@ -483,7 +488,7 @@ created <a href="#Image">Image</a>, or nullptr ### See Also -<a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a><sup><a href="#SkImage_MakeFromAdoptedTexture_2">[2]</a></sup> <a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture">SkSurface::MakeFromBackendTexture</a><sup><a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture_2">[2]</a></sup> +<a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a> <a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture">SkSurface::MakeFromBackendTexture</a><sup><a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture_2">[2]</a></sup> --- @@ -539,7 +544,7 @@ created <a href="#Image">Image</a>, or nullptr ### See Also -<a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a><sup><a href="#SkImage_MakeFromAdoptedTexture_2">[2]</a></sup> <a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture">SkSurface::MakeFromBackendTexture</a><sup><a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture_2">[2]</a></sup> +<a href="#SkImage_MakeFromAdoptedTexture">MakeFromAdoptedTexture</a> <a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture">SkSurface::MakeFromBackendTexture</a><sup><a href="SkSurface_Reference#SkSurface_MakeFromBackendTexture_2">[2]</a></sup> --- @@ -650,7 +655,6 @@ created <a href="#Image">Image</a>, or nullptr --- <a name="SkImage_MakeFromAdoptedTexture"></a> -## MakeFromAdoptedTexture <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context, @@ -663,13 +667,14 @@ static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context, --- <a name="SkImage_MakeFromAdoptedTexture_2"></a> +## MakeFromAdoptedTexture_2 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context, - const GrBackendTexture& backendTexture, - GrSurfaceOrigin surfaceOrigin, SkColorType colorType, - SkAlphaType alphaType = kPremul_SkAlphaType, - sk_sp<SkColorSpace> colorSpace = nullptr) + const GrBackendTexture& backendTexture, + GrSurfaceOrigin surfaceOrigin, SkColorType colorType, + SkAlphaType alphaType = kPremul_SkAlphaType, + sk_sp<SkColorSpace> colorSpace = nullptr) </pre> Creates <a href="#Image">Image</a> from <a href="#SkImage_MakeFromAdoptedTexture_2_backendTexture">backendTexture</a> associated with <a href="#SkImage_MakeFromAdoptedTexture_2_context">context</a>. <a href="#SkImage_MakeFromAdoptedTexture_2_backendTexture">backendTexture</a> and @@ -709,7 +714,7 @@ created <a href="#Image">Image</a>, or nullptr ### See Also -<a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy</a><sup><a href="#SkImage_MakeFromYUVTexturesCopy_2">[2]</a></sup> +<a href="#SkImage_MakeFromTexture">MakeFromTexture</a> <a href="#SkImage_MakeFromYUVTexturesCopy">MakeFromYUVTexturesCopy</a><sup><a href="#SkImage_MakeFromYUVTexturesCopy_2">[2]</a></sup> --- @@ -1448,7 +1453,7 @@ true if <a href="#Image">Image</a> is a <a href="undocumented#GPU_Texture">GPU T ### See Also -<a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> <a href="#SkImage_isValid">isValid</a> +<a href="#SkImage_MakeFromTexture">MakeFromTexture</a> <a href="#SkImage_isValid">isValid</a> --- @@ -1524,7 +1529,7 @@ back-end API texture handle, or nullptr ### See Also -<a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> <a href="#SkImage_isTextureBacked">isTextureBacked</a> +<a href="#SkImage_MakeFromTexture">MakeFromTexture</a> <a href="#SkImage_isTextureBacked">isTextureBacked</a> --- @@ -1956,7 +1961,7 @@ created <a href="#Image">Image</a>, or nullptr ### See Also -<a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> +<a href="#SkImage_MakeFromTexture">MakeFromTexture</a> --- @@ -2116,7 +2121,7 @@ true if backend texture was created ### See Also -<a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> <a href="#SkImage_makeTextureImage">makeTextureImage</a> +<a href="#SkImage_MakeFromTexture">MakeFromTexture</a> <a href="#SkImage_makeTextureImage">makeTextureImage</a> --- @@ -2245,7 +2250,7 @@ created <a href="#Image">Image</a> in <a href="#SkImage_makeColorSpace_target">t ### See Also -MakeFromPixture <a href="#SkImage_MakeFromTexture">MakeFromTexture</a><sup><a href="#SkImage_MakeFromTexture_2">[2]</a></sup><sup><a href="#SkImage_MakeFromTexture_3">[3]</a></sup><sup><a href="#SkImage_MakeFromTexture_4">[4]</a></sup> +MakeFromPixture <a href="#SkImage_MakeFromTexture">MakeFromTexture</a> --- diff --git a/site/user/api/SkPaint_Reference.md b/site/user/api/SkPaint_Reference.md index 07460cb8d2..e909e17cdc 100644 --- a/site/user/api/SkPaint_Reference.md +++ b/site/user/api/SkPaint_Reference.md @@ -3186,7 +3186,7 @@ replace <a href="SkPath_Reference#Path">Path</a> with a modification when drawn< ## <a name="Mask_Filter_Methods"></a> Mask Filter Methods <a href="undocumented#Mask_Filter">Mask Filter</a> uses coverage of the shape drawn to create <a href="undocumented#Mask_Alpha">Mask Alpha</a>. -<a href="undocumented#Mask_Filter">Mask Filter</a> takes a <a href="undocumented#Mask">Mask</a>, and returns a <a href="undocumented#Mask">Mask</a>. +<a href="undocumented#Mask_Filter">Mask Filter</a> takes a Mask, and returns a Mask. <a href="undocumented#Mask_Filter">Mask Filter</a> may change the geometry and transparency of the shape, such as creating a blur effect. Set <a href="undocumented#Mask_Filter">Mask Filter</a> to nullptr to prevent <a href="undocumented#Mask_Filter">Mask Filter</a> from diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm index 07e8a6e5cd..d25fe7774b 100644 --- a/site/user/api/catalog.htm +++ b/site/user/api/catalog.htm @@ -3197,6 +3197,174 @@ "file": "SkCanvas_Reference", "name": "State_Stack_2" }, + "Illustrations_Image_Info_Color_Type_ABGR_4444": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"16-bit word\", 5 + 20 * 8, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 4, 8, 12, 16 };\n const char* labels[] = { \"red\", \"green\", \"blue\", \"alpha\" };\n drawBoxText(&edges[0], &labels[0], 4, 15, 45);\n drawBoxText(&edges[0], &labels[2], 2, 7, 110);\n drawBoxText(&edges[0], &labels[0], 2, 7, 160);\n}\n", + "width": 415, + "height": 250, + "hash": "0441bdba65a19aa72b75b7fa62d22121", + "file": "illustrations", + "name": "Image_Info_Color_Type_ABGR_4444" +}, + "Illustrations_Image_Info_Color_Type_BGRA_8888": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"32-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 8, 16, 24, 32 };\n const char* labels[] = { \"alpha\", \"red\", \"green\", \"blue\" };\n drawBoxText(edges, &labels[0], 4, 31, 45);\n drawBoxText(edges, &labels[3], 1, 7, 110);\n drawBoxText(edges, &labels[2], 1, 7, 160);\n drawBoxText(edges, &labels[1], 1, 7, 210);\n drawBoxText(edges, &labels[0], 1, 7, 260);\n}\n", + "width": 812, + "height": 365, + "hash": "babd0e12db21a88c74d4e88aa40268ab", + "file": "illustrations", + "name": "Image_Info_Color_Type_BGRA_8888" +}, + "Illustrations_Image_Info_Color_Type_BGR_565": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"16-bit word\", 5 + 20 * 8, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 1.5f, 137, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 6.5f, 187, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 5, 11, 16, \n 0, 3, 8,\n 0, 5, 8 };\n const char* labels[] = { \"red\", \"green\", \"blue\" };\n drawBoxText(&edges[0], &labels[0], 3, 15, 45);\n drawBoxText(&edges[4], &labels[1], 2, 7, 110);\n drawBoxText(&edges[7], &labels[0], 2, 7, 160);\n}\n", + "width": 415, + "height": 250, + "hash": "b674a54eb4188d5ce66c04cebdb61089", + "file": "illustrations", + "name": "Image_Info_Color_Type_BGR_565" +}, + "Illustrations_Image_Info_Color_Type_RGBA_1010102": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"32-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 4, 137, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 3, 187, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 7, 187, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 2, 237, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 6, 237, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 5, 287, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 2, 12, 22, 32,\n 0, 8,\n 0, 6, 8,\n 0, 4, 8,\n 0, 2, 8\n };\n const char* labels[] = { \"alpha\", \"blue\", \"green\", \"red\" };\n drawBoxText(&edges[0], &labels[0], 4, 31, 45);\n drawBoxText(&edges[5], &labels[3], 1, 7, 110);\n drawBoxText(&edges[7], &labels[2], 2, 7, 160);\n drawBoxText(&edges[10], &labels[1], 2, 7, 210);\n drawBoxText(&edges[13], &labels[0], 2, 7, 260);\n}\n", + "width": 812, + "height": 380, + "hash": "6c470410001ad8f1ee9f58204c66f1bb", + "file": "illustrations", + "name": "Image_Info_Color_Type_RGBA_1010102" +}, + "Illustrations_Image_Info_Color_Type_RGBA_8888": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"32-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 8, 16, 24, 32 };\n const char* labels[] = { \"alpha\", \"blue\", \"green\", \"red\" };\n drawBoxText(edges, &labels[0], 4, 31, 45);\n drawBoxText(edges, &labels[3], 1, 7, 110);\n drawBoxText(edges, &labels[2], 1, 7, 160);\n drawBoxText(edges, &labels[1], 1, 7, 210);\n drawBoxText(edges, &labels[0], 1, 7, 260);\n}\n", + "width": 812, + "height": 365, + "hash": "4ccd35f27fe73dce8cce8c75e18df23c", + "file": "illustrations", + "name": "Image_Info_Color_Type_RGBA_8888" +}, + "Illustrations_Image_Info_Color_Type_RGBA_F16": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"64-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 135, paint);\n for (int i = 0; i < 4; ++i) {\n canvas->drawString(\"(low bits)\", 5 + 20 * 4, 187 + i * 100, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 4, 237 + i * 100, paint);\n }\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 16, 32,\n 0, 8\n };\n const char* labels[] = { \"alpha\", \"blue\", \"green\", \"red\" };\n drawBoxText(&edges[0], &labels[0], 2, 63, 45);\n drawBoxText(&edges[0], &labels[2], 2, 31, 95);\n drawBoxText(&edges[3], &labels[3], 1, 7, 160);\n drawBoxText(&edges[3], &labels[3], 1, 7, 210);\n drawBoxText(&edges[3], &labels[2], 1, 7, 260);\n drawBoxText(&edges[3], &labels[2], 1, 7, 310);\n drawBoxText(&edges[3], &labels[1], 1, 7, 360);\n drawBoxText(&edges[3], &labels[1], 1, 7, 410);\n drawBoxText(&edges[3], &labels[0], 1, 7, 460);\n drawBoxText(&edges[3], &labels[0], 1, 7, 510);\n}\n", + "width": 812, + "height": 685, + "hash": "9344796c059ff5e4f057595e781905b3", + "file": "illustrations", + "name": "Image_Info_Color_Type_RGBA_F16" +}, + "Illustrations_Image_Info_Color_Type_RGB_101010x": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"32-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 4, 137, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 3, 187, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 7, 187, paint);\n canvas->drawString(\"(low bits)\", 5 + 20 * 2, 237, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 6, 237, paint);\n canvas->drawString(\"(high bits)\", 5 + 20 * 5, 287, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 2, 12, 22, 32,\n 0, 8,\n 0, 6, 8,\n 0, 4, 8,\n 0, 2, 8\n };\n const char* labels[] = { \"unused\", \"blue\", \"green\", \"red\" };\n drawBoxText(&edges[0], &labels[0], 4, 31, 45);\n drawBoxText(&edges[5], &labels[3], 1, 7, 110);\n drawBoxText(&edges[7], &labels[2], 2, 7, 160);\n drawBoxText(&edges[10], &labels[1], 2, 7, 210);\n drawBoxText(&edges[13], &labels[0], 2, 7, 260);\n}\n", + "width": 812, + "height": 380, + "hash": "c22477b11dabaa3e3a0b5bb33a7733cd", + "file": "illustrations", + "name": "Image_Info_Color_Type_RGB_101010x" +}, + "Illustrations_Image_Info_Color_Type_RGB_888x": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(1.25f, 1.25f);\n SkPaint paint;\n paint.setAntiAlias(true);\n paint.setTextSize(10);\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->drawString(\"32-bit word\", 5 + 20 * 16, 20, paint);\n canvas->drawString(\"little endian byte order\", 5 + 20 * 4, 85, paint);\n auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void {\n SkPaint p(paint);\n p.setColor(SK_ColorRED);\n SkScalar xPos = 15;\n int width = n % 32 + 1;\n int lastN = n > 32 ? 32 : 0;\n for (; n >= lastN; --n) {\n for (int i = 0; i <= count; ++i) {\n int a = width - e[i];\n if (a == n || a == n + 1 || a == n - 32 || a == n - 31) {\n char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\\0'};\n canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p);\n break;\n }\n }\n xPos += 20;\n }\n p.setColor(SK_ColorBLACK);\n for (int i = 0; i < count; ++i) {\n canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p);\n }\n p.setStyle(SkPaint::kStroke_Style);\n for (int i = 0; i <= count; ++i) {\n canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p);\n }\n for (int i = 0; i < 2; ++i) {\n canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p);\n }\n };\n SkScalar edges[] = { 0, 8, 16, 24, 32 };\n const char* labels[] = { \"(unused)\", \"blue\", \"green\", \"red\" };\n drawBoxText(edges, &labels[0], 4, 31, 45);\n drawBoxText(edges, &labels[3], 1, 7, 110);\n drawBoxText(edges, &labels[2], 1, 7, 160);\n drawBoxText(edges, &labels[1], 1, 7, 210);\n drawBoxText(edges, &labels[0], 1, 7, 260);\n}\n", + "width": 812, + "height": 365, + "hash": "fecfe58c25cfc1b1e411e5eb50f7d8d1", + "file": "illustrations", + "name": "Image_Info_Color_Type_RGB_888x" +}, + "Image_Info_Alpha_Type_Opaque": { + "code": "void draw(SkCanvas* canvas) {\n SkPMColor color = SkPreMultiplyARGB(255, 50, 100, 150);\n SkString s;\n s.printf(\"%u %u %u %u\", SkColorGetA(color), SkColorGetR(color),\n SkColorGetG(color), SkColorGetB(color));\n SkPaint paint;\n paint.setAntiAlias(true);\n canvas->drawString(s, 10, 62, paint);\n canvas->scale(50, 50);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kOpaque_SkAlphaType);\n if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 0, 0);\n }\n}", + "width": 256, + "height": 64, + "hash": "79146a1a41d58d22582fdc567c6ffe4e", + "file": "SkImageInfo_Reference", + "name": "Alpha_Type_Opaque" +}, + "Image_Info_Alpha_Type_Premul": { + "code": "void draw(SkCanvas* canvas) {\n SkPMColor color = SkPreMultiplyARGB(150, 50, 100, 150);\n SkString s;\n s.printf(\"%u %u %u %u\", SkColorGetA(color), SkColorGetR(color),\n SkColorGetG(color), SkColorGetB(color));\n SkPaint paint;\n paint.setAntiAlias(true);\n canvas->drawString(s, 10, 62, paint);\n canvas->scale(50, 50);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kPremul_SkAlphaType);\n if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 0, 0);\n }\n}", + "width": 256, + "height": 64, + "hash": "ad696b39c915803d566e96896ec3a36c", + "file": "SkImageInfo_Reference", + "name": "Alpha_Type_Premul" +}, + "Image_Info_Alpha_Type_Unpremul": { + "code": "void draw(SkCanvas* canvas) {\n SkColor color = SkColorSetARGB(150, 50, 100, 255);\n SkString s;\n s.printf(\"%u %u %u %u\", SkColorGetA(color), SkColorGetR(color),\n SkColorGetG(color), SkColorGetB(color));\n SkPaint paint;\n paint.setAntiAlias(true);\n canvas->drawString(s, 10, 62, paint);\n canvas->scale(50, 50);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kUnpremul_SkAlphaType);\n if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 0, 0);\n }\n}", + "width": 256, + "height": 256, + "hash": "46e528e0c6b3f3e296d0d0930d638629", + "file": "SkImageInfo_Reference", + "name": "Alpha_Type_Unpremul" +}, + "Image_Info_Color_Type_ABGR_4444": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kARGB_4444_SkColorType, kPremul_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack4444 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint16_t {\n return (a << 0) | (b << 4) | (g << 8) | (r << 12);\n };\n uint16_t red4444[] = { pack4444(0xF, 0xF, 0x0, 0x0), pack4444(0xF, 0xb, 0x0, 0x0), \n pack4444(0xF, 0x7, 0x0, 0x0), pack4444(0xF, 0x3, 0x0, 0x0) };\n uint16_t blue4444[] = { pack4444(0xF, 0x0, 0x0, 0xF), pack4444(0xF, 0x0, 0x0, 0xb),\n pack4444(0xF, 0x0, 0x0, 0x7), pack4444(0xF, 0x0, 0x0, 0x3) };\n SkPixmap redPixmap(imageInfo, &red4444, imageInfo.minRowBytes());\n if (bitmap.writePixels(redPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blue4444, imageInfo.minRowBytes());\n if (bitmap.writePixels(bluePixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "f89e8200d225ccb839e50a1481db48e9", + "file": "SkImageInfo_Reference", + "name": "Color_Type_ABGR_4444" +}, + "Image_Info_Color_Type_Alpha_8": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kAlpha_8_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n SkPaint orangePaint;\n orangePaint.setARGB(0xFF, 0xFF, 0xA5, 0x00);\n canvas->drawBitmap(bitmap, 0, 0, &orangePaint);\n uint8_t alpha8[] = { 0xFF, 0xBB, 0x77, 0x33 };\n SkPixmap alphaPixmap(imageInfo, &alpha8, imageInfo.minRowBytes());\n if (bitmap.writePixels(alphaPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2, &orangePaint);\n }\n}", + "width": 256, + "height": 64, + "hash": "21ae21e4ce53d2018e042dd457997300", + "file": "SkImageInfo_Reference", + "name": "Color_Type_Alpha_8" +}, + "Image_Info_Color_Type_BGRA_8888": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kBGRA_8888_SkColorType, kPremul_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t {\n return (b << 0) | (g << 8) | (r << 16) | (a << 24);\n };\n uint32_t red8888[] = { pack8888(0xFF, 0xFF, 0x0, 0x0), pack8888(0xFF, 0xbb, 0x0, 0x0), \n pack8888(0xFF, 0x99, 0x0, 0x0), pack8888(0xFF, 0x55, 0x0, 0x0) };\n uint32_t blue8888[] = { pack8888(0xFF, 0x0, 0x0, 0x0FF), pack8888(0xFF, 0x0, 0x0, 0x0bb),\n pack8888(0xFF, 0x0, 0x0, 0x099), pack8888(0xFF, 0x0, 0x0, 0x055) };\n SkPixmap redPixmap(imageInfo, &red8888, imageInfo.minRowBytes());\n if (bitmap.writePixels(redPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blue8888, imageInfo.minRowBytes());\n if (bitmap.writePixels(bluePixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "fcadba68a4fe7253b1726487e12b1eeb", + "file": "SkImageInfo_Reference", + "name": "Color_Type_BGRA_8888" +}, + "Image_Info_Color_Type_BGR_565": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_565_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack565 = [](unsigned r, unsigned g, unsigned b) -> uint16_t {\n return (b << 0) | (g << 5) | (r << 11);\n };\n uint16_t red565[] = { pack565(0x1F, 0x00, 0x00), pack565(0x17, 0x00, 0x00), \n pack565(0x0F, 0x00, 0x00), pack565(0x07, 0x00, 0x00) };\n uint16_t blue565[] = { pack565(0x00, 0x00, 0x1F), pack565(0x00, 0x00, 0x17),\n pack565(0x00, 0x00, 0x0F), pack565(0x00, 0x00, 0x07) };\n SkPixmap redPixmap(imageInfo, &red565, imageInfo.minRowBytes());\n if (bitmap.writePixels(redPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blue565, imageInfo.minRowBytes());\n if (bitmap.writePixels(bluePixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "54e4c690d64d73ba028c5b250c0d09f0", + "file": "SkImageInfo_Reference", + "name": "Color_Type_BGR_565" +}, + "Image_Info_Color_Type_Gray_8": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kGray_8_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n uint8_t gray8[] = { 0xFF, 0xBB, 0x77, 0x33 };\n SkPixmap grayPixmap(imageInfo, &gray8, imageInfo.minRowBytes());\n if (bitmap.writePixels(grayPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n}", + "width": 256, + "height": 64, + "hash": "93da0eb0b6722a4f33dc7dae094abf0b", + "file": "SkImageInfo_Reference", + "name": "Color_Type_Gray_8" +}, + "Image_Info_Color_Type_RGBA_1010102": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_1010102_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack1010102 = [](unsigned r, unsigned g, unsigned b, unsigned a) -> uint32_t {\n return (r << 0) | (g << 10) | (b << 20) | (a << 30);\n };\n uint32_t redBits[] = { pack1010102(0x3FF, 0x000, 0x000, 0x3), \n pack1010102(0x2ff, 0x000, 0x000, 0x3), \n pack1010102(0x1ff, 0x000, 0x000, 0x3), \n pack1010102(0x0ff, 0x000, 0x000, 0x3) };\n uint32_t blueBits[] = { pack1010102(0x000, 0x000, 0x3FF, 0x3), \n pack1010102(0x000, 0x000, 0x2ff, 0x3),\n pack1010102(0x000, 0x000, 0x1ff, 0x3), \n pack1010102(0x000, 0x000, 0x0ff, 0x3) };\n if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes());\n if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "1bf1a6f087b4f2f93962960902061a7a", + "file": "SkImageInfo_Reference", + "name": "Color_Type_RGBA_1010102" +}, + "Image_Info_Color_Type_RGBA_8888": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_8888_SkColorType, kPremul_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack8888 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint32_t {\n return (r << 0) | (g << 8) | (b << 16) | (a << 24);\n };\n uint32_t red8888[] = { pack8888(0xFF, 0xFF, 0x0, 0x0), pack8888(0xFF, 0xbb, 0x0, 0x0), \n pack8888(0xFF, 0x77, 0x0, 0x0), pack8888(0xFF, 0x33, 0x0, 0x0) };\n uint32_t blue8888[] = { pack8888(0xFF, 0x0, 0x0, 0x0FF), pack8888(0xFF, 0x0, 0x0, 0x0bb),\n pack8888(0xFF, 0x0, 0x0, 0x077), pack8888(0xFF, 0x0, 0x0, 0x033) };\n SkPixmap redPixmap(imageInfo, &red8888, imageInfo.minRowBytes());\n if (bitmap.writePixels(redPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blue8888, imageInfo.minRowBytes());\n if (bitmap.writePixels(bluePixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "f3b9effa700b1b95ce10caf422b020cd", + "file": "SkImageInfo_Reference", + "name": "Color_Type_RGBA_8888" +}, + "Image_Info_Color_Type_RGBA_F16": { + "code": "union FloatUIntUnion {\n uint32_t fUInt;\n float fFloat;\n};\nuint16_t FloatToHalf(float f) {\n static const FloatUIntUnion magic = { 15 << 23 };\n static const uint32_t round_mask = ~0xfffu;\n FloatUIntUnion floatUnion;\n floatUnion.fFloat = f;\n uint32_t sign = floatUnion.fUInt & 0x80000000u;\n floatUnion.fUInt ^= sign;\n floatUnion.fUInt &= round_mask;\n floatUnion.fFloat *= magic.fFloat;\n floatUnion.fUInt -= round_mask;\n return (floatUnion.fUInt >> 13) | (sign >> 16);\n}\n\nvoid draw(SkCanvas* canvas) { \n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGBA_F16_SkColorType, kPremul_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto H = [](float c) -> uint16_t {\n return FloatToHalf(c);\n };\n // R G B A\n uint16_t red_f16[][4] = { { H(1.0f), H(0.0f), H(0.0f), H(1.0f) },\n { H(.75f), H(0.0f), H(0.0f), H(1.0f) }, \n { H(.50f), H(0.0f), H(0.0f), H(1.0f) },\n { H(.25f), H(0.0f), H(0.0f), H(1.0f) } };\n uint16_t blue_f16[][4] = { { H(0.0f), H(0.0f), H(1.0f), H(1.0f) },\n { H(0.0f), H(0.0f), H(.75f), H(1.0f) }, \n { H(0.0f), H(0.0f), H(.50f), H(1.0f) },\n { H(0.0f), H(0.0f), H(.25f), H(1.0f) } };\n SkPixmap redPixmap(imageInfo, red_f16, imageInfo.minRowBytes());\n if (bitmap.writePixels(redPixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, blue_f16, imageInfo.minRowBytes());\n if (bitmap.writePixels(bluePixmap, 0, 0)) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}\n", + "width": 256, + "height": 96, + "hash": "1795410dffea303b08ba98ee78dc1556", + "file": "SkImageInfo_Reference", + "name": "Color_Type_RGBA_F16" +}, + "Image_Info_Color_Type_RGB_101010x": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_101010x_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack101010x = [](unsigned r, unsigned g, unsigned b) -> uint32_t {\n return (r << 0) | (g << 10) | (b << 20);\n };\n uint32_t redBits[] = { pack101010x(0x3FF, 0x000, 0x000), pack101010x(0x2ff, 0x000, 0x000), \n pack101010x(0x1ff, 0x000, 0x000), pack101010x(0x0ff, 0x000, 0x000) };\n uint32_t blueBits[] = { pack101010x(0x000, 0x000, 0x3FF), pack101010x(0x000, 0x000, 0x2ff),\n pack101010x(0x000, 0x000, 0x1ff), pack101010x(0x000, 0x000, 0x0ff) };\n if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes());\n if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "d975ec17354b1297841e4a31d3f6a5d5", + "file": "SkImageInfo_Reference", + "name": "Color_Type_RGB_101010x" +}, + "Image_Info_Color_Type_RGB_888x": { + "code": "void draw(SkCanvas* canvas) {\n canvas->scale(16, 16);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_888x_SkColorType, kOpaque_SkAlphaType);\n bitmap.allocPixels(imageInfo);\n SkCanvas offscreen(bitmap);\n offscreen.clear(SK_ColorGREEN);\n canvas->drawBitmap(bitmap, 0, 0);\n auto pack888 = [](unsigned r, unsigned g, unsigned b) -> uint32_t {\n return (r << 0) | (g << 8) | (b << 16);\n };\n uint32_t red888[] = { pack888(0xFF, 0x00, 0x00), pack888(0xbb, 0x00, 0x00), \n pack888(0x77, 0x00, 0x00), pack888(0x33, 0x00, 0x00) };\n uint32_t blue888[] = { pack888(0x00, 0x00, 0xFF), pack888(0x00, 0x00, 0xbb),\n pack888(0x00, 0x00, 0x77), pack888(0x00, 0x00, 0x33) };\n if (bitmap.installPixels(imageInfo, (void*) red888, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 2, 2);\n }\n if (bitmap.installPixels(imageInfo, (void*) blue888, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 4, 4);\n }\n}", + "width": 256, + "height": 96, + "hash": "1e236c4c9ce0597c22186589fee9dc1e", + "file": "SkImageInfo_Reference", + "name": "Color_Type_RGB_888x" +}, "Paint_Anti_alias": { "code": "void draw(SkCanvas* canvas) {\n SkBitmap bitmap;\n bitmap.allocN32Pixels(50, 50);\n SkCanvas offscreen(bitmap);\n SkPaint paint;\n paint.setStyle(SkPaint::kStroke_Style);\n paint.setStrokeWidth(10);\n for (bool antialias : { false, true }) {\n paint.setColor(antialias ? SK_ColorRED : SK_ColorBLUE);\n paint.setAntiAlias(antialias);\n bitmap.eraseColor(0);\n offscreen.drawLine(5, 5, 15, 30, paint);\n canvas->drawLine(5, 5, 15, 30, paint);\n canvas->save();\n canvas->scale(10, 10);\n canvas->drawBitmap(bitmap, antialias ? 12 : 0, 0);\n canvas->restore();\n canvas->translate(15, 0);\n }\n}\n", "width": 512, @@ -3501,14 +3669,6 @@ "file": "SkPath_Reference", "name": "Path_2" }, - "SkAlphaType": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkAlphaType" -}, "SkAutoCanvasRestore_SkCanvas_star": { "code": "void draw(SkCanvas* canvas) {\n SkPaint p;\n p.setAntiAlias(true);\n p.setTextSize(64);\n for (SkScalar sx : { -1, 1 } ) {\n for (SkScalar sy : { -1, 1 } ) {\n SkAutoCanvasRestore autoRestore(canvas, true);\n SkMatrix m = SkMatrix::MakeAll(sx, 1, 96, 0, sy, 64, 0, 0, 1);\n canvas->concat(m);\n canvas->drawString(\"R\", 0, 0, p);\n }\n }\n}", "width": 256, @@ -4597,14 +4757,6 @@ "file": "SkCanvas_Reference", "name": "SkCanvas::writePixels_2" }, - "SkColorType": { - "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", - "width": 256, - "height": 256, - "hash": "882e8e0103048009a25cfc20400492f7", - "file": "SkImageInfo_Reference", - "name": "SkColorType" -}, "SkDestinationSurfaceColorMode": { "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}", "width": 256, diff --git a/site/user/api/undocumented.md b/site/user/api/undocumented.md index 01bb9ce5bb..88ac21c4dd 100644 --- a/site/user/api/undocumented.md +++ b/site/user/api/undocumented.md @@ -99,6 +99,15 @@ int SkColorSetARGB(a, r, g, b) --- +<a name="SkPreMultiplyARGB"></a> +## SkPreMultiplyARGB + +<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> +SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) +</pre> + +--- + ### Constants <table> @@ -135,6 +144,8 @@ int SkColorSetARGB(a, r, g, b) ## <a name="RGB-565"></a> RGB-565 +## <a name="Gray"></a> Gray + # <a name="Color_Filter"></a> Color Filter # <a name="SkColorFilter"></a> Class SkColorFilter @@ -421,48 +432,12 @@ static sk_sp<SkPixelRef> MakeAllocate(const SkImageInfo&, size_t rowBytes) --- -# <a name="Mask"></a> Mask - -# <a name="SkMask"></a> Class SkMask - -## <a name="SkMask_Format"></a> Enum SkMask::Format - -### Constants - -<table> - <tr> - <td><a name="SkMask_kBW_Format"> <code><strong>SkMask::kBW_Format </strong></code> </a></td><td>0</td><td></td> - </tr> - <tr> - <td><a name="SkMask_kA8_Format"> <code><strong>SkMask::kA8_Format </strong></code> </a></td><td>1</td><td></td> - </tr> - <tr> - <td><a name="SkMask_k3D_Format"> <code><strong>SkMask::k3D_Format </strong></code> </a></td><td>2</td><td></td> - </tr> - <tr> - <td><a name="SkMask_kARGB32_Format"> <code><strong>SkMask::kARGB32_Format </strong></code> </a></td><td>3</td><td></td> - </tr> -k <tr> - <td><a name="SkMask_LCD16_Format"> <code><strong>SkMask::LCD16_Format </strong></code> </a></td><td>4</td><td></td> - </tr> - -</table> - # <a name="Mask_Alpha"></a> Mask Alpha # <a name="Mask_Filter"></a> Mask Filter # <a name="SkMaskFilter"></a> Class SkMaskFilter -<a name="SkMaskFilter_filterMask"></a> -## filterMask - -<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> -virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, SkIPoint* margin) const -</pre> - ---- - <a name="SkMaskFilter_toString"></a> ## toString |