1SkBitmap Reference 2=== 3 4# <a name="Bitmap"></a> Bitmap 5 6## <a name="Overview"></a> Overview 7 8## <a name="Subtopics"></a> Subtopics 9 10| name | description | 11| --- | --- | 12| <a href="#Classes_and_Structs">Classes and Structs</a> | embedded struct and class members | 13| Constants | enum and enum class, const values | 14| <a href="#Constructors">Constructors</a> | functions that construct <a href="SkBitmap_Reference#SkBitmap">SkBitmap</a> | 15| <a href="#Member_Functions">Member Functions</a> | static functions and member methods | 16| <a href="#Operators">Operators</a> | operator overloading methods | 17| <a href="#Related_Functions">Related Functions</a> | similar methods grouped together | 18 19# <a name="SkBitmap"></a> Class SkBitmap 20<a href="#Bitmap">Bitmap</a> describes a two-dimensional raster pixel array. <a href="#Bitmap">Bitmap</a> is built on 21<a href="SkImageInfo_Reference#Image_Info">Image Info</a>, containing integer width and height, <a href="SkImageInfo_Reference#Color_Type">Color Type</a> and <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> 22describing the pixel format, and <a href="undocumented#Color_Space">Color Space</a> describing the range of colors. 23<a href="#Bitmap">Bitmap</a> points to <a href="undocumented#Pixel_Ref">Pixel Ref</a>, which describes the physical array of pixels. 24<a href="SkImageInfo_Reference#Image_Info">Image Info</a> bounds may be located anywhere fully inside <a href="undocumented#Pixel_Ref">Pixel Ref</a> bounds. 25 26<a href="#Bitmap">Bitmap</a> can be drawn using <a href="SkCanvas_Reference#Canvas">Canvas</a>. <a href="#Bitmap">Bitmap</a> can be a drawing destination for <a href="SkCanvas_Reference#Canvas">Canvas</a> 27draw methods. <a href="#Bitmap">Bitmap</a> flexibility as a pixel container limits some optimizations 28available to the target platform. 29 30If pixel array is primarily read-only, use <a href="SkImage_Reference#Image">Image</a> for better performance. 31If pixel array is primarily written to, use <a href="SkSurface_Reference#Surface">Surface</a> for better performance. 32 33Declaring <a href="#SkBitmap">SkBitmap</a> const prevents altering <a href="SkImageInfo_Reference#Image_Info">Image Info</a>: the <a href="#Bitmap">Bitmap</a> height, width, 34and so on cannot change. It does not affect <a href="undocumented#Pixel_Ref">Pixel Ref</a>: a caller may write its 35pixels. Declaring <a href="#SkBitmap">SkBitmap</a> const affects <a href="#Bitmap">Bitmap</a> configuration, not its contents. 36 37<a href="#Bitmap">Bitmap</a> is not thread safe. Each thread must have its own copy of <a href="#Bitmap">Bitmap</a> fields, 38although threads may share the underlying pixel array. 39 40## <a name="Row_Bytes"></a> Row Bytes 41 42<a href="#Bitmap">Bitmap</a> pixels may be contiguous, or may have a gap at the end of each row. 43<a href="#Row_Bytes">Row Bytes</a> is the interval from one row to the next. <a href="#Row_Bytes">Row Bytes</a> may be specified; 44sometimes passing zero will compute the <a href="#Row_Bytes">Row Bytes</a> from the row width and the 45number of bytes in a pixel. <a href="#Row_Bytes">Row Bytes</a> may be larger than the row requires. This 46is useful to position one or more <a href="#Bitmap">Bitmaps</a> within a shared pixel array. 47 48## <a name="Related_Functions"></a> Related Functions 49 50| name | description | 51| --- | --- | 52| <a href="#Row_Bytes">Row Bytes</a> | interval from one row to the next | 53 54## <a name="Classes_and_Structs"></a> Classes and Structs 55 56| name | description | 57| --- | --- | 58| <a href="#SkBitmap_Allocator">Allocator</a> | abstract subclass of <a href="#SkBitmap_HeapAllocator">HeapAllocator</a> | 59| <a href="#SkBitmap_HeapAllocator">HeapAllocator</a> | allocates pixel memory from heap | 60 61## <a name="Constructors"></a> Constructors 62 63| name | description | 64| --- | --- | 65| <a href="#SkBitmap_empty_constructor">SkBitmap()</a> | constructs with default values | 66| <a href="#SkBitmap_move_SkBitmap">SkBitmap(SkBitmap&& src)</a> | takes ownership of pixels | 67| <a href="#SkBitmap_copy_const_SkBitmap">SkBitmap(const SkBitmap& src)</a> | shares ownership of pixels | 68| <a href="#SkBitmap_destructor">~SkBitmap()</a> | releases ownership of pixels | 69 70## <a name="Operators"></a> Operators 71 72| name | description | 73| --- | --- | 74| <a href="#SkBitmap_move_operator">operator=(SkBitmap&& src)</a> | takes ownership of pixels | 75| <a href="#SkBitmap_copy_operator">operator=(const SkBitmap& src)</a> | shares ownership of pixels | 76 77## <a name="Member_Functions"></a> Member Functions 78 79| name | description | 80| --- | --- | 81| <a href="#SkBitmap_ComputeIsOpaque">ComputeIsOpaque</a> | returns true if all pixels are opaque | 82| <a href="#SkBitmap_allocN32Pixels">allocN32Pixels</a> | allocates compatible <a href="#ARGB">Color ARGB</a> pixels, or aborts | 83| <a href="#SkBitmap_allocPixels">allocPixels</a> | allocates pixels from <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, or aborts | 84| <a href="#SkBitmap_allocPixelsFlags">allocPixelsFlags</a> | allocates pixels from <a href="SkImageInfo_Reference#Image_Info">Image Info</a> with options, or aborts | 85| <a href="#SkBitmap_alphaType">alphaType</a> | returns <a href="SkImageInfo_Reference#Image_Info">Image Info</a> <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> | 86| <a href="#SkBitmap_bounds">bounds</a> | returns <a href="#SkBitmap_width">width</a> and <a href="#SkBitmap_height">height</a> as Rectangle | 87| <a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a> | returns number of bytes in pixel based on <a href="SkImageInfo_Reference#Color_Type">Color Type</a> | 88| <a href="#SkBitmap_colorSpace">colorSpace</a> | returns <a href="SkImageInfo_Reference#Image_Info">Image Info</a> <a href="undocumented#Color_Space">Color Space</a> | 89| <a href="#SkBitmap_colorType">colorType</a> | returns <a href="SkImageInfo_Reference#Image_Info">Image Info</a> <a href="SkImageInfo_Reference#Color_Type">Color Type</a> | 90| <a href="#SkBitmap_computeByteSize">computeByteSize</a> | returns size required for pixels | 91| <a href="#SkBitmap_dimensions">dimensions</a> | returns <a href="#SkBitmap_width">width</a> and <a href="#SkBitmap_height">height</a> | 92| <a href="#SkBitmap_drawsNothing">drawsNothing</a> | returns true if no <a href="#SkBitmap_width">width</a>, no <a href="#SkBitmap_height">height</a>, or no <a href="undocumented#Pixel_Ref">Pixel Ref</a> | 93| <a href="#SkBitmap_empty">empty</a> | returns true if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> has zero <a href="#SkBitmap_width">width</a> or <a href="#SkBitmap_height">height</a> | 94| <a href="#SkBitmap_erase">erase</a> | writes <a href="undocumented#Color">Color</a> to rectangle of pixels | 95| <a href="#SkBitmap_eraseARGB">eraseARGB</a> | writes <a href="undocumented#Color">Color</a> to pixels | 96| <a href="#SkBitmap_eraseArea">eraseArea</a> | deprecated | 97| <a href="#SkBitmap_eraseColor">eraseColor</a> | writes <a href="undocumented#Color">Color</a> to pixels | 98| <a href="#SkBitmap_eraseRGB">eraseRGB</a> | deprecated | 99| <a href="#SkBitmap_extractAlpha">extractAlpha</a> | creates <a href="#Bitmap">Bitmap</a> containing <a href="#Alpha">Alpha</a> of pixels | 100| <a href="#SkBitmap_extractSubset">extractSubset</a> | creates <a href="#Bitmap">Bitmap</a>, sharing pixels if possible | 101| <a href="#SkBitmap_getAddr">getAddr</a> | returns readable pixel address as void pointer | 102| <a href="#SkBitmap_getAddr16">getAddr16</a> | returns readable pixel address as 16-bit pointer | 103| <a href="#SkBitmap_getAddr32">getAddr32</a> | returns readable pixel address as 32-bit pointer | 104| <a href="#SkBitmap_getAddr8">getAddr8</a> | returns readable pixel address as 8-bit pointer | 105| <a href="#SkBitmap_getBounds">getBounds</a> | returns <a href="#SkBitmap_width">width</a> and <a href="#SkBitmap_height">height</a> as Rectangle | 106| <a href="#SkBitmap_getColor">getColor</a> | returns one pixel as <a href="#Unpremultiply">Unpremultiplied</a> <a href="undocumented#Color">Color</a> | 107| <a href="#SkBitmap_getGenerationID">getGenerationID</a> | returns unique ID | 108| <a href="#SkBitmap_getPixels">getPixels</a> | returns address of pixels | 109| <a href="#SkBitmap_getSubset">getSubset</a> | returns bounds offset by origin | 110| <a href="#SkBitmap_hasHardwareMipMap">hasHardwareMipMap</a> | returns <a href="undocumented#Mip_Map">Mip Map</a> support present; Android only | 111| <a href="#SkBitmap_height">height</a> | returns pixel row count | 112| <a href="#SkBitmap_info">info</a> | returns <a href="SkImageInfo_Reference#Image_Info">Image Info</a> | 113| <a href="#SkBitmap_installMaskPixels">installMaskPixels</a> | creates <a href="undocumented#Pixel_Ref">Pixel Ref</a> from <a href="undocumented#Mask">Mask</a> | 114| <a href="#SkBitmap_installPixels">installPixels</a> | creates <a href="undocumented#Pixel_Ref">Pixel Ref</a>, with optional release function | 115| <a href="#SkBitmap_isImmutable">isImmutable</a> | returns true if pixels will not change | 116| <a href="#SkBitmap_isNull">isNull</a> | returns true if <a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr | 117| <a href="#SkBitmap_isOpaque">isOpaque</a> | returns true if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> describes opaque pixels | 118| <a href="#SkBitmap_isVolatile">isVolatile</a> | returns true if pixels should not be cached | 119| <a href="#SkBitmap_notifyPixelsChanged">notifyPixelsChanged</a> | marks pixels as changed, altering the unique ID | 120| <a href="#SkBitmap_peekPixels">peekPixels</a> | returns <a href="SkPixmap_Reference#Pixmap">Pixmap</a> if possible | 121| <a href="#SkBitmap_pixelRef">pixelRef</a> | returns <a href="undocumented#Pixel_Ref">Pixel Ref</a>, or nullptr | 122| <a href="#SkBitmap_pixelRefOrigin">pixelRefOrigin</a> | returns offset within <a href="undocumented#Pixel_Ref">Pixel Ref</a> | 123| <a href="#SkBitmap_pixmap">pixmap</a> | returns <a href="SkPixmap_Reference#Pixmap">Pixmap</a> | 124| <a href="#SkBitmap_readPixels">readPixels</a> | copies and converts pixels | 125| <a href="#SkBitmap_readyToDraw">readyToDraw</a> | returns true if address of pixels is not nullptr | 126| <a href="#SkBitmap_refColorSpace">refColorSpace</a> | returns <a href="SkImageInfo_Reference#Image_Info">Image Info</a> <a href="undocumented#Color_Space">Color Space</a> | 127| <a href="#SkBitmap_reset">reset</a> | sets to default values, releases pixel ownership | 128| <a href="#SkBitmap_rowBytes">rowBytes</a> | returns interval between rows in bytes | 129| <a href="#SkBitmap_rowBytesAsPixels">rowBytesAsPixels</a> | returns interval between rows in pixels | 130| <a href="#SkBitmap_setAlphaType">setAlphaType</a> | sets <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> of shared pixels | 131| <a href="#SkBitmap_setHasHardwareMipMap">setHasHardwareMipMap</a> | sets <a href="undocumented#Mip_Map">Mip Map</a> support present; Android only | 132| <a href="#SkBitmap_setImmutable">setImmutable</a> | marks that pixels will not change | 133| <a href="#SkBitmap_setInfo">setInfo</a> | sets height, width, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, and so on, releasing pixels | 134| <a href="#SkBitmap_setIsVolatile">setIsVolatile</a> | marks if pixels should not be cached | 135| <a href="#SkBitmap_setPixelRef">setPixelRef</a> | sets <a href="undocumented#Pixel_Ref">Pixel Ref</a> and offset | 136| <a href="#SkBitmap_setPixels">setPixels</a> | sets <a href="undocumented#Pixel_Ref">Pixel Ref</a> without an offset | 137| <a href="#SkBitmap_shiftPerPixel">shiftPerPixel</a> | returns bit shift from pixels to bytes | 138| <a href="#SkBitmap_swap">swap</a> | exchanges <a href="#Bitmap">Bitmap</a> pair | 139| <a href="#SkBitmap_toString">toString</a> | converts <a href="#Bitmap">Bitmap</a> to machine readable form | 140| <a href="#SkBitmap_tryAllocN32Pixels">tryAllocN32Pixels</a> | allocates compatible <a href="#ARGB">Color ARGB</a> pixels if possible | 141| <a href="#SkBitmap_tryAllocPixels">tryAllocPixels</a> | allocates pixels from <a href="SkImageInfo_Reference#Image_Info">Image Info</a> if possible | 142| <a href="#SkBitmap_tryAllocPixelsFlags">tryAllocPixelsFlags</a> | allocates pixels from <a href="SkImageInfo_Reference#Image_Info">Image Info</a> with options if possible | 143| <a href="#SkBitmap_validate">validate</a> | asserts if <a href="#Bitmap">Bitmap</a> is invalid (debug only) | 144| <a href="#SkBitmap_width">width</a> | returns pixel column count | 145| <a href="#SkBitmap_writePixels">writePixels</a> | copies and converts pixels | 146 147# <a name="SkBitmap::Allocator"></a> Class SkBitmap::Allocator 148 149<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 150class <a href="#SkBitmap_Allocator">Allocator</a> : public <a href="undocumented#SkRefCnt">SkRefCnt</a> { 151public: 152virtual bool <a href="#SkBitmap_Allocator_allocPixelRef">allocPixelRef(SkBitmap* bitmap)</a> = 0; 153};</pre> 154 155Abstract subclass of <a href="#SkBitmap_HeapAllocator">HeapAllocator</a>. 156 157<a name="SkBitmap_Allocator_allocPixelRef"></a> 158## allocPixelRef 159 160<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 161virtual bool allocPixelRef(SkBitmap* bitmap) = 0 162</pre> 163 164Allocates the pixel memory for the <a href="#SkBitmap_Allocator_allocPixelRef_bitmap">bitmap</a>, given its dimensions and 165<a href="SkImageInfo_Reference#Color_Type">Color Type</a>. Returns true on success, where success means either <a href="#SkBitmap_setPixels">setPixels</a> 166or <a href="#SkBitmap_setPixelRef">setPixelRef</a> was called. 167 168### Parameters 169 170<table> <tr> <td><a name="SkBitmap_Allocator_allocPixelRef_bitmap"> <code><strong>bitmap </strong></code> </a></td> <td> 171<a href="#Bitmap">Bitmap</a> containing <a href="SkImageInfo_Reference#Image_Info">Image Info</a> as input, and <a href="undocumented#Pixel_Ref">Pixel Ref</a> as output</td> 172 </tr> 173</table> 174 175### Return Value 176 177true if <a href="undocumented#Pixel_Ref">Pixel Ref</a> was allocated 178 179### See Also 180 181<a href="#SkBitmap_HeapAllocator">HeapAllocator</a> 182 183--- 184 185# <a name="SkBitmap::HeapAllocator"></a> Class SkBitmap::HeapAllocator 186 187<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 188class <a href="#SkBitmap_HeapAllocator">HeapAllocator</a> : public <a href="#SkBitmap_Allocator">Allocator</a> { 189public: 190bool <a href="#SkBitmap_HeapAllocator_allocPixelRef">allocPixelRef(SkBitmap* bitmap)</a> override; 191};</pre> 192 193Subclass of <a href="#SkBitmap_Allocator">Allocator</a> that returns a <a href="undocumented#Pixel_Ref">Pixel Ref</a> that allocates its pixel 194memory from the heap. This is the default <a href="#SkBitmap_Allocator">Allocator</a> invoked by 195<a href="#SkBitmap_allocPixels">allocPixels</a>. 196 197<a name="SkBitmap_HeapAllocator_allocPixelRef"></a> 198## allocPixelRef 199 200<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 201bool allocPixelRef(SkBitmap* bitmap) override 202</pre> 203 204Allocates the pixel memory for the <a href="#SkBitmap_HeapAllocator_allocPixelRef_bitmap">bitmap</a>, given its dimensions and 205<a href="SkImageInfo_Reference#Color_Type">Color Type</a>. Returns true on success, where success means either <a href="#SkBitmap_setPixels">setPixels</a> 206or <a href="#SkBitmap_setPixelRef">setPixelRef</a> was called. 207 208### Parameters 209 210<table> <tr> <td><a name="SkBitmap_HeapAllocator_allocPixelRef_bitmap"> <code><strong>bitmap </strong></code> </a></td> <td> 211<a href="#Bitmap">Bitmap</a> containing <a href="SkImageInfo_Reference#Image_Info">Image Info</a> as input, and <a href="undocumented#Pixel_Ref">Pixel Ref</a> as output</td> 212 </tr> 213</table> 214 215### Return Value 216 217true if pixels are allocated 218 219### Example 220 221<div><fiddle-embed name="fe79a9c1ec350264eb9c7b2509dd3638"> 222 223#### Example Output 224 225~~~~ 226#Volatile 227pixel address = (nil) 228pixel address = 0x560ddd0ac670 229~~~~ 230 231</fiddle-embed></div> 232 233### See Also 234 235<a href="#SkBitmap_Allocator">Allocator</a> <a href="#SkBitmap_tryAllocPixels">tryAllocPixels</a><sup><a href="#SkBitmap_tryAllocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_4">[4]</a></sup> 236 237--- 238 239<a name="SkBitmap_empty_constructor"></a> 240## SkBitmap 241 242<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 243SkBitmap() 244</pre> 245 246Creates an empty <a href="#Bitmap">Bitmap</a> without pixels, with <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>, 247<a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>, and with a width and height of zero. <a href="undocumented#Pixel_Ref">Pixel Ref</a> origin is 248set to (0, 0). <a href="#Bitmap">Bitmap</a> is not volatile. 249 250Use <a href="#SkBitmap_setInfo">setInfo</a> to associate <a href="SkImageInfo_Reference#SkColorType">SkColorType</a>, <a href="SkImageInfo_Reference#SkAlphaType">SkAlphaType</a>, width, and height 251after <a href="#Bitmap">Bitmap</a> has been created. 252 253### Return Value 254 255empty <a href="#Bitmap">Bitmap</a> 256 257### Example 258 259<div><fiddle-embed name="6739d14ec0d6a373f2fcadc6b3077fd4"> 260 261#### Example Output 262 263~~~~ 264width: 0 height: 0 color: kUnknown_SkColorType alpha: kUnknown_SkAlphaType 265width: 25 height: 35 color: kRGBA_8888_SkColorType alpha: kOpaque_SkAlphaType 266~~~~ 267 268</fiddle-embed></div> 269 270### See Also 271 272<a href="#SkBitmap_setInfo">setInfo</a> 273 274--- 275 276<a name="SkBitmap_copy_const_SkBitmap"></a> 277## SkBitmap 278 279<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 280SkBitmap(const SkBitmap& src) 281</pre> 282 283Copies settings from <a href="#SkBitmap_copy_const_SkBitmap_src">src</a> to returned <a href="#Bitmap">Bitmap</a>. Shares pixels if <a href="#SkBitmap_copy_const_SkBitmap_src">src</a> has pixels 284allocated, so both bitmaps reference the same pixels. 285 286### Parameters 287 288<table> <tr> <td><a name="SkBitmap_copy_const_SkBitmap_src"> <code><strong>src </strong></code> </a></td> <td> 289<a href="#Bitmap">Bitmap</a> to copy <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, and share <a href="undocumented#Pixel_Ref">Pixel Ref</a></td> 290 </tr> 291</table> 292 293### Return Value 294 295copy of <a href="#SkBitmap_copy_const_SkBitmap_src">src</a> 296 297### Example 298 299<div><fiddle-embed name="dbf46a0b60324ec611cc18d86772e7b9"> 300 301#### Example Output 302 303~~~~ 304original has pixels before copy: true 305original has pixels after copy: true 306copy has pixels: true 307~~~~ 308 309</fiddle-embed></div> 310 311### See Also 312 313<a href="#SkBitmap_setInfo">setInfo</a> <a href="#SkBitmap_setPixelRef">setPixelRef</a> <a href="#SkBitmap_setPixels">setPixels</a> <a href="#SkBitmap_swap">swap</a> 314 315--- 316 317<a name="SkBitmap_move_SkBitmap"></a> 318## SkBitmap 319 320<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 321SkBitmap(SkBitmap&& src) 322</pre> 323 324Copies settings from <a href="#SkBitmap_move_SkBitmap_src">src</a> to returned <a href="#Bitmap">Bitmap</a>. Moves ownership of <a href="#SkBitmap_move_SkBitmap_src">src</a> pixels to 325<a href="#Bitmap">Bitmap</a>. 326 327### Parameters 328 329<table> <tr> <td><a name="SkBitmap_move_SkBitmap_src"> <code><strong>src </strong></code> </a></td> <td> 330<a href="#Bitmap">Bitmap</a> to copy <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, and reassign <a href="undocumented#Pixel_Ref">Pixel Ref</a></td> 331 </tr> 332</table> 333 334### Return Value 335 336copy of <a href="#SkBitmap_move_SkBitmap_src">src</a> 337 338### Example 339 340<div><fiddle-embed name="8172a14e66cb763b7133f70dc4ff601e"> 341 342#### Example Output 343 344~~~~ 345original has pixels before move: true 346original has pixels after move: false 347copy has pixels: true 348~~~~ 349 350</fiddle-embed></div> 351 352### See Also 353 354<a href="#SkBitmap_setInfo">setInfo</a> <a href="#SkBitmap_setPixelRef">setPixelRef</a> <a href="#SkBitmap_setPixels">setPixels</a> <a href="#SkBitmap_swap">swap</a> 355 356--- 357 358<a name="SkBitmap_destructor"></a> 359## ~SkBitmap 360 361<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 362~SkBitmap() 363</pre> 364 365Decrements <a href="undocumented#Pixel_Ref">Pixel Ref</a> reference count, if <a href="undocumented#Pixel_Ref">Pixel Ref</a> is not nullptr. 366 367### See Also 368 369<a href="undocumented#Pixel_Ref">Pixel Ref</a> 370 371--- 372 373<a name="SkBitmap_copy_operator"></a> 374## operator= 375 376<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 377SkBitmap& operator=(const SkBitmap& src) 378</pre> 379 380Copies settings from <a href="#SkBitmap_copy_operator_src">src</a> to returned <a href="#Bitmap">Bitmap</a>. Shares pixels if <a href="#SkBitmap_copy_operator_src">src</a> has pixels 381allocated, so both bitmaps reference the same pixels. 382 383### Parameters 384 385<table> <tr> <td><a name="SkBitmap_copy_operator_src"> <code><strong>src </strong></code> </a></td> <td> 386<a href="#Bitmap">Bitmap</a> to copy <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, and share <a href="undocumented#Pixel_Ref">Pixel Ref</a></td> 387 </tr> 388</table> 389 390### Return Value 391 392copy of <a href="#SkBitmap_copy_operator_src">src</a> 393 394### Example 395 396<div><fiddle-embed name="6366fa1b1b3df1bebbfa3ed1c5a43457"> 397 398#### Example Output 399 400~~~~ 401original has pixels before copy: true 402original has pixels after copy: true 403copy has pixels: true 404~~~~ 405 406</fiddle-embed></div> 407 408### See Also 409 410<a href="#SkBitmap_setInfo">setInfo</a> <a href="#SkBitmap_setPixelRef">setPixelRef</a> <a href="#SkBitmap_setPixels">setPixels</a> <a href="#SkBitmap_swap">swap</a> 411 412--- 413 414<a name="SkBitmap_move_operator"></a> 415## operator= 416 417<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 418SkBitmap& operator=(SkBitmap&& src) 419</pre> 420 421Copies settings from <a href="#SkBitmap_move_operator_src">src</a> to returned <a href="#Bitmap">Bitmap</a>. Moves ownership of <a href="#SkBitmap_move_operator_src">src</a> pixels to 422<a href="#Bitmap">Bitmap</a>. 423 424### Parameters 425 426<table> <tr> <td><a name="SkBitmap_move_operator_src"> <code><strong>src </strong></code> </a></td> <td> 427<a href="#Bitmap">Bitmap</a> to copy <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, and reassign <a href="undocumented#Pixel_Ref">Pixel Ref</a></td> 428 </tr> 429</table> 430 431### Return Value 432 433copy of <a href="#SkBitmap_move_operator_src">src</a> 434 435### Example 436 437<div><fiddle-embed name="5066583054077df5098bb1d2aa402149"> 438 439#### Example Output 440 441~~~~ 442original has pixels before move: true 443original has pixels after move: false 444copy has pixels: true 445~~~~ 446 447</fiddle-embed></div> 448 449### See Also 450 451<a href="#SkBitmap_setInfo">setInfo</a> <a href="#SkBitmap_setPixelRef">setPixelRef</a> <a href="#SkBitmap_setPixels">setPixels</a> <a href="#SkBitmap_swap">swap</a> 452 453--- 454 455<a name="SkBitmap_swap"></a> 456## swap 457 458<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 459void swap(SkBitmap& other) 460</pre> 461 462Swaps the fields of the two bitmaps. 463 464### Parameters 465 466<table> <tr> <td><a name="SkBitmap_swap_other"> <code><strong>other </strong></code> </a></td> <td> 467<a href="#Bitmap">Bitmap</a> exchanged with original</td> 468 </tr> 469</table> 470 471### Example 472 473<div><fiddle-embed name="274d02e5f33866b1a9a78423c5569e22"> 474 475#### Example Output 476 477~~~~ 478one width:1 height:1 colorType:kRGBA_8888_SkColorType alphaType:kOpaque_SkAlphaType 479two width:2 height:2 colorType:kBGRA_8888_SkColorType alphaType:kPremul_SkAlphaType 480one width:2 height:2 colorType:kBGRA_8888_SkColorType alphaType:kPremul_SkAlphaType 481two width:1 height:1 colorType:kRGBA_8888_SkColorType alphaType:kOpaque_SkAlphaType 482~~~~ 483 484</fiddle-embed></div> 485 486### See Also 487 488<a href="#SkBitmap_move_SkBitmap">SkBitmap(SkBitmap&& src)</a> <a href="#SkBitmap_move_operator">operator=(SkBitmap&& src)</a> 489 490--- 491 492<a name="SkBitmap_pixmap"></a> 493## pixmap 494 495<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 496const SkPixmap& pixmap() const 497</pre> 498 499Returns a constant reference to the <a href="SkPixmap_Reference#Pixmap">Pixmap</a> holding the <a href="#Bitmap">Bitmap</a> pixel 500address, row bytes, and <a href="SkImageInfo_Reference#Image_Info">Image Info</a>. 501 502### Return Value 503 504reference to <a href="SkPixmap_Reference#Pixmap">Pixmap</a> describing this <a href="#Bitmap">Bitmap</a> 505 506### Example 507 508<div><fiddle-embed name="7f972d742dd78d2500034d8867e9ef2f"> 509 510#### Example Output 511 512~~~~ 513---------- 514---xx----- 515--x--x---- 516--x------- 517--xx------ 518--x-x---x- 519-x---x--x- 520-x----xx-- 521-xx---x--- 522--xxxx-xx- 523---------- 524~~~~ 525 526</fiddle-embed></div> 527 528### See Also 529 530<a href="#SkBitmap_peekPixels">peekPixels</a> <a href="#SkBitmap_installPixels">installPixels</a><sup><a href="#SkBitmap_installPixels_2">[2]</a></sup><sup><a href="#SkBitmap_installPixels_3">[3]</a></sup> <a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> <a href="#SkBitmap_writePixels">writePixels</a><sup><a href="#SkBitmap_writePixels_2">[2]</a></sup><sup><a href="#SkBitmap_writePixels_3">[3]</a></sup> 531 532--- 533 534<a name="SkBitmap_info"></a> 535## info 536 537<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 538const SkImageInfo& info() const 539</pre> 540 541Returns width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, and <a href="undocumented#Color_Space">Color Space</a>. 542 543### Return Value 544 545reference to <a href="SkImageInfo_Reference#Image_Info">Image Info</a> 546 547### Example 548 549<div><fiddle-embed name="ec47c4dc23e2925ad565eaba55a91553"> 550 551#### Example Output 552 553~~~~ 554width: 56 height: 56 color: BGRA_8888 alpha: Opaque 555~~~~ 556 557</fiddle-embed></div> 558 559### See Also 560 561<a href="SkImageInfo_Reference#Image_Info">Image Info</a> 562 563--- 564 565<a name="SkBitmap_width"></a> 566## width 567 568<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 569int width() const 570</pre> 571 572Returns pixel count in each row. Should be equal or less than: 573 574<a href="#SkBitmap_rowBytes">rowBytes</a> / <a href="#SkBitmap_info">info</a>.<a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a>. 575 576Maybe be less than <a href="#SkBitmap_pixelRef">pixelRef</a>.<a href="#SkBitmap_width">width</a>. Will not exceed <a href="#SkBitmap_pixelRef">pixelRef</a>.<a href="#SkBitmap_width">width</a> less 577<a href="#SkBitmap_pixelRefOrigin">pixelRefOrigin</a>.fX. 578 579### Return Value 580 581pixel width in <a href="SkImageInfo_Reference#Image_Info">Image Info</a> 582 583### Example 584 585<div><fiddle-embed name="d06880c42f8bb3b4c3b67bd988046049"> 586 587#### Example Output 588 589~~~~ 590bitmap width: 16 info width: 16 591~~~~ 592 593</fiddle-embed></div> 594 595### See Also 596 597<a href="#SkBitmap_height">height</a> <a href="#SkPixelRef_width">SkPixelRef::width()</a> <a href="#SkImageInfo_width">SkImageInfo::width()</a> 598 599--- 600 601<a name="SkBitmap_height"></a> 602## height 603 604<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 605int height() const 606</pre> 607 608Returns pixel row count. 609 610Maybe be less than <a href="#SkBitmap_pixelRef">pixelRef</a>.<a href="#SkBitmap_height">height</a>. Will not exceed <a href="#SkBitmap_pixelRef">pixelRef</a>.<a href="#SkBitmap_height">height</a> less 611<a href="#SkBitmap_pixelRefOrigin">pixelRefOrigin</a>.fY. 612 613### Return Value 614 615pixel height in <a href="SkImageInfo_Reference#Image_Info">Image Info</a> 616 617### Example 618 619<div><fiddle-embed name="c79a196278c58b34cd5f551b0124ecc9"> 620 621#### Example Output 622 623~~~~ 624bitmap height: 32 info height: 32 625~~~~ 626 627</fiddle-embed></div> 628 629### See Also 630 631<a href="#SkBitmap_width">width</a> <a href="#SkPixelRef_height">SkPixelRef::height()</a> <a href="#SkImageInfo_height">SkImageInfo::height()</a> 632 633--- 634 635<a name="SkBitmap_colorType"></a> 636## colorType 637 638<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 639SkColorType colorType() const 640</pre> 641 642Returns <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, one of: <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>, <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>, 643<a href="SkImageInfo_Reference#SkColorType">kRGB 565 SkColorType</a>, <a href="SkImageInfo_Reference#SkColorType">kARGB 4444 SkColorType</a>, <a href="SkImageInfo_Reference#SkColorType">kRGBA 8888 SkColorType</a>, 644<a href="SkImageInfo_Reference#SkColorType">kBGRA 8888 SkColorType</a>, <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, <a href="SkImageInfo_Reference#SkColorType">kRGBA F16 SkColorType</a>. 645 646### Return Value 647 648<a href="SkImageInfo_Reference#Color_Type">Color Type</a> in <a href="SkImageInfo_Reference#Image_Info">Image Info</a> 649 650### Example 651 652<div><fiddle-embed name="ceb77fab7326b57822a147b04aa0960e"> 653 654#### Example Output 655 656~~~~ 657color type: kAlpha_8_SkColorType 658~~~~ 659 660</fiddle-embed></div> 661 662### See Also 663 664<a href="#SkBitmap_alphaType">alphaType</a> <a href="#SkImageInfo_colorType">SkImageInfo::colorType</a> 665 666--- 667 668<a name="SkBitmap_alphaType"></a> 669## alphaType 670 671<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 672SkAlphaType alphaType() const 673</pre> 674 675Returns <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, one of: <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>, <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>, 676<a href="SkImageInfo_Reference#SkAlphaType">kPremul SkAlphaType</a>, <a href="SkImageInfo_Reference#SkAlphaType">kUnpremul SkAlphaType</a>. 677 678### Return Value 679 680<a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> in <a href="SkImageInfo_Reference#Image_Info">Image Info</a> 681 682### Example 683 684<div><fiddle-embed name="070b1a60232be499eb10c6ea62371804"> 685 686#### Example Output 687 688~~~~ 689alpha type: kPremul_SkAlphaType 690~~~~ 691 692</fiddle-embed></div> 693 694### See Also 695 696<a href="#SkBitmap_colorType">colorType</a> <a href="#SkImageInfo_alphaType">SkImageInfo::alphaType</a> 697 698--- 699 700<a name="SkBitmap_colorSpace"></a> 701## colorSpace 702 703<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 704SkColorSpace* colorSpace() const 705</pre> 706 707Returns <a href="undocumented#Color_Space">Color Space</a>, the range of colors, associated with <a href="SkImageInfo_Reference#Image_Info">Image Info</a>. The 708reference count of <a href="undocumented#Color_Space">Color Space</a> is unchanged. The returned <a href="undocumented#Color_Space">Color Space</a> is 709immutable. 710 711### Return Value 712 713<a href="undocumented#Color_Space">Color Space</a> in <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, or nullptr 714 715### Example 716 717<div><fiddle-embed name="7ade8a1a21ea5197e565c86740b47b73"><div><a href="#SkColorSpace_MakeSRGBLinear">SkColorSpace::MakeSRGBLinear</a> creates <a href="undocumented#Color_Space">Color Space</a> with linear gamma 718and an sRGB gamut. This <a href="undocumented#Color_Space">Color Space</a> gamma is not close to sRGB gamma.</div> 719 720#### Example Output 721 722~~~~ 723gammaCloseToSRGB: false gammaIsLinear: true isSRGB: false 724~~~~ 725 726</fiddle-embed></div> 727 728### See Also 729 730<a href="undocumented#Color_Space">Color Space</a> <a href="#SkImageInfo_colorSpace">SkImageInfo::colorSpace</a> 731 732--- 733 734<a name="SkBitmap_refColorSpace"></a> 735## refColorSpace 736 737<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 738sk_sp<SkColorSpace> refColorSpace() const 739</pre> 740 741Returns a smart pointer to <a href="undocumented#Color_Space">Color Space</a>, the range of colors, associated with 742<a href="SkImageInfo_Reference#Image_Info">Image Info</a>. The smart pointer tracks the number of objects sharing this 743<a href="undocumented#Color_Space">Color Space</a> reference so the memory is released when the owners destruct. 744 745The returned <a href="undocumented#Color_Space">Color Space</a> is immutable. 746 747### Return Value 748 749<a href="undocumented#Color_Space">Color Space</a> in <a href="SkImageInfo_Reference#Image_Info">Image Info</a> wrapped in a smart pointer 750 751### Example 752 753<div><fiddle-embed name="972e9bb22c1ce94bb97b2d106168280e"> 754 755#### Example Output 756 757~~~~ 758gammaCloseToSRGB: false gammaIsLinear: true isSRGB: false 759~~~~ 760 761</fiddle-embed></div> 762 763### See Also 764 765<a href="undocumented#Color_Space">Color Space</a> <a href="#SkImageInfo_colorSpace">SkImageInfo::colorSpace</a> 766 767--- 768 769<a name="SkBitmap_bytesPerPixel"></a> 770## bytesPerPixel 771 772<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 773int bytesPerPixel() const 774</pre> 775 776Returns number of bytes per pixel required by <a href="SkImageInfo_Reference#Color_Type">Color Type</a>. 777Returns zero if <a href="#SkBitmap_colorType">colorType</a>( is <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>. 778 779### Return Value 780 781bytes in pixel 782 783### Example 784 785<div><fiddle-embed name="4bfe28ea3f70f3bfd73d956e913c1a20"> 786 787#### Example Output 788 789~~~~ 790color: kUnknown_SkColorType bytesPerPixel: 0 791color: kAlpha_8_SkColorType bytesPerPixel: 1 792color: kRGB_565_SkColorType bytesPerPixel: 2 793color: kARGB_4444_SkColorType bytesPerPixel: 2 794color: kRGBA_8888_SkColorType bytesPerPixel: 4 795color: kBGRA_8888_SkColorType bytesPerPixel: 4 796color: kGray_8_SkColorType bytesPerPixel: 1 797color: kRGBA_F16_SkColorType bytesPerPixel: 8 798~~~~ 799 800</fiddle-embed></div> 801 802### See Also 803 804<a href="#SkBitmap_rowBytes">rowBytes</a> <a href="#SkBitmap_rowBytesAsPixels">rowBytesAsPixels</a> <a href="#SkBitmap_width">width</a> <a href="#SkBitmap_shiftPerPixel">shiftPerPixel</a> 805 806--- 807 808<a name="SkBitmap_rowBytesAsPixels"></a> 809## rowBytesAsPixels 810 811<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 812int rowBytesAsPixels() const 813</pre> 814 815Returns number of pixels that fit on row. Should be greater than or equal to 816<a href="#SkBitmap_width">width</a>. 817 818### Return Value 819 820maximum pixels per row 821 822### Example 823 824<div><fiddle-embed name="03a9e08082a23a98de17c3e24871d61a"> 825 826#### Example Output 827 828~~~~ 829rowBytes: 4 rowBytesAsPixels: 1 830rowBytes: 5 rowBytesAsPixels: 1 831rowBytes: 6 rowBytesAsPixels: 1 832rowBytes: 7 rowBytesAsPixels: 1 833rowBytes: 8 rowBytesAsPixels: 2 834~~~~ 835 836</fiddle-embed></div> 837 838### See Also 839 840<a href="#SkBitmap_rowBytes">rowBytes</a> <a href="#SkBitmap_shiftPerPixel">shiftPerPixel</a> <a href="#SkBitmap_width">width</a> <a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a> 841 842--- 843 844<a name="SkBitmap_shiftPerPixel"></a> 845## shiftPerPixel 846 847<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 848int shiftPerPixel() const 849</pre> 850 851Returns bit shift converting row bytes to row pixels. 852Returns zero for <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>. 853 854### Return Value 855 856one of: 0, 1, 2, 3; left shift to convert pixels to bytes 857 858### Example 859 860<div><fiddle-embed name="2c77d92f20b950154b9444d3b639b36c"> 861 862#### Example Output 863 864~~~~ 865color: kUnknown_SkColorType shiftPerPixel: 0 866color: kAlpha_8_SkColorType shiftPerPixel: 0 867color: kRGB_565_SkColorType shiftPerPixel: 1 868color: kARGB_4444_SkColorType shiftPerPixel: 1 869color: kRGBA_8888_SkColorType shiftPerPixel: 2 870color: kBGRA_8888_SkColorType shiftPerPixel: 2 871color: kGray_8_SkColorType shiftPerPixel: 0 872color: kRGBA_F16_SkColorType shiftPerPixel: 3 873~~~~ 874 875</fiddle-embed></div> 876 877### See Also 878 879<a href="#SkBitmap_rowBytes">rowBytes</a> <a href="#SkBitmap_rowBytesAsPixels">rowBytesAsPixels</a> <a href="#SkBitmap_width">width</a> <a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a> 880 881--- 882 883<a name="SkBitmap_empty"></a> 884## empty 885 886<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 887bool empty() const 888</pre> 889 890Returns true if either <a href="#SkBitmap_width">width</a> or <a href="#SkBitmap_height">height</a> are zero. 891 892Does not check if <a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr; call <a href="#SkBitmap_drawsNothing">drawsNothing</a> to check <a href="#SkBitmap_width">width</a>, 893<a href="#SkBitmap_height">height</a>, and <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 894 895### Return Value 896 897true if dimensions do not enclose area 898 899### Example 900 901<div><fiddle-embed name="a3762c2722b56ba55e42689c527f146c"> 902 903#### Example Output 904 905~~~~ 906width: 0 height: 0 empty: true 907width: 0 height: 2 empty: true 908width: 2 height: 0 empty: true 909width: 2 height: 2 empty: false 910~~~~ 911 912</fiddle-embed></div> 913 914### See Also 915 916<a href="#SkBitmap_height">height</a> <a href="#SkBitmap_width">width</a> <a href="#SkBitmap_drawsNothing">drawsNothing</a> 917 918--- 919 920<a name="SkBitmap_isNull"></a> 921## isNull 922 923<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 924bool isNull() const 925</pre> 926 927Return true if <a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr. 928 929Does not check if <a href="#SkBitmap_width">width</a> or <a href="#SkBitmap_height">height</a> are zero; call <a href="#SkBitmap_drawsNothing">drawsNothing</a> to check 930<a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_height">height</a>, and <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 931 932### Return Value 933 934true if no <a href="undocumented#Pixel_Ref">Pixel Ref</a> is associated 935 936### Example 937 938<div><fiddle-embed name="211ec89418011aa6e54aa2cc9567e003"> 939 940#### Example Output 941 942~~~~ 943empty bitmap does not have pixels 944bitmap with dimensions does not have pixels 945allocated bitmap does have pixels 946~~~~ 947 948</fiddle-embed></div> 949 950### See Also 951 952<a href="#SkBitmap_empty">empty</a> <a href="#SkBitmap_drawsNothing">drawsNothing</a> <a href="#SkBitmap_pixelRef">pixelRef</a> 953 954--- 955 956<a name="SkBitmap_drawsNothing"></a> 957## drawsNothing 958 959<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 960bool drawsNothing() const 961</pre> 962 963Return true if <a href="#SkBitmap_width">width</a> or <a href="#SkBitmap_height">height</a> are zero, or if <a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr. 964If true, <a href="#Bitmap">Bitmap</a> has no effect when drawn or drawn into. 965 966### Return Value 967 968true if drawing has no effect 969 970### Example 971 972<div><fiddle-embed name="daacf43394ce4045a362a48b5774deed"> 973 974#### Example Output 975 976~~~~ 977empty:true isNull:true drawsNothing:true 978empty:true isNull:false drawsNothing:true 979empty:false isNull:true drawsNothing:true 980empty:false isNull:false drawsNothing:false 981~~~~ 982 983</fiddle-embed></div> 984 985### See Also 986 987<a href="#SkBitmap_empty">empty</a> <a href="#SkBitmap_isNull">isNull</a> <a href="#SkBitmap_pixelRef">pixelRef</a> 988 989--- 990 991<a name="SkBitmap_rowBytes"></a> 992## rowBytes 993 994<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 995size_t rowBytes() const 996</pre> 997 998Returns row bytes, the interval from one pixel row to the next. Row bytes 999is at least as large as<a href="#SkBitmap_width">width</a> * <a href="#SkBitmap_info">info</a>.<a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a>. 1000 1001Returns zero if <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>, or if row bytes supplied to 1002<a href="#SkBitmap_setInfo">setInfo</a> is not large enough to hold a row of pixels. 1003 1004### Return Value 1005 1006byte length of pixel row 1007 1008### Example 1009 1010<div><fiddle-embed name="a654fd0b73f424859ae6c95e03f55099"> 1011 1012#### Example Output 1013 1014~~~~ 1015setInfo returned:false rowBytes:0 1016setInfo returned:true rowBytes:8 1017~~~~ 1018 1019</fiddle-embed></div> 1020 1021### See Also 1022 1023<a href="#SkBitmap_info">info</a> <a href="#SkBitmap_setInfo">setInfo</a> <a href="#SkImageInfo_minRowBytes">SkImageInfo::minRowBytes</a> 1024 1025--- 1026 1027<a name="SkBitmap_setAlphaType"></a> 1028## setAlphaType 1029 1030<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1031bool setAlphaType(SkAlphaType alphaType) 1032</pre> 1033 1034Sets <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, if <a href="#SkBitmap_alphaType">alphaType</a> is compatible with <a href="SkImageInfo_Reference#Color_Type">Color Type</a>. 1035Returns true unless <a href="#SkBitmap_alphaType">alphaType</a> is <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a> and current <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> 1036is not <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>. 1037 1038Returns true if <a href="SkImageInfo_Reference#Color_Type">Color Type</a> is <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>. <a href="#SkBitmap_alphaType">alphaType</a> is ignored, and 1039<a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> remains <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>. 1040 1041Returns true if <a href="SkImageInfo_Reference#Color_Type">Color Type</a> is <a href="SkImageInfo_Reference#SkColorType">kRGB 565 SkColorType</a> or <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>. 1042<a href="#SkBitmap_alphaType">alphaType</a> is ignored, and <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> remains <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>. 1043 1044If <a href="SkImageInfo_Reference#Color_Type">Color Type</a> is <a href="SkImageInfo_Reference#SkColorType">kARGB 4444 SkColorType</a>, <a href="SkImageInfo_Reference#SkColorType">kRGBA 8888 SkColorType</a>, 1045<a href="SkImageInfo_Reference#SkColorType">kBGRA 8888 SkColorType</a>, or <a href="SkImageInfo_Reference#SkColorType">kRGBA F16 SkColorType</a>: returns true unless 1046<a href="#SkBitmap_alphaType">alphaType</a> is <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a> and <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> is not <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>. 1047If <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> is <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>, <a href="#SkBitmap_alphaType">alphaType</a> is ignored. 1048 1049If <a href="SkImageInfo_Reference#Color_Type">Color Type</a> is <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>, returns true unless 1050<a href="#SkBitmap_alphaType">alphaType</a> is <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a> and <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> is not <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>. 1051If <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> is <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>, <a href="#SkBitmap_alphaType">alphaType</a> is ignored. If <a href="#SkBitmap_alphaType">alphaType</a> is 1052<a href="SkImageInfo_Reference#SkAlphaType">kUnpremul SkAlphaType</a>, it is treated as <a href="SkImageInfo_Reference#SkAlphaType">kPremul SkAlphaType</a>. 1053 1054This changes <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> in <a href="undocumented#Pixel_Ref">Pixel Ref</a>; all bitmaps sharing <a href="undocumented#Pixel_Ref">Pixel Ref</a> 1055are affected. 1056 1057### Parameters 1058 1059<table> <tr> <td><a name="SkBitmap_setAlphaType_alphaType"> <code><strong>alphaType </strong></code> </a></td> <td> 1060one of: <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>, <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>, 1061<a href="SkImageInfo_Reference#SkAlphaType">kPremul SkAlphaType</a>, <a href="SkImageInfo_Reference#SkAlphaType">kUnpremul SkAlphaType</a></td> 1062 </tr> 1063</table> 1064 1065### Return Value 1066 1067true if <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> is set 1068 1069### Example 1070 1071<div><fiddle-embed name="9394975fa8a13204a5cc2e94f86737e5"></fiddle-embed></div> 1072 1073### See Also 1074 1075<a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> <a href="SkImageInfo_Reference#Color_Type">Color Type</a> <a href="SkImageInfo_Reference#Image_Info">Image Info</a> <a href="#SkBitmap_setInfo">setInfo</a> 1076 1077--- 1078 1079<a name="SkBitmap_getPixels"></a> 1080## getPixels 1081 1082<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1083void* getPixels() const 1084</pre> 1085 1086Returns pixel address, the base address corresponding to the pixel origin. 1087 1088### Return Value 1089 1090pixel address 1091 1092### Example 1093 1094<div><fiddle-embed name="e006bb05cf74ec8d2b3d6adeb5dba11b"> 1095 1096#### Example Output 1097 1098~~~~ 1099bitmap.getColor(0, 1) == 0x00000000 1100bitmap.getColor(0, 0) == 0xFFFFFFFF 1101~~~~ 1102 1103</fiddle-embed></div> 1104 1105### See Also 1106 1107<a href="#SkBitmap_isNull">isNull</a> <a href="#SkBitmap_drawsNothing">drawsNothing</a> 1108 1109--- 1110 1111<a name="SkBitmap_computeByteSize"></a> 1112## computeByteSize 1113 1114<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1115size_t computeByteSize() const 1116</pre> 1117 1118Returns minimum memory required for pixel storage. 1119Does not include unused memory on last row when <a href="#SkBitmap_rowBytesAsPixels">rowBytesAsPixels</a> exceeds <a href="#SkBitmap_width">width</a>. 1120Returns zero if result does not fit in size_t. 1121Returns zero if <a href="#SkBitmap_height">height</a> or <a href="#SkBitmap_width">width</a> is 0. 1122Returns <a href="#SkBitmap_height">height</a> times <a href="#SkBitmap_rowBytes">rowBytes</a> if <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>. 1123 1124### Return Value 1125 1126size in bytes of image buffer 1127 1128### Example 1129 1130<div><fiddle-embed name="165c8f208829fc0908e8a50da60c0076"> 1131 1132#### Example Output 1133 1134~~~~ 1135width: 1 height: 1 computeByteSize: 4 1136width: 1 height: 1000 computeByteSize: 4999 1137width: 1 height: 1000000 computeByteSize: 4999999 1138width: 1000 height: 1 computeByteSize: 4000 1139width: 1000 height: 1000 computeByteSize: 4999000 1140width: 1000 height: 1000000 computeByteSize: 4999999000 1141width: 1000000 height: 1 computeByteSize: 4000000 1142width: 1000000 height: 1000 computeByteSize: 4999000000 1143width: 1000000 height: 1000000 computeByteSize: 4999999000000 1144~~~~ 1145 1146</fiddle-embed></div> 1147 1148### See Also 1149 1150<a href="#SkImageInfo_computeByteSize">SkImageInfo::computeByteSize</a> 1151 1152--- 1153 1154<a name="SkBitmap_isImmutable"></a> 1155## isImmutable 1156 1157<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1158bool isImmutable() const 1159</pre> 1160 1161Returns true if pixels can not change. 1162 1163Most immutable <a href="#Bitmap">Bitmap</a> checks trigger an assert only on debug builds. 1164 1165### Return Value 1166 1167true if pixels are immutable 1168 1169### Example 1170 1171<div><fiddle-embed name="cca4f94232e5e1fcee9a841b13df9d9c"> 1172 1173#### Example Output 1174 1175~~~~ 1176original is immutable 1177copy is immutable 1178~~~~ 1179 1180</fiddle-embed></div> 1181 1182### See Also 1183 1184<a href="#SkBitmap_setImmutable">setImmutable</a> <a href="#SkPixelRef_isImmutable">SkPixelRef::isImmutable</a> <a href="SkImage_Reference#SkImage">SkImage</a> 1185 1186--- 1187 1188<a name="SkBitmap_setImmutable"></a> 1189## setImmutable 1190 1191<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1192void setImmutable() 1193</pre> 1194 1195Sets internal flag to mark <a href="#Bitmap">Bitmap</a> as immutable. Once set, pixels can not change. 1196Any other bitmap sharing the same <a href="undocumented#Pixel_Ref">Pixel Ref</a> are also marked as immutable. 1197Once <a href="undocumented#Pixel_Ref">Pixel Ref</a> is marked immutable, the setting cannot be cleared. 1198 1199Writing to immutable <a href="#Bitmap">Bitmap</a> pixels triggers an assert on debug builds. 1200 1201### Example 1202 1203<div><fiddle-embed name="9210060d1f4ca46e1375496237902ef3"><div>Triggers assert if SK_DEBUG is true, runs fine otherwise.</div></fiddle-embed></div> 1204 1205### See Also 1206 1207<a href="#SkBitmap_isImmutable">isImmutable</a> <a href="#SkPixelRef_setImmutable">SkPixelRef::setImmutable</a> <a href="SkImage_Reference#SkImage">SkImage</a> 1208 1209--- 1210 1211<a name="SkBitmap_isOpaque"></a> 1212## isOpaque 1213 1214<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1215bool isOpaque() const 1216</pre> 1217 1218Returns true if <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> is <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>. 1219Does not check if <a href="SkImageInfo_Reference#Color_Type">Color Type</a> allows <a href="#Alpha">Alpha</a>, or if any pixel value has 1220transparency. 1221 1222### Return Value 1223 1224true if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> describes opaque <a href="#Alpha">Alpha</a> 1225 1226### Example 1227 1228<div><fiddle-embed name="5e76b68bb46d54315eb0c12d83bd6949"><div><a href="#SkBitmap_isOpaque">isOpaque</a> ignores whether all pixels are opaque or not.</div> 1229 1230#### Example Output 1231 1232~~~~ 1233isOpaque: false 1234isOpaque: false 1235isOpaque: true 1236isOpaque: true 1237~~~~ 1238 1239</fiddle-embed></div> 1240 1241### See Also 1242 1243<a href="#SkBitmap_ComputeIsOpaque">ComputeIsOpaque</a> <a href="#SkImageInfo_isOpaque">SkImageInfo::isOpaque</a> 1244 1245--- 1246 1247<a name="SkBitmap_isVolatile"></a> 1248## isVolatile 1249 1250<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1251bool isVolatile() const 1252</pre> 1253 1254If true, provides a hint to caller that pixels should not 1255be cached. Only true if <a href="#SkBitmap_setIsVolatile">setIsVolatile</a> has been called to mark as volatile. 1256 1257Volatile state is not shared by other bitmaps sharing the same <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 1258 1259### Return Value 1260 1261true if marked volatile 1262 1263### Example 1264 1265<div><fiddle-embed name="4f3e4d39cf34ea52fcd933dbafc46dfa"> 1266 1267#### Example Output 1268 1269~~~~ 1270original is volatile 1271copy is not volatile 1272~~~~ 1273 1274</fiddle-embed></div> 1275 1276### See Also 1277 1278<a href="#SkBitmap_setIsVolatile">setIsVolatile</a> 1279 1280--- 1281 1282<a name="SkBitmap_setIsVolatile"></a> 1283## setIsVolatile 1284 1285<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1286void setIsVolatile(bool isVolatile) 1287</pre> 1288 1289Sets if pixels should be read from <a href="undocumented#Pixel_Ref">Pixel Ref</a> on every access. <a href="#Bitmap">Bitmaps</a> are not 1290volatile by default; a GPU back end may upload pixel values expecting them to be 1291accessed repeatedly. Marking temporary <a href="#Bitmap">Bitmaps</a> as volatile provides a hint to 1292<a href="undocumented#Device">Device</a> that the <a href="#Bitmap">Bitmap</a> pixels should not be cached. This can 1293improve performance by avoiding overhead and reducing resource 1294consumption on <a href="undocumented#Device">Device</a>. 1295 1296### Parameters 1297 1298<table> <tr> <td><a name="SkBitmap_setIsVolatile_isVolatile"> <code><strong>isVolatile </strong></code> </a></td> <td> 1299true if backing pixels are temporary</td> 1300 </tr> 1301</table> 1302 1303### Example 1304 1305<div><fiddle-embed name="9443ada07e6123fc895be4c958244218"></fiddle-embed></div> 1306 1307### See Also 1308 1309<a href="#SkBitmap_isVolatile">isVolatile</a> 1310 1311--- 1312 1313<a name="SkBitmap_reset"></a> 1314## reset 1315 1316<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1317void reset() 1318</pre> 1319 1320Resets to its initial state; all fields are set to zero, as if <a href="#Bitmap">Bitmap</a> had 1321been initialized by <a href="#SkBitmap_empty_constructor">SkBitmap()</a>. 1322 1323Sets width, height, row bytes to zero; pixel address to nullptr; <a href="SkImageInfo_Reference#SkColorType">SkColorType</a> to 1324<a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>; and <a href="SkImageInfo_Reference#SkAlphaType">SkAlphaType</a> to <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>. 1325 1326If <a href="undocumented#Pixel_Ref">Pixel Ref</a> is allocated, its reference count is decreased by one, releasing 1327its memory if <a href="#Bitmap">Bitmap</a> is the sole owner. 1328 1329### Example 1330 1331<div><fiddle-embed name="458f838acf38302abec477cec3102f0f"> 1332 1333#### Example Output 1334 1335~~~~ 1336width:1 height:1 isNull:false 1337width:0 height:0 isNull:true 1338~~~~ 1339 1340</fiddle-embed></div> 1341 1342### See Also 1343 1344<a href="#SkBitmap_empty_constructor">SkBitmap()</a> <a href="SkImageInfo_Reference#SkAlphaType">SkAlphaType</a> <a href="SkImageInfo_Reference#SkColorType">SkColorType</a> 1345 1346--- 1347 1348<a name="SkBitmap_ComputeIsOpaque"></a> 1349## ComputeIsOpaque 1350 1351<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1352static bool ComputeIsOpaque(const SkBitmap& bm) 1353</pre> 1354 1355Returns true if all pixels are opaque. <a href="SkImageInfo_Reference#Color_Type">Color Type</a> determines how pixels 1356are encoded, and whether pixel describes <a href="#Alpha">Alpha</a>. Returns true for <a href="SkImageInfo_Reference#Color_Type">Color Types</a> 1357without alpha in each pixel; for other <a href="SkImageInfo_Reference#Color_Type">Color Types</a>, returns true if all 1358pixels have alpha values equivalent to 1.0 or greater. 1359 1360For <a href="SkImageInfo_Reference#Color_Type">Color Types</a> <a href="SkImageInfo_Reference#SkColorType">kRGB 565 SkColorType</a> or <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>: always 1361returns true. For <a href="SkImageInfo_Reference#Color_Type">Color Types</a> <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>, <a href="SkImageInfo_Reference#SkColorType">kBGRA 8888 SkColorType</a>, 1362<a href="SkImageInfo_Reference#SkColorType">kRGBA 8888 SkColorType</a>: returns true if all pixel <a href="#Alpha">Alpha</a> values are 255. 1363For <a href="SkImageInfo_Reference#Color_Type">Color Type</a> <a href="SkImageInfo_Reference#SkColorType">kARGB 4444 SkColorType</a>: returns true if all pixel <a href="#Alpha">Alpha</a> values are 15. 1364For <a href="SkImageInfo_Reference#SkColorType">kRGBA F16 SkColorType</a>: returns true if all pixel <a href="#Alpha">Alpha</a> values are 1.0 or 1365greater. 1366 1367Returns false for <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>. 1368 1369### Parameters 1370 1371<table> <tr> <td><a name="SkBitmap_ComputeIsOpaque_bm"> <code><strong>bm </strong></code> </a></td> <td> 1372<a href="#Bitmap">Bitmap</a> to check</td> 1373 </tr> 1374</table> 1375 1376### Return Value 1377 1378true if all pixels have opaque values or <a href="SkImageInfo_Reference#Color_Type">Color Type</a> is opaque 1379 1380### Example 1381 1382<div><fiddle-embed name="9df1baa17658fbd0c419780f26fd854f"> 1383 1384#### Example Output 1385 1386~~~~ 1387computeIsOpaque: false 1388computeIsOpaque: true 1389computeIsOpaque: false 1390computeIsOpaque: true 1391~~~~ 1392 1393</fiddle-embed></div> 1394 1395### See Also 1396 1397<a href="#SkBitmap_isOpaque">isOpaque</a> <a href="SkImageInfo_Reference#Color_Type">Color Type</a> <a href="#Alpha">Alpha</a> 1398 1399--- 1400 1401<a name="SkBitmap_getBounds"></a> 1402## getBounds 1403 1404<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1405void getBounds(SkRect* bounds) const 1406</pre> 1407 1408Returns <a href="SkRect_Reference#Rect">Rect</a> { 0, 0, <a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_height">height</a> }. 1409 1410### Parameters 1411 1412<table> <tr> <td><a name="SkBitmap_getBounds_bounds"> <code><strong>bounds </strong></code> </a></td> <td> 1413container for floating point rectangle</td> 1414 </tr> 1415</table> 1416 1417### Example 1418 1419<div><fiddle-embed name="2431ebc7e7d1e91e6d9daafd0f7a478f"></fiddle-embed></div> 1420 1421### See Also 1422 1423<a href="#SkBitmap_bounds">bounds</a> 1424 1425--- 1426 1427<a name="SkBitmap_getBounds_2"></a> 1428 1429<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1430void getBounds(SkIRect* bounds) const 1431</pre> 1432 1433Returns <a href="SkIRect_Reference#IRect">IRect</a> { 0, 0, <a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_height">height</a> }. 1434 1435### Parameters 1436 1437<table> <tr> <td><a name="SkBitmap_getBounds_2_bounds"> <code><strong>bounds </strong></code> </a></td> <td> 1438container for integral rectangle</td> 1439 </tr> 1440</table> 1441 1442### Example 1443 1444<div><fiddle-embed name="0c45da35172bc0a529b2faecddae62a2"></fiddle-embed></div> 1445 1446### See Also 1447 1448<a href="#SkBitmap_bounds">bounds</a> 1449 1450--- 1451 1452<a name="SkBitmap_bounds"></a> 1453## bounds 1454 1455<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1456SkIRect bounds() const 1457</pre> 1458 1459Returns <a href="SkIRect_Reference#IRect">IRect</a> { 0, 0, <a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_height">height</a> }. 1460 1461### Return Value 1462 1463integral rectangle from origin to <a href="#SkBitmap_width">width</a> and <a href="#SkBitmap_height">height</a> 1464 1465### Example 1466 1467<div><fiddle-embed name="41a60435d6eb76cb400fe9be635e3762"></fiddle-embed></div> 1468 1469### See Also 1470 1471<a href="#SkBitmap_getBounds">getBounds</a><sup><a href="#SkBitmap_getBounds_2">[2]</a></sup> 1472 1473--- 1474 1475<a name="SkBitmap_dimensions"></a> 1476## dimensions 1477 1478<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1479SkISize dimensions() const 1480</pre> 1481 1482Returns <a href="undocumented#ISize">ISize</a> { <a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_height">height</a> }. 1483 1484### Return Value 1485 1486integral size of <a href="#SkBitmap_width">width</a> and <a href="#SkBitmap_height">height</a> 1487 1488### Example 1489 1490<div><fiddle-embed name="647056bcc12c27fb4413f212f33a2898"></fiddle-embed></div> 1491 1492### See Also 1493 1494<a href="#SkBitmap_height">height</a> <a href="#SkBitmap_width">width</a> 1495 1496--- 1497 1498<a name="SkBitmap_getSubset"></a> 1499## getSubset 1500 1501<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1502SkIRect getSubset() const 1503</pre> 1504 1505Returns the bounds of this bitmap, offset by its <a href="undocumented#Pixel_Ref">Pixel Ref</a> origin. 1506 1507### Return Value 1508 1509bounds within <a href="undocumented#Pixel_Ref">Pixel Ref</a> bounds 1510 1511### Example 1512 1513<div><fiddle-embed name="d6dd0b425aa550f21b938a18c2e1a981"> 1514 1515#### Example Output 1516 1517~~~~ 1518source: 0, 0, 512, 512 1519subset: 100, 100, 412, 412 1520~~~~ 1521 1522</fiddle-embed></div> 1523 1524### See Also 1525 1526<a href="#SkBitmap_extractSubset">extractSubset</a> <a href="#SkBitmap_getBounds">getBounds</a><sup><a href="#SkBitmap_getBounds_2">[2]</a></sup> 1527 1528--- 1529 1530<a name="SkBitmap_setInfo"></a> 1531## setInfo 1532 1533<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1534bool setInfo(const SkImageInfo& imageInfo, size_t rowBytes = 0) 1535</pre> 1536 1537Sets width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a>, and optional 1538<a href="#SkBitmap_rowBytes">rowBytes</a>. Frees pixels, and returns true if successful. 1539 1540<a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_alphaType">alphaType</a> may be altered to a value permitted by <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_colorSpace">colorSpace</a>. 1541If <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>, <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_alphaType">alphaType</a> is 1542set to <a href="SkImageInfo_Reference#SkAlphaType">kUnknown SkAlphaType</a>. 1543If <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a> and <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_alphaType">alphaType</a> is 1544<a href="SkImageInfo_Reference#SkAlphaType">kUnpremul SkAlphaType</a>, <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_alphaType">alphaType</a> is replaced by <a href="SkImageInfo_Reference#SkAlphaType">kPremul SkAlphaType</a>. 1545If <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kRGB 565 SkColorType</a> or <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, 1546<a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_alphaType">alphaType</a> is set to <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>. 1547If <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kARGB 4444 SkColorType</a>, <a href="SkImageInfo_Reference#SkColorType">kRGBA 8888 SkColorType</a>, 1548<a href="SkImageInfo_Reference#SkColorType">kBGRA 8888 SkColorType</a>, or <a href="SkImageInfo_Reference#SkColorType">kRGBA F16 SkColorType</a>: <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_alphaType">alphaType</a> remains 1549unchanged. 1550 1551<a href="#SkBitmap_rowBytes">rowBytes</a> must equal or exceed <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="SkImageInfo_Reference#SkImageInfo">minRowBytes</a>. If <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_colorSpace">colorSpace</a> is 1552<a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>, <a href="#SkBitmap_rowBytes">rowBytes</a> is ignored and treated as zero; for all other 1553<a href="undocumented#Color_Space">Color Space</a> values, <a href="#SkBitmap_rowBytes">rowBytes</a> of zero is treated as <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="SkImageInfo_Reference#SkImageInfo">minRowBytes</a>. 1554 1555Calls <a href="#SkBitmap_reset">reset</a> and returns false if: 1556 1557<table> <tr> 1558 <td><a href="#SkBitmap_rowBytes">rowBytes</a> exceeds 31 bits</td> </tr> <tr> 1559 <td><a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_width">width</a> is negative</td> </tr> <tr> 1560 <td><a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_height">height</a> is negative</td> </tr> <tr> 1561 <td><a href="#SkBitmap_rowBytes">rowBytes</a> is positive and less than <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_width">width</a> times <a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a></td> </tr> 1562</table> 1563 1564### Parameters 1565 1566<table> <tr> <td><a name="SkBitmap_setInfo_imageInfo"> <code><strong>imageInfo </strong></code> </a></td> <td> 1567contains width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 1568 </tr> <tr> <td><a name="SkBitmap_setInfo_rowBytes"> <code><strong>rowBytes </strong></code> </a></td> <td> 1569<a href="#SkBitmap_setInfo_imageInfo">imageInfo</a>.<a href="SkImageInfo_Reference#SkImageInfo">minRowBytes</a> or larger; or zero</td> 1570 </tr> 1571</table> 1572 1573### Return Value 1574 1575true if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> set successfully 1576 1577### Example 1578 1579<div><fiddle-embed name="599ab64d0aea005498176249bbfb64eb"></fiddle-embed></div> 1580 1581### See Also 1582 1583<a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> <a href="SkImageInfo_Reference#Color_Type">Color Type</a> <a href="undocumented#Color_Space">Color Space</a> <a href="#SkBitmap_height">height</a> <a href="#SkBitmap_rowBytes">rowBytes</a> <a href="#SkBitmap_width">width</a> 1584 1585--- 1586 1587## <a name="SkBitmap_AllocFlags"></a> Enum SkBitmap::AllocFlags 1588 1589<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1590enum <a href="#SkBitmap_AllocFlags">AllocFlags</a> { 1591<a href="#SkBitmap_kZeroPixels_AllocFlag">kZeroPixels AllocFlag</a> = 1 << 0, 1592};</pre> 1593 1594<a href="#SkBitmap_AllocFlags">AllocFlags</a> provides the option to zero pixel memory when allocated. 1595 1596### Constants 1597 1598<table> 1599 <tr> 1600 <td><a name="SkBitmap_kZeroPixels_AllocFlag"> <code><strong>SkBitmap::kZeroPixels_AllocFlag </strong></code> </a></td><td>1</td><td>Instructs <a href="#SkBitmap_tryAllocPixelsFlags">tryAllocPixelsFlags</a> and <a href="#SkBitmap_allocPixelsFlags">allocPixelsFlags</a> to zero pixel memory.</td> 1601 </tr> 1602</table> 1603 1604### See Also 1605 1606<a href="#SkBitmap_tryAllocPixelsFlags">tryAllocPixelsFlags</a> <a href="#SkBitmap_allocPixelsFlags">allocPixelsFlags</a> <a href="#SkBitmap_erase">erase</a> <a href="#SkBitmap_eraseColor">eraseColor</a> 1607 1608 1609 1610<a name="SkBitmap_tryAllocPixelsFlags"></a> 1611## tryAllocPixelsFlags 1612 1613<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1614bool SK_WARN_UNUSED_RESULT tryAllocPixelsFlags(const SkImageInfo& info, uint32_t flags) 1615</pre> 1616 1617Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to info following the rules in <a href="#SkBitmap_setInfo">setInfo</a> and allocates pixel 1618memory. If <a href="#SkBitmap_tryAllocPixelsFlags_flags">flags</a> is <a href="#SkBitmap_kZeroPixels_AllocFlag">kZeroPixels AllocFlag</a>, memory is zeroed. 1619 1620Returns false and calls <a href="#SkBitmap_reset">reset</a> if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> could not be set, or memory could 1621not be allocated, or memory could not optionally be zeroed. 1622 1623On most platforms, allocating pixel memory may succeed even though there is 1624not sufficient memory to hold pixels; allocation does not take place 1625until the pixels are written to. The actual behavior depends on the platform 1626implementation of malloc(), if <a href="#SkBitmap_tryAllocPixelsFlags_flags">flags</a> is zero, and calloc(), if <a href="#SkBitmap_tryAllocPixelsFlags_flags">flags</a> is 1627<a href="#SkBitmap_kZeroPixels_AllocFlag">kZeroPixels AllocFlag</a>. 1628 1629Passing <a href="#SkBitmap_kZeroPixels_AllocFlag">kZeroPixels AllocFlag</a> is usually faster than separately calling 1630 1631### Parameters 1632 1633<table> <tr> <td><a name="SkBitmap_tryAllocPixelsFlags_info"> <code><strong>info </strong></code> </a></td> <td> 1634contains width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 1635 </tr> <tr> <td><a name="SkBitmap_tryAllocPixelsFlags_flags"> <code><strong>flags </strong></code> </a></td> <td> 1636<a href="#SkBitmap_kZeroPixels_AllocFlag">kZeroPixels AllocFlag</a>, or zero</td> 1637 </tr> 1638</table> 1639 1640### Return Value 1641 1642true if pixels allocation is successful 1643 1644### Example 1645 1646<div><fiddle-embed name="4fff5f5034ced615ad5a1d50c40aeff3"> 1647 1648#### Example Output 1649 1650~~~~ 1651bitmap allocation succeeded! 1652~~~~ 1653 1654</fiddle-embed></div> 1655 1656### See Also 1657 1658<a href="#SkBitmap_allocPixelsFlags">allocPixelsFlags</a> <a href="#SkBitmap_tryAllocPixels">tryAllocPixels</a><sup><a href="#SkBitmap_tryAllocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_4">[4]</a></sup> <a href="#SkMallocPixelRef_MakeZeroed">SkMallocPixelRef::MakeZeroed</a> 1659 1660--- 1661 1662<a name="SkBitmap_allocPixelsFlags"></a> 1663## allocPixelsFlags 1664 1665<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1666void allocPixelsFlags(const SkImageInfo& info, uint32_t flags) 1667</pre> 1668 1669Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to info following the rules in <a href="#SkBitmap_setInfo">setInfo</a> and allocates pixel 1670memory. If <a href="#SkBitmap_allocPixelsFlags_flags">flags</a> is <a href="#SkBitmap_kZeroPixels_AllocFlag">kZeroPixels AllocFlag</a>, memory is zeroed. 1671 1672Aborts execution if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> could not be set, or memory could 1673not be allocated, or memory could not optionally 1674be zeroed. Abort steps may be provided by the user at compile time by defining 1675SK_ABORT. 1676 1677On most platforms, allocating pixel memory may succeed even though there is 1678not sufficient memory to hold pixels; allocation does not take place 1679until the pixels are written to. The actual behavior depends on the platform 1680implementation of malloc(), if <a href="#SkBitmap_allocPixelsFlags_flags">flags</a> is zero, and calloc(), if <a href="#SkBitmap_allocPixelsFlags_flags">flags</a> is 1681<a href="#SkBitmap_kZeroPixels_AllocFlag">kZeroPixels AllocFlag</a>. 1682 1683Passing <a href="#SkBitmap_kZeroPixels_AllocFlag">kZeroPixels AllocFlag</a> is usually faster than separately calling 1684 1685### Parameters 1686 1687<table> <tr> <td><a name="SkBitmap_allocPixelsFlags_info"> <code><strong>info </strong></code> </a></td> <td> 1688contains width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 1689 </tr> <tr> <td><a name="SkBitmap_allocPixelsFlags_flags"> <code><strong>flags </strong></code> </a></td> <td> 1690<a href="#SkBitmap_kZeroPixels_AllocFlag">kZeroPixels AllocFlag</a>, or zero</td> 1691 </tr> 1692</table> 1693 1694### Example 1695 1696<div><fiddle-embed name="f21b8965a88c94a32393a8890c4672af"><div><a href="undocumented#Text">Text</a> is drawn on a transparent background; drawing the bitmap a second time 1697lets the first draw show through.</div></fiddle-embed></div> 1698 1699### See Also 1700 1701<a href="#SkBitmap_tryAllocPixelsFlags">tryAllocPixelsFlags</a> <a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> <a href="#SkMallocPixelRef_MakeZeroed">SkMallocPixelRef::MakeZeroed</a> 1702 1703--- 1704 1705<a name="SkBitmap_tryAllocPixels"></a> 1706## tryAllocPixels 1707 1708<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1709bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info, size_t rowBytes) 1710</pre> 1711 1712Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to info following the rules in <a href="#SkBitmap_setInfo">setInfo</a> and allocates pixel 1713memory. <a href="#SkBitmap_rowBytes">rowBytes</a> must equal or exceed info.<a href="#SkBitmap_width">width</a> times info.<a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a>, 1714or equal zero. Pass in zero for <a href="#SkBitmap_rowBytes">rowBytes</a> to compute the minimum valid value. 1715 1716Returns false and calls <a href="#SkBitmap_reset">reset</a> if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> could not be set, or memory could 1717not be allocated. 1718 1719On most platforms, allocating pixel memory may succeed even though there is 1720not sufficient memory to hold pixels; allocation does not take place 1721until the pixels are written to. The actual behavior depends on the platform 1722implementation of malloc(). 1723 1724### Parameters 1725 1726<table> <tr> <td><a name="SkBitmap_tryAllocPixels_info"> <code><strong>info </strong></code> </a></td> <td> 1727contains width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 1728 </tr> <tr> <td><a name="SkBitmap_tryAllocPixels_rowBytes"> <code><strong>rowBytes </strong></code> </a></td> <td> 1729size of pixel row or larger; may be zero</td> 1730 </tr> 1731</table> 1732 1733### Return Value 1734 1735true if pixel storage is allocated 1736 1737### Example 1738 1739<div><fiddle-embed name="34479d5aa23ce9f5e334b0786c9edb22"></fiddle-embed></div> 1740 1741### See Also 1742 1743<a href="#SkBitmap_tryAllocPixelsFlags">tryAllocPixelsFlags</a> <a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> <a href="#SkMallocPixelRef_MakeAllocate">SkMallocPixelRef::MakeAllocate</a> 1744 1745--- 1746 1747<a name="SkBitmap_allocPixels"></a> 1748## allocPixels 1749 1750<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1751void allocPixels(const SkImageInfo& info, size_t rowBytes) 1752</pre> 1753 1754Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to info following the rules in <a href="#SkBitmap_setInfo">setInfo</a> and allocates pixel 1755memory. <a href="#SkBitmap_rowBytes">rowBytes</a> must equal or exceed info.<a href="#SkBitmap_width">width</a> times info.<a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a>, 1756or equal zero. Pass in zero for <a href="#SkBitmap_rowBytes">rowBytes</a> to compute the minimum valid value. 1757 1758Aborts execution if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> could not be set, or memory could 1759not be allocated. Abort steps may be provided by 1760the user at compile time by defining SK_ABORT. 1761 1762On most platforms, allocating pixel memory may succeed even though there is 1763not sufficient memory to hold pixels; allocation does not take place 1764until the pixels are written to. The actual behavior depends on the platform 1765implementation of malloc(). 1766 1767### Parameters 1768 1769<table> <tr> <td><a name="SkBitmap_allocPixels_info"> <code><strong>info </strong></code> </a></td> <td> 1770contains width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 1771 </tr> <tr> <td><a name="SkBitmap_allocPixels_rowBytes"> <code><strong>rowBytes </strong></code> </a></td> <td> 1772size of pixel row or larger; may be zero</td> 1773 </tr> 1774</table> 1775 1776### Example 1777 1778<div><fiddle-embed name="555c0f62f96602a9dcd459badcd005e0"></fiddle-embed></div> 1779 1780### See Also 1781 1782<a href="#SkBitmap_tryAllocPixels">tryAllocPixels</a><sup><a href="#SkBitmap_tryAllocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_4">[4]</a></sup> <a href="#SkBitmap_allocPixelsFlags">allocPixelsFlags</a> <a href="#SkMallocPixelRef_MakeAllocate">SkMallocPixelRef::MakeAllocate</a> 1783 1784--- 1785 1786<a name="SkBitmap_tryAllocPixels_2"></a> 1787 1788<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1789bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info) 1790</pre> 1791 1792Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to info following the rules in <a href="#SkBitmap_setInfo">setInfo</a> and allocates pixel 1793memory. 1794 1795Returns false and calls <a href="#SkBitmap_reset">reset</a> if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> could not be set, or memory could 1796not be allocated. 1797 1798On most platforms, allocating pixel memory may succeed even though there is 1799not sufficient memory to hold pixels; allocation does not take place 1800until the pixels are written to. The actual behavior depends on the platform 1801implementation of malloc(). 1802 1803### Parameters 1804 1805<table> <tr> <td><a name="SkBitmap_tryAllocPixels_2_info"> <code><strong>info </strong></code> </a></td> <td> 1806contains width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 1807 </tr> 1808</table> 1809 1810### Return Value 1811 1812true if pixel storage is allocated 1813 1814### Example 1815 1816<div><fiddle-embed name="7ef3d043c4c5885649e591dd7dca92ff"></fiddle-embed></div> 1817 1818### See Also 1819 1820<a href="#SkBitmap_tryAllocPixelsFlags">tryAllocPixelsFlags</a> <a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> <a href="#SkMallocPixelRef_MakeAllocate">SkMallocPixelRef::MakeAllocate</a> 1821 1822--- 1823 1824<a name="SkBitmap_allocPixels_2"></a> 1825 1826<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1827void allocPixels(const SkImageInfo& info) 1828</pre> 1829 1830Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to info following the rules in <a href="#SkBitmap_setInfo">setInfo</a> and allocates pixel 1831memory. 1832 1833Aborts execution if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> could not be set, or memory could 1834not be allocated. Abort steps may be provided by 1835the user at compile time by defining SK_ABORT. 1836 1837On most platforms, allocating pixel memory may succeed even though there is 1838not sufficient memory to hold pixels; allocation does not take place 1839until the pixels are written to. The actual behavior depends on the platform 1840implementation of malloc(). 1841 1842### Parameters 1843 1844<table> <tr> <td><a name="SkBitmap_allocPixels_2_info"> <code><strong>info </strong></code> </a></td> <td> 1845contains width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 1846 </tr> 1847</table> 1848 1849### Example 1850 1851<div><fiddle-embed name="91f474a11a2112cd5c88c40a9015048d"></fiddle-embed></div> 1852 1853### See Also 1854 1855<a href="#SkBitmap_tryAllocPixels">tryAllocPixels</a><sup><a href="#SkBitmap_tryAllocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_4">[4]</a></sup> <a href="#SkBitmap_allocPixelsFlags">allocPixelsFlags</a> <a href="#SkMallocPixelRef_MakeAllocate">SkMallocPixelRef::MakeAllocate</a> 1856 1857--- 1858 1859<a name="SkBitmap_tryAllocN32Pixels"></a> 1860## tryAllocN32Pixels 1861 1862<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1863bool SK_WARN_UNUSED_RESULT tryAllocN32Pixels(int width, int height, bool isOpaque = false) 1864</pre> 1865 1866Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to width, height, and <a href="SkImageInfo_Reference#Color_Type">Native Color Type</a>; and allocates 1867pixel memory. If <a href="#SkBitmap_isOpaque">isOpaque</a> is true, sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>; 1868otherwise, sets to <a href="SkImageInfo_Reference#SkAlphaType">kPremul SkAlphaType</a>. 1869 1870Calls <a href="#SkBitmap_reset">reset</a> and returns false if width exceeds 29 bits or is negative, 1871or height is negative. 1872 1873Returns false if allocation fails. 1874 1875Use to create <a href="#Bitmap">Bitmap</a> that matches <a href="undocumented#SkPMColor">SkPMColor</a>, the native pixel arrangement on 1876the platform. <a href="#Bitmap">Bitmap</a> drawn to output device skips converting its pixel format. 1877 1878### Parameters 1879 1880<table> <tr> <td><a name="SkBitmap_tryAllocN32Pixels_width"> <code><strong>width </strong></code> </a></td> <td> 1881pixel column count; must be zero or greater</td> 1882 </tr> <tr> <td><a name="SkBitmap_tryAllocN32Pixels_height"> <code><strong>height </strong></code> </a></td> <td> 1883pixel row count; must be zero or greater</td> 1884 </tr> <tr> <td><a name="SkBitmap_tryAllocN32Pixels_isOpaque"> <code><strong>isOpaque </strong></code> </a></td> <td> 1885true if pixels do not have transparency</td> 1886 </tr> 1887</table> 1888 1889### Return Value 1890 1891true if pixel storage is allocated 1892 1893### Example 1894 1895<div><fiddle-embed name="a2b1e0910f37066f15ae56368775a6d8"></fiddle-embed></div> 1896 1897### See Also 1898 1899<a href="#SkBitmap_tryAllocPixels">tryAllocPixels</a><sup><a href="#SkBitmap_tryAllocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_4">[4]</a></sup> <a href="#SkBitmap_allocN32Pixels">allocN32Pixels</a> <a href="#SkMallocPixelRef_MakeAllocate">SkMallocPixelRef::MakeAllocate</a> 1900 1901--- 1902 1903<a name="SkBitmap_allocN32Pixels"></a> 1904## allocN32Pixels 1905 1906<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1907void allocN32Pixels(int width, int height, bool isOpaque = false) 1908</pre> 1909 1910Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to width, height, and the <a href="SkImageInfo_Reference#Color_Type">Native Color Type</a>; and allocates 1911pixel memory. If <a href="#SkBitmap_isOpaque">isOpaque</a> is true, sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to <a href="SkImageInfo_Reference#SkAlphaType">kPremul SkAlphaType</a>; 1912otherwise, sets to <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>. 1913 1914Aborts if width exceeds 29 bits or is negative, or height is negative, or 1915allocation fails. Abort steps may be provided by the user at compile time by 1916defining SK_ABORT. 1917 1918Use to create <a href="#Bitmap">Bitmap</a> that matches <a href="undocumented#SkPMColor">SkPMColor</a>, the native pixel arrangement on 1919the platform. <a href="#Bitmap">Bitmap</a> drawn to output device skips converting its pixel format. 1920 1921### Parameters 1922 1923<table> <tr> <td><a name="SkBitmap_allocN32Pixels_width"> <code><strong>width </strong></code> </a></td> <td> 1924pixel column count; must be zero or greater</td> 1925 </tr> <tr> <td><a name="SkBitmap_allocN32Pixels_height"> <code><strong>height </strong></code> </a></td> <td> 1926pixel row count; must be zero or greater</td> 1927 </tr> <tr> <td><a name="SkBitmap_allocN32Pixels_isOpaque"> <code><strong>isOpaque </strong></code> </a></td> <td> 1928true if pixels do not have transparency</td> 1929 </tr> 1930</table> 1931 1932### Example 1933 1934<div><fiddle-embed name="c717491f9251604724c9cbde7088ec20"></fiddle-embed></div> 1935 1936### See Also 1937 1938<a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> <a href="#SkBitmap_tryAllocN32Pixels">tryAllocN32Pixels</a> <a href="#SkMallocPixelRef_MakeAllocate">SkMallocPixelRef::MakeAllocate</a> 1939 1940--- 1941 1942<a name="SkBitmap_installPixels"></a> 1943## installPixels 1944 1945<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1946bool installPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, void (*releaseProc) 1947 (void* addr, void* context) , void* context) 1948</pre> 1949 1950Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to info following the rules in <a href="#SkBitmap_setInfo">setInfo</a>, and creates <a href="undocumented#Pixel_Ref">Pixel Ref</a> 1951containing <a href="#SkBitmap_installPixels_pixels">pixels</a> and <a href="#SkBitmap_rowBytes">rowBytes</a>. <a href="#SkBitmap_installPixels_releaseProc">releaseProc</a>, if not nullptr, is called 1952immediately on failure or when <a href="#SkBitmap_installPixels_pixels">pixels</a> are no longer referenced. <a href="#SkBitmap_installPixels_context">context</a> may be 1953nullptr. 1954 1955If <a href="SkImageInfo_Reference#Image_Info">Image Info</a> could not be set, or <a href="#SkBitmap_rowBytes">rowBytes</a> is less than info.<a href="SkImageInfo_Reference#SkImageInfo">minRowBytes</a>: 1956calls <a href="#SkBitmap_installPixels_releaseProc">releaseProc</a> if present, calls <a href="#SkBitmap_reset">reset</a>, and returns false. 1957 1958Otherwise, if <a href="#SkBitmap_installPixels_pixels">pixels</a> equals nullptr: sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, calls <a href="#SkBitmap_installPixels_releaseProc">releaseProc</a> if 1959present, returns true. 1960 1961If <a href="SkImageInfo_Reference#Image_Info">Image Info</a> is set, <a href="#SkBitmap_installPixels_pixels">pixels</a> is not nullptr, and <a href="#SkBitmap_installPixels_releaseProc">releaseProc</a> is not nullptr: 1962when <a href="#SkBitmap_installPixels_pixels">pixels</a> are no longer referenced, calls <a href="#SkBitmap_installPixels_releaseProc">releaseProc</a> with <a href="#SkBitmap_installPixels_pixels">pixels</a> and <a href="#SkBitmap_installPixels_context">context</a> 1963as parameters. 1964 1965### Parameters 1966 1967<table> <tr> <td><a name="SkBitmap_installPixels_info"> <code><strong>info </strong></code> </a></td> <td> 1968contains width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 1969 </tr> <tr> <td><a name="SkBitmap_installPixels_pixels"> <code><strong>pixels </strong></code> </a></td> <td> 1970address or pixel storage; may be nullptr</td> 1971 </tr> <tr> <td><a name="SkBitmap_installPixels_rowBytes"> <code><strong>rowBytes </strong></code> </a></td> <td> 1972size of pixel row or larger</td> 1973 </tr> <tr> <td><a name="SkBitmap_installPixels_releaseProc"> <code><strong>releaseProc </strong></code> </a></td> <td> 1974function called when <a href="#SkBitmap_installPixels_pixels">pixels</a> can be deleted; may be nullptr</td> 1975 </tr> <tr> <td><a name="SkBitmap_installPixels_context"> <code><strong>context </strong></code> </a></td> <td> 1976caller state passed to <a href="#SkBitmap_installPixels_releaseProc">releaseProc</a>; may be nullptr</td> 1977 </tr> 1978</table> 1979 1980### Return Value 1981 1982true if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> is set to info 1983 1984### Example 1985 1986<div><fiddle-embed name="ff5b5c349efb5d929ff5dff07b7727e6"><div><a href="#SkBitmap_installPixels_releaseProc">releaseProc</a> is called immediately because <a href="#SkBitmap_rowBytes">rowBytes</a> is too small for <a href="undocumented#Pixel_Ref">Pixel Ref</a>.</div> 1987 1988#### Example Output 1989 1990~~~~ 1991before installPixels 1992releaseProc called 1993install not successful 1994~~~~ 1995 1996</fiddle-embed></div> 1997 1998### See Also 1999 2000<a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> 2001 2002--- 2003 2004<a name="SkBitmap_installPixels_2"></a> 2005 2006<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2007bool installPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) 2008</pre> 2009 2010Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to info following the rules in <a href="#SkBitmap_setInfo">setInfo</a>, and creates <a href="undocumented#Pixel_Ref">Pixel Ref</a> 2011containing <a href="#SkBitmap_installPixels_2_pixels">pixels</a> and <a href="#SkBitmap_rowBytes">rowBytes</a>. 2012 2013If <a href="SkImageInfo_Reference#Image_Info">Image Info</a> could not be set, or <a href="#SkBitmap_rowBytes">rowBytes</a> is less than info.<a href="SkImageInfo_Reference#SkImageInfo">minRowBytes</a>: 2014calls <a href="#SkBitmap_reset">reset</a>, and returns false. 2015 2016Otherwise, if <a href="#SkBitmap_installPixels_2_pixels">pixels</a> equals nullptr: sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, returns true. 2017 2018Caller must ensure that <a href="#SkBitmap_installPixels_2_pixels">pixels</a> are valid for the lifetime of <a href="#Bitmap">Bitmap</a> and <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 2019 2020### Parameters 2021 2022<table> <tr> <td><a name="SkBitmap_installPixels_2_info"> <code><strong>info </strong></code> </a></td> <td> 2023contains width, height, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 2024 </tr> <tr> <td><a name="SkBitmap_installPixels_2_pixels"> <code><strong>pixels </strong></code> </a></td> <td> 2025address or pixel storage; may be nullptr</td> 2026 </tr> <tr> <td><a name="SkBitmap_installPixels_2_rowBytes"> <code><strong>rowBytes </strong></code> </a></td> <td> 2027size of pixel row or larger</td> 2028 </tr> 2029</table> 2030 2031### Return Value 2032 2033true if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> is set to info 2034 2035### Example 2036 2037<div><fiddle-embed name="a7e04447b2081010c50d7920e80a6bb2"><div>GPU does not support <a href="SkImageInfo_Reference#SkAlphaType">kUnpremul SkAlphaType</a>, does not assert that it does not.</div></fiddle-embed></div> 2038 2039### See Also 2040 2041<a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> 2042 2043--- 2044 2045<a name="SkBitmap_installPixels_3"></a> 2046 2047<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2048bool installPixels(const SkPixmap& pixmap) 2049</pre> 2050 2051Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to pixmap.<a href="#SkBitmap_info">info</a> following the rules in <a href="#SkBitmap_setInfo">setInfo</a>, and creates 2052<a href="undocumented#Pixel_Ref">Pixel Ref</a> containing pixmap.addr() and pixmap.<a href="#SkBitmap_rowBytes">rowBytes</a>. 2053 2054If <a href="SkImageInfo_Reference#Image_Info">Image Info</a> could not be set, or pixmap.<a href="#SkBitmap_rowBytes">rowBytes</a> is less than 2055<a href="#SkImageInfo_minRowBytes">SkImageInfo::minRowBytes</a>: calls <a href="#SkBitmap_reset">reset</a>, and returns false. 2056 2057Otherwise, if pixmap.addr() equals nullptr: sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, returns true. 2058 2059Caller must ensure that pixmap is valid for the lifetime of <a href="#Bitmap">Bitmap</a> and <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 2060 2061### Parameters 2062 2063<table> <tr> <td><a name="SkBitmap_installPixels_3_pixmap"> <code><strong>pixmap </strong></code> </a></td> <td> 2064<a href="SkImageInfo_Reference#Image_Info">Image Info</a>, pixel address, and <a href="#SkBitmap_rowBytes">rowBytes</a></td> 2065 </tr> 2066</table> 2067 2068### Return Value 2069 2070true if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> was set to pixmap.<a href="#SkBitmap_info">info</a> 2071 2072### Example 2073 2074<div><fiddle-embed name="6e2a8c9358b34aebd2ec586815fe9d3a"><div>Draw a five by five bitmap, and draw it again with a center white pixel.</div></fiddle-embed></div> 2075 2076### See Also 2077 2078<a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> 2079 2080--- 2081 2082<a name="SkBitmap_installMaskPixels"></a> 2083## installMaskPixels 2084 2085<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2086bool installMaskPixels(const SkMask& mask) 2087</pre> 2088 2089Sets <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to <a href="#SkBitmap_installMaskPixels_mask">mask</a> width, <a href="#SkBitmap_installMaskPixels_mask">mask</a> height, <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>, and 2090<a href="SkImageInfo_Reference#SkAlphaType">kPremul SkAlphaType</a>. Sets <a href="undocumented#Pixel_Ref">Pixel Ref</a> to <a href="#SkBitmap_installMaskPixels_mask">mask</a> image and <a href="#SkBitmap_installMaskPixels_mask">mask</a> <a href="#SkBitmap_rowBytes">rowBytes</a>. 2091 2092Returns false and calls <a href="#SkBitmap_reset">reset</a> if <a href="#SkBitmap_installMaskPixels_mask">mask</a> format is not <a href="#SkMask_kA8_Format">SkMask::kA8 Format</a>, 2093or if <a href="#SkBitmap_installMaskPixels_mask">mask</a> width or <a href="#SkBitmap_installMaskPixels_mask">mask</a> height is negative, or if <a href="#SkBitmap_installMaskPixels_mask">mask</a> <a href="#SkBitmap_rowBytes">rowBytes</a> is less 2094than <a href="#SkBitmap_installMaskPixels_mask">mask</a> width. 2095 2096Caller must ensure that <a href="#SkBitmap_installMaskPixels_mask">mask</a> is valid for the lifetime of <a href="#Bitmap">Bitmap</a> and <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 2097 2098### Parameters 2099 2100<table> <tr> <td><a name="SkBitmap_installMaskPixels_mask"> <code><strong>mask </strong></code> </a></td> <td> 2101<a href="#Alpha">Alpha</a> 8-bit bitmap</td> 2102 </tr> 2103</table> 2104 2105### Return Value 2106 2107true if <a href="SkImageInfo_Reference#Image_Info">Image Info</a> and <a href="undocumented#Pixel_Ref">Pixel Ref</a> refer to <a href="#SkBitmap_installMaskPixels_mask">mask</a> 2108 2109### Example 2110 2111<div><fiddle-embed name="b0456fc063ca467ccecf2105160a3d1d"><div>Draw a five by five bitmap, and draw it again with a center white pixel.</div></fiddle-embed></div> 2112 2113### See Also 2114 2115<a href="#SkBitmap_installPixels">installPixels</a><sup><a href="#SkBitmap_installPixels_2">[2]</a></sup><sup><a href="#SkBitmap_installPixels_3">[3]</a></sup> <a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> 2116 2117--- 2118 2119<a name="SkBitmap_setPixels"></a> 2120## setPixels 2121 2122<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2123void setPixels(void* pixels) 2124</pre> 2125 2126Replaces <a href="undocumented#Pixel_Ref">Pixel Ref</a> with <a href="#SkBitmap_setPixels_pixels">pixels</a>, preserving <a href="SkImageInfo_Reference#Image_Info">Image Info</a> and <a href="#SkBitmap_rowBytes">rowBytes</a>. 2127Sets <a href="undocumented#Pixel_Ref">Pixel Ref</a> origin to (0, 0). 2128 2129If <a href="#SkBitmap_setPixels_pixels">pixels</a> is nullptr, or if <a href="#SkBitmap_info">info</a>.<a href="#SkBitmap_colorType">colorType</a> equals <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>; 2130release reference to <a href="undocumented#Pixel_Ref">Pixel Ref</a>, and set <a href="undocumented#Pixel_Ref">Pixel Ref</a> to nullptr. 2131 2132Caller is responsible for handling ownership pixel memory for the lifetime 2133of <a href="#Bitmap">Bitmap</a> and <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 2134 2135### Parameters 2136 2137<table> <tr> <td><a name="SkBitmap_setPixels_pixels"> <code><strong>pixels </strong></code> </a></td> <td> 2138address of pixel storage, managed by caller</td> 2139 </tr> 2140</table> 2141 2142### Example 2143 2144<div><fiddle-embed name="f0db16e06c9a1436917c8179f8c1718f"></fiddle-embed></div> 2145 2146### See Also 2147 2148<a href="#SkBitmap_installPixels">installPixels</a><sup><a href="#SkBitmap_installPixels_2">[2]</a></sup><sup><a href="#SkBitmap_installPixels_3">[3]</a></sup> <a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> 2149 2150--- 2151 2152<a name="SkBitmap_tryAllocPixels_3"></a> 2153 2154<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2155bool SK_WARN_UNUSED_RESULT tryAllocPixels() 2156</pre> 2157 2158Allocates pixel memory with <a href="#SkBitmap_HeapAllocator">HeapAllocator</a>, and replaces existing <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 2159The allocation size is determined by <a href="SkImageInfo_Reference#Image_Info">Image Info</a> width, height, and <a href="SkImageInfo_Reference#Color_Type">Color Type</a>. 2160 2161Returns false if <a href="#SkBitmap_info">info</a>.<a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>, or allocation fails. 2162 2163### Return Value 2164 2165true if the allocation succeeds 2166 2167### Example 2168 2169<div><fiddle-embed name="720e4c053fae9e929ab6518b47e49370"><div><a href="#Bitmap">Bitmap</a> hosts and draws gray values in set1. <a href="#SkBitmap_tryAllocPixels">tryAllocPixels</a> replaces <a href="undocumented#Pixel_Ref">Pixel Ref</a> 2170and erases it to black, but does not alter set1. <a href="#SkBitmap_setPixels">setPixels</a> replaces black 2171<a href="undocumented#Pixel_Ref">Pixel Ref</a> with set1.</div></fiddle-embed></div> 2172 2173### See Also 2174 2175<a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> <a href="#SkBitmap_installPixels">installPixels</a><sup><a href="#SkBitmap_installPixels_2">[2]</a></sup><sup><a href="#SkBitmap_installPixels_3">[3]</a></sup> <a href="#SkBitmap_setPixels">setPixels</a> 2176 2177--- 2178 2179<a name="SkBitmap_allocPixels_3"></a> 2180 2181<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2182void allocPixels() 2183</pre> 2184 2185Allocates pixel memory with <a href="#SkBitmap_HeapAllocator">HeapAllocator</a>, and replaces existing <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 2186The allocation size is determined by <a href="SkImageInfo_Reference#Image_Info">Image Info</a> width, height, and <a href="SkImageInfo_Reference#Color_Type">Color Type</a>. 2187 2188Aborts if <a href="#SkBitmap_info">info</a>.<a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>, or allocation fails. 2189Abort steps may be provided by the user at compile 2190time by defining SK_ABORT. 2191 2192### Example 2193 2194<div><fiddle-embed name="1219b38c788bf270fb20f8cd2d78cff8"><div><a href="#Bitmap">Bitmap</a> hosts and draws gray values in set1. <a href="#SkBitmap_allocPixels">allocPixels</a> replaces <a href="undocumented#Pixel_Ref">Pixel Ref</a> 2195and erases it to black, but does not alter set1. <a href="#SkBitmap_setPixels">setPixels</a> replaces black 2196<a href="undocumented#Pixel_Ref">Pixel Ref</a> with set2.</div></fiddle-embed></div> 2197 2198### See Also 2199 2200<a href="#SkBitmap_tryAllocPixels">tryAllocPixels</a><sup><a href="#SkBitmap_tryAllocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_tryAllocPixels_4">[4]</a></sup> <a href="#SkBitmap_installPixels">installPixels</a><sup><a href="#SkBitmap_installPixels_2">[2]</a></sup><sup><a href="#SkBitmap_installPixels_3">[3]</a></sup> <a href="#SkBitmap_setPixels">setPixels</a> 2201 2202--- 2203 2204<a name="SkBitmap_tryAllocPixels_4"></a> 2205 2206<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2207bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator* allocator) 2208</pre> 2209 2210Allocates pixel memory with <a href="#SkBitmap_tryAllocPixels_4_allocator">allocator</a>, and replaces existing <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 2211The allocation size is determined by <a href="SkImageInfo_Reference#Image_Info">Image Info</a> width, height, and <a href="SkImageInfo_Reference#Color_Type">Color Type</a>. 2212If <a href="#SkBitmap_tryAllocPixels_4_allocator">allocator</a> is nullptr, use <a href="#SkBitmap_HeapAllocator">HeapAllocator</a> instead. 2213 2214Returns false if <a href="#SkBitmap_tryAllocPixels_4_allocator">allocator</a> <a href="#SkBitmap_HeapAllocator_allocPixelRef">allocPixelRef</a> return false. 2215 2216### Parameters 2217 2218<table> <tr> <td><a name="SkBitmap_tryAllocPixels_4_allocator"> <code><strong>allocator </strong></code> </a></td> <td> 2219instance of <a href="#SkBitmap_Allocator">SkBitmap::Allocator</a> instantiation</td> 2220 </tr> 2221</table> 2222 2223### Return Value 2224 2225true if custom <a href="#SkBitmap_tryAllocPixels_4_allocator">allocator</a> reports success 2226 2227### Example 2228 2229<div><fiddle-embed name="eb6f861ca1839146d26e40d56c2a001c"><div><a href="#SkBitmap_HeapAllocator">HeapAllocator</a> limits the maximum size of <a href="#Bitmap">Bitmap</a> to two gigabytes. Using 2230a custom <a href="#SkBitmap_tryAllocPixels_4_allocator">allocator</a>, this limitation may be relaxed. This example can be 2231modified to allocate an eight gigabyte <a href="#Bitmap">Bitmap</a> on a 64 bit platform with 2232sufficient memory.</div></fiddle-embed></div> 2233 2234### See Also 2235 2236<a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> <a href="#SkBitmap_Allocator">Allocator</a> <a href="undocumented#Pixel_Ref">Pixel Ref</a> 2237 2238--- 2239 2240<a name="SkBitmap_allocPixels_4"></a> 2241 2242<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2243void allocPixels(Allocator* allocator) 2244</pre> 2245 2246Allocates pixel memory with <a href="#SkBitmap_allocPixels_4_allocator">allocator</a>, and replaces existing <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 2247The allocation size is determined by <a href="SkImageInfo_Reference#Image_Info">Image Info</a> width, height, and <a href="SkImageInfo_Reference#Color_Type">Color Type</a>. 2248If <a href="#SkBitmap_allocPixels_4_allocator">allocator</a> is nullptr, use <a href="#SkBitmap_HeapAllocator">HeapAllocator</a> instead. 2249 2250Aborts if <a href="#SkBitmap_allocPixels_4_allocator">allocator</a> <a href="#SkBitmap_HeapAllocator_allocPixelRef">allocPixelRef</a> return false. Abort steps may be provided by 2251the user at compile time by defining SK_ABORT. 2252 2253### Parameters 2254 2255<table> <tr> <td><a name="SkBitmap_allocPixels_4_allocator"> <code><strong>allocator </strong></code> </a></td> <td> 2256instance of <a href="#SkBitmap_Allocator">SkBitmap::Allocator</a> instantiation</td> 2257 </tr> 2258</table> 2259 2260### Example 2261 2262<div><fiddle-embed name="1b2800d23c9ea249b45c2c21a34b6d14"></fiddle-embed></div> 2263 2264### See Also 2265 2266<a href="#SkBitmap_allocPixels">allocPixels</a><sup><a href="#SkBitmap_allocPixels_2">[2]</a></sup><sup><a href="#SkBitmap_allocPixels_3">[3]</a></sup><sup><a href="#SkBitmap_allocPixels_4">[4]</a></sup> <a href="#SkBitmap_Allocator">Allocator</a> <a href="undocumented#Pixel_Ref">Pixel Ref</a> 2267 2268--- 2269 2270<a name="SkBitmap_pixelRef"></a> 2271## pixelRef 2272 2273<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2274SkPixelRef* pixelRef() const 2275</pre> 2276 2277Returns <a href="undocumented#Pixel_Ref">Pixel Ref</a>, which contains: pixel base address; its dimensions; and 2278<a href="#SkBitmap_rowBytes">rowBytes</a>, the interval from one row to the next. Does not change <a href="undocumented#Pixel_Ref">Pixel Ref</a> 2279reference count. <a href="undocumented#Pixel_Ref">Pixel Ref</a> may be shared by multiple bitmaps. 2280If <a href="undocumented#Pixel_Ref">Pixel Ref</a> has not been set, returns nullptr. 2281 2282### Return Value 2283 2284<a href="undocumented#Pixel_Ref">Pixel Ref</a>, or nullptr 2285 2286### Example 2287 2288<div><fiddle-embed name="5db2d30870a7cc45f28e22578d1880c3"></fiddle-embed></div> 2289 2290### See Also 2291 2292<a href="#SkBitmap_getPixels">getPixels</a> <a href="#SkBitmap_getAddr">getAddr</a> 2293 2294--- 2295 2296<a name="SkBitmap_pixelRefOrigin"></a> 2297## pixelRefOrigin 2298 2299<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2300SkIPoint pixelRefOrigin() const 2301</pre> 2302 2303Returns origin of pixels within <a href="undocumented#Pixel_Ref">Pixel Ref</a>. <a href="#Bitmap">Bitmap</a> bounds is always contained 2304by <a href="undocumented#Pixel_Ref">Pixel Ref</a> bounds, which may be the same size or larger. Multiple <a href="#Bitmap">Bitmaps</a> 2305can share the same <a href="undocumented#Pixel_Ref">Pixel Ref</a>, where each <a href="#Bitmap">Bitmap</a> has different bounds. 2306 2307The returned origin added to <a href="#Bitmap">Bitmap</a> dimensions equals or is smaller than the 2308<a href="undocumented#Pixel_Ref">Pixel Ref</a> dimensions. 2309 2310Returns (0, 0) if <a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr. 2311 2312### Return Value 2313 2314pixel origin within <a href="undocumented#Pixel_Ref">Pixel Ref</a> 2315 2316### Example 2317 2318<div><fiddle-embed name="6d31686c6c0829c70f284ae716526d6a"> 2319 2320#### Example Output 2321 2322~~~~ 2323source origin: 0, 0 2324subset origin: 32, 64 2325~~~~ 2326 2327</fiddle-embed></div> 2328 2329### See Also 2330 2331<a href="undocumented#SkPixelRef">SkPixelRef</a> <a href="#SkBitmap_getSubset">getSubset</a> <a href="#SkBitmap_setPixelRef">setPixelRef</a> 2332 2333--- 2334 2335<a name="SkBitmap_setPixelRef"></a> 2336## setPixelRef 2337 2338<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2339void setPixelRef(sk_sp<SkPixelRef> pixelRef, int dx, int dy) 2340</pre> 2341 2342Replaces <a href="#SkBitmap_pixelRef">pixelRef</a> and origin in <a href="#Bitmap">Bitmap</a>. <a href="#SkBitmap_setPixelRef_dx">dx</a> and <a href="#SkBitmap_setPixelRef_dy">dy</a> specify the offset 2343within the <a href="undocumented#Pixel_Ref">Pixel Ref</a> pixels for the top-left corner of the bitmap. 2344 2345Asserts in debug builds if <a href="#SkBitmap_setPixelRef_dx">dx</a> or <a href="#SkBitmap_setPixelRef_dy">dy</a> are out of range. Pins <a href="#SkBitmap_setPixelRef_dx">dx</a> and <a href="#SkBitmap_setPixelRef_dy">dy</a> 2346to legal range in release builds. 2347 2348The caller is responsible for ensuring that the pixels match the 2349<a href="SkImageInfo_Reference#Color_Type">Color Type</a> and <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> in <a href="SkImageInfo_Reference#Image_Info">Image Info</a>. 2350 2351### Parameters 2352 2353<table> <tr> <td><a name="SkBitmap_setPixelRef_pixelRef"> <code><strong>pixelRef </strong></code> </a></td> <td> 2354<a href="undocumented#Pixel_Ref">Pixel Ref</a> describing pixel address and <a href="#SkBitmap_rowBytes">rowBytes</a></td> 2355 </tr> <tr> <td><a name="SkBitmap_setPixelRef_dx"> <code><strong>dx </strong></code> </a></td> <td> 2356column offset in <a href="undocumented#Pixel_Ref">Pixel Ref</a> for bitmap origin</td> 2357 </tr> <tr> <td><a name="SkBitmap_setPixelRef_dy"> <code><strong>dy </strong></code> </a></td> <td> 2358row offset in <a href="undocumented#Pixel_Ref">Pixel Ref</a> for bitmap origin</td> 2359 </tr> 2360</table> 2361 2362### Example 2363 2364<div><fiddle-embed name="13df9e5b1adcec33d11e4b0f8a91ecb8"><div>Treating 32 bit data as 8 bit data is unlikely to produce useful results.</div></fiddle-embed></div> 2365 2366### See Also 2367 2368<a href="#SkBitmap_setInfo">setInfo</a> 2369 2370--- 2371 2372<a name="SkBitmap_readyToDraw"></a> 2373## readyToDraw 2374 2375<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2376bool readyToDraw() const 2377</pre> 2378 2379Returns true if <a href="#Bitmap">Bitmap</a> is can be drawn. 2380 2381### Return Value 2382 2383true if <a href="#SkBitmap_getPixels">getPixels</a> is not nullptr 2384 2385### Example 2386 2387<div><fiddle-embed name="e89c78ca992e2e789ed50944fe68f920"></fiddle-embed></div> 2388 2389### See Also 2390 2391<a href="#SkBitmap_getPixels">getPixels</a> <a href="#SkBitmap_drawsNothing">drawsNothing</a> 2392 2393--- 2394 2395<a name="SkBitmap_getGenerationID"></a> 2396## getGenerationID 2397 2398<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2399uint32_t getGenerationID() const 2400</pre> 2401 2402Returns a unique value corresponding to the pixels in <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 2403Returns a different value after <a href="#SkBitmap_notifyPixelsChanged">notifyPixelsChanged</a> has been called. 2404Returns zero if <a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr. 2405 2406Determines if pixels have changed since last examined. 2407 2408### Return Value 2409 2410unique value for pixels in <a href="undocumented#Pixel_Ref">Pixel Ref</a> 2411 2412### Example 2413 2414<div><fiddle-embed name="db9dd91e0207c3941c09538555817b4b"> 2415 2416#### Example Output 2417 2418~~~~ 2419#Volatile 2420empty id 0 2421alloc id 4 2422erase id 6 2423~~~~ 2424 2425</fiddle-embed></div> 2426 2427### See Also 2428 2429<a href="#SkBitmap_notifyPixelsChanged">notifyPixelsChanged</a> <a href="undocumented#Pixel_Ref">Pixel Ref</a> 2430 2431--- 2432 2433<a name="SkBitmap_notifyPixelsChanged"></a> 2434## notifyPixelsChanged 2435 2436<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2437void notifyPixelsChanged() const 2438</pre> 2439 2440Marks that pixels in <a href="undocumented#Pixel_Ref">Pixel Ref</a> have changed. Subsequent calls to 2441<a href="#SkBitmap_getGenerationID">getGenerationID</a> return a different value. 2442 2443### Example 2444 2445<div><fiddle-embed name="706e6409c8364e7786d6c69db7242c76"></fiddle-embed></div> 2446 2447### See Also 2448 2449<a href="#SkBitmap_getGenerationID">getGenerationID</a> <a href="#SkBitmap_isVolatile">isVolatile</a> <a href="undocumented#Pixel_Ref">Pixel Ref</a> 2450 2451--- 2452 2453<a name="SkBitmap_eraseColor"></a> 2454## eraseColor 2455 2456<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2457void eraseColor(SkColor c) const 2458</pre> 2459 2460Replaces pixel values with <a href="#SkBitmap_eraseColor_c">c</a>. All pixels contained by <a href="#SkBitmap_bounds">bounds</a> are affected. 2461If the <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a> or k565_SkColorType, then <a href="#Alpha">Color Alpha</a> 2462is ignored; <a href="#RGB">Color RGB</a> is treated as opaque. If <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>, 2463then <a href="#RGB">Color RGB</a> is ignored. 2464 2465### Parameters 2466 2467<table> <tr> <td><a name="SkBitmap_eraseColor_c"> <code><strong>c </strong></code> </a></td> <td> 2468<a href="#Unpremultiply">Unpremultiplied</a> <a href="undocumented#Color">Color</a></td> 2469 </tr> 2470</table> 2471 2472### Example 2473 2474<div><fiddle-embed name="22804faa423192f96a29578b1d396ace"></fiddle-embed></div> 2475 2476### See Also 2477 2478<a href="#SkBitmap_eraseARGB">eraseARGB</a> <a href="#SkBitmap_erase">erase</a> 2479 2480--- 2481 2482<a name="SkBitmap_eraseARGB"></a> 2483## eraseARGB 2484 2485<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2486void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const 2487</pre> 2488 2489Replaces pixel values with <a href="#Unpremultiply">Unpremultiplied</a> <a href="undocumented#Color">Color</a> built from <a href="#SkBitmap_eraseARGB_a">a</a>, <a href="#SkBitmap_eraseARGB_r">r</a>, <a href="#SkBitmap_eraseARGB_g">g</a>, and <a href="#SkBitmap_eraseARGB_b">b</a>. 2490All pixels contained by <a href="#SkBitmap_bounds">bounds</a> are affected. 2491If the <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a> or k565_SkColorType, then <a href="#SkBitmap_eraseARGB_a">a</a> 2492is ignored; <a href="#SkBitmap_eraseARGB_r">r</a>, <a href="#SkBitmap_eraseARGB_g">g</a>, and <a href="#SkBitmap_eraseARGB_b">b</a> are treated as opaque. If <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>, 2493then <a href="#SkBitmap_eraseARGB_r">r</a>, <a href="#SkBitmap_eraseARGB_g">g</a>, and <a href="#SkBitmap_eraseARGB_b">b</a> are ignored. 2494 2495### Parameters 2496 2497<table> <tr> <td><a name="SkBitmap_eraseARGB_a"> <code><strong>a </strong></code> </a></td> <td> 2498amount of <a href="#Alpha">Color Alpha</a>, from fully transparent (0) to fully opaque (255)</td> 2499 </tr> <tr> <td><a name="SkBitmap_eraseARGB_r"> <code><strong>r </strong></code> </a></td> <td> 2500amount of <a href="#RGB_Red">Color RGB Red</a>, from no red (0) to full red (255)</td> 2501 </tr> <tr> <td><a name="SkBitmap_eraseARGB_g"> <code><strong>g </strong></code> </a></td> <td> 2502amount of <a href="#RGB_Green">Color RGB Green</a>, from no green (0) to full green (255)</td> 2503 </tr> <tr> <td><a name="SkBitmap_eraseARGB_b"> <code><strong>b </strong></code> </a></td> <td> 2504amount of <a href="#RGB_Blue">Color RGB Blue</a>, from no blue (0) to full blue (255)</td> 2505 </tr> 2506</table> 2507 2508### Example 2509 2510<div><fiddle-embed name="ebaa436565ce9c0f883bef871d099654"></fiddle-embed></div> 2511 2512### See Also 2513 2514<a href="#SkBitmap_eraseColor">eraseColor</a> <a href="#SkBitmap_erase">erase</a> 2515 2516--- 2517 2518<a name="SkBitmap_eraseRGB"></a> 2519## eraseRGB 2520 2521<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2522void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const 2523</pre> 2524 2525Deprecated. Use <a href="#SkBitmap_eraseARGB">eraseARGB</a> or <a href="#SkBitmap_eraseColor">eraseColor</a>. 2526 2527### Parameters 2528 2529<table> <tr> <td><a name="SkBitmap_eraseRGB_r"> <code><strong>r </strong></code> </a></td> <td> 2530amount of red</td> 2531 </tr> <tr> <td><a name="SkBitmap_eraseRGB_g"> <code><strong>g </strong></code> </a></td> <td> 2532amount of green</td> 2533 </tr> <tr> <td><a name="SkBitmap_eraseRGB_b"> <code><strong>b </strong></code> </a></td> <td> 2534amount of blue</td> 2535 </tr> 2536</table> 2537 2538### See Also 2539 2540<a href="#SkBitmap_eraseColor">eraseColor</a> <a href="#SkBitmap_eraseARGB">eraseARGB</a> <a href="#SkBitmap_erase">erase</a> 2541 2542--- 2543 2544<a name="SkBitmap_erase"></a> 2545## erase 2546 2547<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2548void erase(SkColor c, const SkIRect& area) const 2549</pre> 2550 2551Replaces pixel values inside <a href="#SkBitmap_erase_area">area</a> with <a href="#SkBitmap_erase_c">c</a>. If <a href="#SkBitmap_erase_area">area</a> does not intersect <a href="#SkBitmap_bounds">bounds</a>, 2552call has no effect. 2553 2554If the <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a> or k565_SkColorType, then <a href="#Alpha">Color Alpha</a> 2555is ignored; <a href="#RGB">Color RGB</a> is treated as opaque. If <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>, 2556then <a href="#RGB">Color RGB</a> is ignored. 2557 2558### Parameters 2559 2560<table> <tr> <td><a name="SkBitmap_erase_c"> <code><strong>c </strong></code> </a></td> <td> 2561<a href="#Unpremultiply">Unpremultiplied</a> <a href="undocumented#Color">Color</a></td> 2562 </tr> <tr> <td><a name="SkBitmap_erase_area"> <code><strong>area </strong></code> </a></td> <td> 2563rectangle to fill</td> 2564 </tr> 2565</table> 2566 2567### Example 2568 2569<div><fiddle-embed name="116baaa35348b5c0a353fb6d4917d574"></fiddle-embed></div> 2570 2571### See Also 2572 2573<a href="#SkBitmap_eraseColor">eraseColor</a> <a href="#SkBitmap_eraseARGB">eraseARGB</a> <a href="#SkBitmap_eraseRGB">eraseRGB</a> <a href="#SkCanvas_drawRect">SkCanvas::drawRect</a> 2574 2575--- 2576 2577<a name="SkBitmap_eraseArea"></a> 2578## eraseArea 2579 2580<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2581void eraseArea(const SkIRect& area, SkColor c) const 2582</pre> 2583 2584Legacy call to be deprecated. 2585 2586--- 2587 2588<a name="SkBitmap_getColor"></a> 2589## getColor 2590 2591<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2592SkColor getColor(int x, int y) const 2593</pre> 2594 2595Returns pixel at (<a href="#SkBitmap_getColor_x">x</a>, <a href="#SkBitmap_getColor_y">y</a>) as <a href="#Unpremultiply">Unpremultiplied</a> <a href="undocumented#Color">Color</a>. 2596Returns black with <a href="#Alpha">Alpha</a> if <a href="SkImageInfo_Reference#Color_Type">Color Type</a> is <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>. 2597 2598Input is not validated: out of bounds values of <a href="#SkBitmap_getColor_x">x</a> or <a href="#SkBitmap_getColor_y">y</a> trigger an assert() if 2599built with SK_DEBUG defined; and returns undefined values or may crash if 2600SK_RELEASE is defined. Fails if <a href="SkImageInfo_Reference#Color_Type">Color Type</a> is <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a> or 2601pixel address is nullptr. 2602 2603<a href="undocumented#Color_Space">Color Space</a> in <a href="SkImageInfo_Reference#Image_Info">Image Info</a> is ignored. Some <a href="undocumented#Color">Color</a> precision may be lost in the 2604conversion to <a href="#Unpremultiply">Unpremultiplied</a> <a href="undocumented#Color">Color</a>; original pixel data may have additional 2605precision. 2606 2607### Parameters 2608 2609<table> <tr> <td><a name="SkBitmap_getColor_x"> <code><strong>x </strong></code> </a></td> <td> 2610column index, zero or greater, and less than <a href="#SkBitmap_width">width</a></td> 2611 </tr> <tr> <td><a name="SkBitmap_getColor_y"> <code><strong>y </strong></code> </a></td> <td> 2612row index, zero or greater, and less than <a href="#SkBitmap_height">height</a></td> 2613 </tr> 2614</table> 2615 2616### Return Value 2617 2618pixel converted to <a href="#Unpremultiply">Unpremultiplied</a> <a href="undocumented#Color">Color</a> 2619 2620### Example 2621 2622<div><fiddle-embed name="2e49fa71dd4be95470248ea6eb35468b"> 2623 2624#### Example Output 2625 2626~~~~ 2627Premultiplied: 2628(0, 0) 0x00000000 0x2a0e002a 0x55380055 0x7f7f007f 2629(0, 1) 0x2a000e2a 0x551c1c55 0x7f542a7f 0xaaaa38aa 2630(0, 2) 0x55003855 0x7f2a547f 0xaa7171aa 0xd4d48dd4 2631(0, 3) 0x7f007f7f 0xaa38aaaa 0xd48dd4d4 0xffffffff 2632Unpremultiplied: 2633(0, 0) 0x00000000 0x2a5500ff 0x55a800ff 0x7fff00ff 2634(0, 1) 0x2a0055ff 0x555454ff 0x7fa954ff 0xaaff54ff 2635(0, 2) 0x5500a8ff 0x7f54a9ff 0xaaaaaaff 0xd4ffaaff 2636(0, 3) 0x7f00ffff 0xaa54ffff 0xd4aaffff 0xffffffff 2637~~~~ 2638 2639</fiddle-embed></div> 2640 2641### See Also 2642 2643<a href="#SkBitmap_getAddr">getAddr</a> <a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> 2644 2645--- 2646 2647<a name="SkBitmap_getAddr"></a> 2648## getAddr 2649 2650<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2651void* getAddr(int x, int y) const 2652</pre> 2653 2654Returns pixel address at (<a href="#SkBitmap_getAddr_x">x</a>, <a href="#SkBitmap_getAddr_y">y</a>). 2655 2656Input is not validated: out of bounds values of <a href="#SkBitmap_getAddr_x">x</a> or <a href="#SkBitmap_getAddr_y">y</a>, or <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>, 2657trigger an assert() if built with SK_DEBUG defined. Returns nullptr if 2658<a href="SkImageInfo_Reference#Color_Type">Color Type</a> is <a href="SkImageInfo_Reference#SkColorType">kUnknown SkColorType</a>, or <a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr. 2659 2660Performs a lookup of pixel size; for better performance, call 2661one of: <a href="#SkBitmap_getAddr8">getAddr8</a>, <a href="#SkBitmap_getAddr16">getAddr16</a>, or <a href="#SkBitmap_getAddr32">getAddr32</a>. 2662 2663### Parameters 2664 2665<table> <tr> <td><a name="SkBitmap_getAddr_x"> <code><strong>x </strong></code> </a></td> <td> 2666column index, zero or greater, and less than <a href="#SkBitmap_width">width</a></td> 2667 </tr> <tr> <td><a name="SkBitmap_getAddr_y"> <code><strong>y </strong></code> </a></td> <td> 2668row index, zero or greater, and less than <a href="#SkBitmap_height">height</a></td> 2669 </tr> 2670</table> 2671 2672### Return Value 2673 2674generic pointer to pixel 2675 2676### Example 2677 2678<div><fiddle-embed name="bd0e0adb48b16d75129092649eab1617"> 2679 2680#### Example Output 2681 2682~~~~ 2683addr interval == rowBytes 2684~~~~ 2685 2686</fiddle-embed></div> 2687 2688### See Also 2689 2690<a href="#SkBitmap_getAddr8">getAddr8</a> <a href="#SkBitmap_getAddr16">getAddr16</a> <a href="#SkBitmap_getAddr32">getAddr32</a> <a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> <a href="#SkPixmap_addr">SkPixmap::addr</a><sup><a href="#SkPixmap_addr_2">[2]</a></sup> 2691 2692--- 2693 2694<a name="SkBitmap_getAddr32"></a> 2695## getAddr32 2696 2697<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2698inline uint32_t* getAddr32(int x, int y) const 2699</pre> 2700 2701Returns address at (<a href="#SkBitmap_getAddr32_x">x</a>, <a href="#SkBitmap_getAddr32_y">y</a>). 2702 2703Input is not validated. Triggers an assert() if built with SK_DEBUG defined and: 2704 2705<table> <tr> 2706 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> <tr> 2707 <td><a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a> is not four</td> </tr> <tr> 2708 <td><a href="#SkBitmap_getAddr32_x">x</a> is negative, or not less than <a href="#SkBitmap_width">width</a></td> </tr> <tr> 2709 <td><a href="#SkBitmap_getAddr32_y">y</a> is negative, or not less than <a href="#SkBitmap_height">height</a></td> </tr> 2710</table> 2711 2712### Parameters 2713 2714<table> <tr> <td><a name="SkBitmap_getAddr32_x"> <code><strong>x </strong></code> </a></td> <td> 2715column index, zero or greater, and less than <a href="#SkBitmap_width">width</a></td> 2716 </tr> <tr> <td><a name="SkBitmap_getAddr32_y"> <code><strong>y </strong></code> </a></td> <td> 2717row index, zero or greater, and less than <a href="#SkBitmap_height">height</a></td> 2718 </tr> 2719</table> 2720 2721### Return Value 2722 2723unsigned 32-bit pointer to pixel at (<a href="#SkBitmap_getAddr32_x">x</a>, <a href="#SkBitmap_getAddr32_y">y</a>) 2724 2725### Example 2726 2727<div><fiddle-embed name="837a2bcc9fb9ce617a3420956cefc64a"> 2728 2729#### Example Output 2730 2731~~~~ 2732addr interval == rowBytes 2733~~~~ 2734 2735</fiddle-embed></div> 2736 2737### See Also 2738 2739<a href="#SkBitmap_getAddr8">getAddr8</a> <a href="#SkBitmap_getAddr16">getAddr16</a> <a href="#SkBitmap_getAddr">getAddr</a> <a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> <a href="#SkPixmap_addr32">SkPixmap::addr32</a><sup><a href="#SkPixmap_addr32_2">[2]</a></sup> 2740 2741--- 2742 2743<a name="SkBitmap_getAddr16"></a> 2744## getAddr16 2745 2746<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2747inline uint16_t* getAddr16(int x, int y) const 2748</pre> 2749 2750Returns address at (<a href="#SkBitmap_getAddr16_x">x</a>, <a href="#SkBitmap_getAddr16_y">y</a>). 2751 2752Input is not validated. Triggers an assert() if built with SK_DEBUG defined and: 2753 2754<table> <tr> 2755 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> <tr> 2756 <td><a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a> is not two</td> </tr> <tr> 2757 <td><a href="#SkBitmap_getAddr16_x">x</a> is negative, or not less than <a href="#SkBitmap_width">width</a></td> </tr> <tr> 2758 <td><a href="#SkBitmap_getAddr16_y">y</a> is negative, or not less than <a href="#SkBitmap_height">height</a></td> </tr> 2759</table> 2760 2761### Parameters 2762 2763<table> <tr> <td><a name="SkBitmap_getAddr16_x"> <code><strong>x </strong></code> </a></td> <td> 2764column index, zero or greater, and less than <a href="#SkBitmap_width">width</a></td> 2765 </tr> <tr> <td><a name="SkBitmap_getAddr16_y"> <code><strong>y </strong></code> </a></td> <td> 2766row index, zero or greater, and less than <a href="#SkBitmap_height">height</a></td> 2767 </tr> 2768</table> 2769 2770### Return Value 2771 2772unsigned 16-bit pointer to pixel at (<a href="#SkBitmap_getAddr16_x">x</a>, <a href="#SkBitmap_getAddr16_y">y</a>) 2773 2774### Example 2775 2776<div><fiddle-embed name="3d7e49d428c9a4812558b39cf505baa6"> 2777 2778#### Example Output 2779 2780~~~~ 2781addr interval == rowBytes 2782~~~~ 2783 2784</fiddle-embed></div> 2785 2786### See Also 2787 2788<a href="#SkBitmap_getAddr8">getAddr8</a> <a href="#SkBitmap_getAddr">getAddr</a> <a href="#SkBitmap_getAddr32">getAddr32</a> <a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> <a href="#SkPixmap_addr16">SkPixmap::addr16</a><sup><a href="#SkPixmap_addr16_2">[2]</a></sup> 2789 2790--- 2791 2792<a name="SkBitmap_getAddr8"></a> 2793## getAddr8 2794 2795<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2796inline uint8_t* getAddr8(int x, int y) const 2797</pre> 2798 2799Returns address at (<a href="#SkBitmap_getAddr8_x">x</a>, <a href="#SkBitmap_getAddr8_y">y</a>). 2800 2801Input is not validated. Triggers an assert() if built with SK_DEBUG defined and: 2802 2803<table> <tr> 2804 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> <tr> 2805 <td><a href="#SkBitmap_bytesPerPixel">bytesPerPixel</a> is not one</td> </tr> <tr> 2806 <td><a href="#SkBitmap_getAddr8_x">x</a> is negative, or not less than <a href="#SkBitmap_width">width</a></td> </tr> <tr> 2807 <td><a href="#SkBitmap_getAddr8_y">y</a> is negative, or not less than <a href="#SkBitmap_height">height</a></td> </tr> 2808</table> 2809 2810### Parameters 2811 2812<table> <tr> <td><a name="SkBitmap_getAddr8_x"> <code><strong>x </strong></code> </a></td> <td> 2813column index, zero or greater, and less than <a href="#SkBitmap_width">width</a></td> 2814 </tr> <tr> <td><a name="SkBitmap_getAddr8_y"> <code><strong>y </strong></code> </a></td> <td> 2815row index, zero or greater, and less than <a href="#SkBitmap_height">height</a></td> 2816 </tr> 2817</table> 2818 2819### Return Value 2820 2821unsigned 8-bit pointer to pixel at (<a href="#SkBitmap_getAddr8_x">x</a>, <a href="#SkBitmap_getAddr8_y">y</a>) 2822 2823### Example 2824 2825<div><fiddle-embed name="cb9a08e8ff779b6a1cf8bb54f3883aaf"> 2826 2827#### Example Output 2828 2829~~~~ 2830&pixels[4][2] == bitmap.getAddr8(2, 4) 2831~~~~ 2832 2833</fiddle-embed></div> 2834 2835### See Also 2836 2837<a href="#SkBitmap_getAddr">getAddr</a> <a href="#SkBitmap_getAddr16">getAddr16</a> <a href="#SkBitmap_getAddr32">getAddr32</a> <a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> <a href="#SkPixmap_addr8">SkPixmap::addr8</a><sup><a href="#SkPixmap_addr8_2">[2]</a></sup> 2838 2839--- 2840 2841<a name="SkBitmap_extractSubset"></a> 2842## extractSubset 2843 2844<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2845bool extractSubset(SkBitmap* dst, const SkIRect& subset) const 2846</pre> 2847 2848Shares <a href="undocumented#Pixel_Ref">Pixel Ref</a> with <a href="#SkBitmap_extractSubset_dst">dst</a>. Pixels are not copied; <a href="#Bitmap">Bitmap</a> and <a href="#SkBitmap_extractSubset_dst">dst</a> point 2849to the same pixels; <a href="#SkBitmap_extractSubset_dst">dst</a> <a href="#SkBitmap_bounds">bounds</a> are set to the intersection of <a href="#SkBitmap_extractSubset_subset">subset</a> 2850and the original <a href="#SkBitmap_bounds">bounds</a>. 2851 2852<a href="#SkBitmap_extractSubset_subset">subset</a> may be larger than <a href="#SkBitmap_bounds">bounds</a>. Any area outside of <a href="#SkBitmap_bounds">bounds</a> is ignored. 2853 2854Any contents of <a href="#SkBitmap_extractSubset_dst">dst</a> are discarded. <a href="#SkBitmap_isVolatile">isVolatile</a> setting is copied to <a href="#SkBitmap_extractSubset_dst">dst</a>. 2855<a href="#SkBitmap_extractSubset_dst">dst</a> is set to <a href="#SkBitmap_colorType">colorType</a>, <a href="#SkBitmap_alphaType">alphaType</a>, and <a href="#SkBitmap_colorSpace">colorSpace</a>. 2856 2857Return false if: 2858 2859<table> <tr> 2860 <td><a href="#SkBitmap_extractSubset_dst">dst</a> is nullptr</td> </tr> <tr> 2861 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> <tr> 2862 <td><a href="#SkBitmap_extractSubset_subset">subset</a> does not intersect <a href="#SkBitmap_bounds">bounds</a></td> </tr> 2863</table> 2864 2865### Parameters 2866 2867<table> <tr> <td><a name="SkBitmap_extractSubset_dst"> <code><strong>dst </strong></code> </a></td> <td> 2868<a href="#Bitmap">Bitmap</a> set to <a href="#SkBitmap_extractSubset_subset">subset</a></td> 2869 </tr> <tr> <td><a name="SkBitmap_extractSubset_subset"> <code><strong>subset </strong></code> </a></td> <td> 2870rectangle of pixels to reference</td> 2871 </tr> 2872</table> 2873 2874### Return Value 2875 2876true if <a href="#SkBitmap_extractSubset_dst">dst</a> is replaced by <a href="#SkBitmap_extractSubset_subset">subset</a> 2877 2878### Example 2879 2880<div><fiddle-embed name="3ad80d8fcb13344612f361812658b696"> 2881 2882#### Example Output 2883 2884~~~~ 2885bounds: 0, 0, 512, 512 2886subset: -100, 100, 0, 200 success; false 2887subset: -100, 100, 100, 200 success; true subset: 0, 0, 100, 100 2888subset: -100, 100, 1000, 200 success; true subset: 0, 0, 512, 100 2889subset: 0, 100, 0, 200 success; false 2890subset: 0, 100, 100, 200 success; true subset: 0, 0, 100, 100 2891subset: 0, 100, 1000, 200 success; true subset: 0, 0, 512, 100 2892subset: 100, 100, 0, 200 success; false 2893subset: 100, 100, 100, 200 success; false 2894subset: 100, 100, 1000, 200 success; true subset: 0, 0, 412, 100 2895subset: 1000, 100, 0, 200 success; false 2896subset: 1000, 100, 100, 200 success; false 2897subset: 1000, 100, 1000, 200 success; false 2898~~~~ 2899 2900</fiddle-embed></div> 2901 2902### See Also 2903 2904<a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> <a href="#SkBitmap_writePixels">writePixels</a><sup><a href="#SkBitmap_writePixels_2">[2]</a></sup><sup><a href="#SkBitmap_writePixels_3">[3]</a></sup> <a href="#SkCanvas_drawBitmap">SkCanvas::drawBitmap</a> 2905 2906--- 2907 2908<a name="SkBitmap_readPixels"></a> 2909## readPixels 2910 2911<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2912bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY, 2913 SkTransferFunctionBehavior behavior) const 2914</pre> 2915 2916Copies <a href="SkRect_Reference#Rect">Rect</a> of pixels from <a href="#Bitmap">Bitmap</a> pixels to <a href="#SkBitmap_readPixels_dstPixels">dstPixels</a>. Copy starts at (<a href="#SkBitmap_readPixels_srcX">srcX</a>, <a href="#SkBitmap_readPixels_srcY">srcY</a>), 2917and does not exceed <a href="#Bitmap">Bitmap</a> (<a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_height">height</a>). 2918 2919<a href="#SkBitmap_readPixels_dstInfo">dstInfo</a> specifies width, height, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, and 2920<a href="undocumented#Color_Space">Color Space</a> of destination. <a href="#SkBitmap_readPixels_dstRowBytes">dstRowBytes</a> specifics the gap from one destination 2921row to the next. Returns true if pixels are copied. Returns false if: 2922 2923<table> <tr> 2924 <td><a href="#SkBitmap_readPixels_dstInfo">dstInfo</a>.addr() equals nullptr</td> </tr> <tr> 2925 <td><a href="#SkBitmap_readPixels_dstRowBytes">dstRowBytes</a> is less than <a href="#SkBitmap_readPixels_dstInfo">dstInfo</a>.<a href="SkImageInfo_Reference#SkImageInfo">minRowBytes</a></td> </tr> <tr> 2926 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> 2927</table> 2928 2929Pixels are copied only if pixel conversion is possible. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is 2930<a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, or <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>; <a href="#SkBitmap_readPixels_dstInfo">dstInfo</a>.<a href="#SkBitmap_colorType">colorType</a> must match. 2931If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, <a href="#SkBitmap_readPixels_dstInfo">dstInfo</a>.<a href="#SkBitmap_colorSpace">colorSpace</a> must match. 2932If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_alphaType">alphaType</a> is <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>, <a href="#SkBitmap_readPixels_dstInfo">dstInfo</a>.<a href="#SkBitmap_alphaType">alphaType</a> must 2933match. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorSpace">colorSpace</a> is nullptr, <a href="#SkBitmap_readPixels_dstInfo">dstInfo</a>.<a href="#SkBitmap_colorSpace">colorSpace</a> must match. Returns 2934false if pixel conversion is not possible. 2935<a href="#SkBitmap_readPixels_srcX">srcX</a> and <a href="#SkBitmap_readPixels_srcY">srcY</a> may be negative to copy only top or left of source. Returns 2936false if <a href="#SkBitmap_width">width</a> or <a href="#SkBitmap_height">height</a> is zero or negative. 2937Returns false ifabs(srcX) >= <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_width">width</a>, 2938or ifabs(srcY) >= <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_height">height</a>. 2939 2940If <a href="#SkBitmap_readPixels_behavior">behavior</a> is <a href="#SkTransferFunctionBehavior_kRespect">SkTransferFunctionBehavior::kRespect</a>: converts source 2941pixels to a linear space before converting to <a href="#SkBitmap_readPixels_dstInfo">dstInfo</a>. 2942If <a href="#SkBitmap_readPixels_behavior">behavior</a> is <a href="#SkTransferFunctionBehavior_kIgnore">SkTransferFunctionBehavior::kIgnore</a>: source 2943pixels are treated as if they are linear, regardless of how they are encoded. 2944 2945### Parameters 2946 2947<table> <tr> <td><a name="SkBitmap_readPixels_dstInfo"> <code><strong>dstInfo </strong></code> </a></td> <td> 2948destination width, height, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 2949 </tr> <tr> <td><a name="SkBitmap_readPixels_dstPixels"> <code><strong>dstPixels </strong></code> </a></td> <td> 2950destination pixel storage</td> 2951 </tr> <tr> <td><a name="SkBitmap_readPixels_dstRowBytes"> <code><strong>dstRowBytes </strong></code> </a></td> <td> 2952destination row length</td> 2953 </tr> <tr> <td><a name="SkBitmap_readPixels_srcX"> <code><strong>srcX </strong></code> </a></td> <td> 2954column index whose absolute value is less than <a href="#SkBitmap_width">width</a></td> 2955 </tr> <tr> <td><a name="SkBitmap_readPixels_srcY"> <code><strong>srcY </strong></code> </a></td> <td> 2956row index whose absolute value is less than <a href="#SkBitmap_height">height</a></td> 2957 </tr> <tr> <td><a name="SkBitmap_readPixels_behavior"> <code><strong>behavior </strong></code> </a></td> <td> 2958one of: <a href="#SkTransferFunctionBehavior_kRespect">SkTransferFunctionBehavior::kRespect</a>, 2959<a href="#SkTransferFunctionBehavior_kIgnore">SkTransferFunctionBehavior::kIgnore</a></td> 2960 </tr> 2961</table> 2962 2963### Return Value 2964 2965true if pixels are copied to <a href="#SkBitmap_readPixels_dstPixels">dstPixels</a> 2966 2967### Example 2968 2969<div><fiddle-embed name="86fb9979516d256d71aa3f3f2182fe0c"></fiddle-embed></div> 2970 2971### See Also 2972 2973<a href="#SkBitmap_writePixels">writePixels</a><sup><a href="#SkBitmap_writePixels_2">[2]</a></sup><sup><a href="#SkBitmap_writePixels_3">[3]</a></sup> <a href="#SkPixmap_readPixels">SkPixmap::readPixels</a><sup><a href="#SkPixmap_readPixels_2">[2]</a></sup><sup><a href="#SkPixmap_readPixels_3">[3]</a></sup><sup><a href="#SkPixmap_readPixels_4">[4]</a></sup><sup><a href="#SkPixmap_readPixels_5">[5]</a></sup> <a href="#SkCanvas_readPixels">SkCanvas::readPixels</a><sup><a href="#SkCanvas_readPixels_2">[2]</a></sup><sup><a href="#SkCanvas_readPixels_3">[3]</a></sup> <a href="#SkImage_readPixels">SkImage::readPixels</a><sup><a href="#SkImage_readPixels_2">[2]</a></sup> <a href="#SkSurface_readPixels">SkSurface::readPixels</a><sup><a href="#SkSurface_readPixels_2">[2]</a></sup><sup><a href="#SkSurface_readPixels_3">[3]</a></sup> 2974 2975--- 2976 2977<a name="SkBitmap_readPixels_2"></a> 2978 2979<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2980bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY) const 2981</pre> 2982 2983Copies a <a href="SkRect_Reference#Rect">Rect</a> of pixels from <a href="#Bitmap">Bitmap</a> to <a href="#SkBitmap_readPixels_2_dstPixels">dstPixels</a>. Copy starts at (<a href="#SkBitmap_readPixels_2_srcX">srcX</a>, <a href="#SkBitmap_readPixels_2_srcY">srcY</a>), 2984and does not exceed <a href="#Bitmap">Bitmap</a> (<a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_height">height</a>). 2985 2986<a href="#SkBitmap_readPixels_2_dstInfo">dstInfo</a> specifies width, height, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, and <a href="undocumented#Color_Space">Color Space</a> of 2987destination. <a href="#SkBitmap_readPixels_2_dstRowBytes">dstRowBytes</a> specifics the gap from one destination row to the next. 2988Returns true if pixels are copied. Returns false if: 2989 2990<table> <tr> 2991 <td><a href="#SkBitmap_readPixels_2_dstInfo">dstInfo</a>.addr() equals nullptr</td> </tr> <tr> 2992 <td><a href="#SkBitmap_readPixels_2_dstRowBytes">dstRowBytes</a> is less than <a href="#SkBitmap_readPixels_2_dstInfo">dstInfo</a>.<a href="SkImageInfo_Reference#SkImageInfo">minRowBytes</a></td> </tr> <tr> 2993 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> 2994</table> 2995 2996Pixels are copied only if pixel conversion is possible. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is 2997<a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, or <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>; <a href="#SkBitmap_readPixels_2_dstInfo">dstInfo</a>.<a href="#SkBitmap_colorType">colorType</a> must match. 2998If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, <a href="#SkBitmap_readPixels_2_dstInfo">dstInfo</a>.<a href="#SkBitmap_colorSpace">colorSpace</a> must match. 2999If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_alphaType">alphaType</a> is <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>, <a href="#SkBitmap_readPixels_2_dstInfo">dstInfo</a>.<a href="#SkBitmap_alphaType">alphaType</a> must 3000match. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorSpace">colorSpace</a> is nullptr, <a href="#SkBitmap_readPixels_2_dstInfo">dstInfo</a>.<a href="#SkBitmap_colorSpace">colorSpace</a> must match. Returns 3001false if pixel conversion is not possible. 3002<a href="#SkBitmap_readPixels_2_srcX">srcX</a> and <a href="#SkBitmap_readPixels_2_srcY">srcY</a> may be negative to copy only top or left of source. Returns 3003false if <a href="#SkBitmap_width">width</a> or <a href="#SkBitmap_height">height</a> is zero or negative. 3004Returns false ifabs(srcX) >= <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_width">width</a>, 3005or ifabs(srcY) >= <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_height">height</a>. 3006 3007### Parameters 3008 3009<table> <tr> <td><a name="SkBitmap_readPixels_2_dstInfo"> <code><strong>dstInfo </strong></code> </a></td> <td> 3010destination width, height, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="undocumented#Color_Space">Color Space</a></td> 3011 </tr> <tr> <td><a name="SkBitmap_readPixels_2_dstPixels"> <code><strong>dstPixels </strong></code> </a></td> <td> 3012destination pixel storage</td> 3013 </tr> <tr> <td><a name="SkBitmap_readPixels_2_dstRowBytes"> <code><strong>dstRowBytes </strong></code> </a></td> <td> 3014destination row length</td> 3015 </tr> <tr> <td><a name="SkBitmap_readPixels_2_srcX"> <code><strong>srcX </strong></code> </a></td> <td> 3016column index whose absolute value is less than <a href="#SkBitmap_width">width</a></td> 3017 </tr> <tr> <td><a name="SkBitmap_readPixels_2_srcY"> <code><strong>srcY </strong></code> </a></td> <td> 3018row index whose absolute value is less than <a href="#SkBitmap_height">height</a></td> 3019 </tr> 3020</table> 3021 3022### Return Value 3023 3024true if pixels are copied to <a href="#SkBitmap_readPixels_2_dstPixels">dstPixels</a> 3025 3026### Example 3027 3028<div><fiddle-embed name="b2cbbbbcffb618865d8aae3bc04b2a62"><div>Transferring the gradient from 8 bits per component to 4 bits per component 3029creates visible banding.</div></fiddle-embed></div> 3030 3031### See Also 3032 3033<a href="#SkBitmap_writePixels">writePixels</a><sup><a href="#SkBitmap_writePixels_2">[2]</a></sup><sup><a href="#SkBitmap_writePixels_3">[3]</a></sup> <a href="#SkPixmap_readPixels">SkPixmap::readPixels</a><sup><a href="#SkPixmap_readPixels_2">[2]</a></sup><sup><a href="#SkPixmap_readPixels_3">[3]</a></sup><sup><a href="#SkPixmap_readPixels_4">[4]</a></sup><sup><a href="#SkPixmap_readPixels_5">[5]</a></sup> <a href="#SkCanvas_readPixels">SkCanvas::readPixels</a><sup><a href="#SkCanvas_readPixels_2">[2]</a></sup><sup><a href="#SkCanvas_readPixels_3">[3]</a></sup> <a href="#SkImage_readPixels">SkImage::readPixels</a><sup><a href="#SkImage_readPixels_2">[2]</a></sup> <a href="#SkSurface_readPixels">SkSurface::readPixels</a><sup><a href="#SkSurface_readPixels_2">[2]</a></sup><sup><a href="#SkSurface_readPixels_3">[3]</a></sup> 3034 3035--- 3036 3037<a name="SkBitmap_readPixels_3"></a> 3038 3039<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3040bool readPixels(const SkPixmap& dst, int srcX, int srcY) const 3041</pre> 3042 3043Copies a <a href="SkRect_Reference#Rect">Rect</a> of pixels from <a href="#Bitmap">Bitmap</a> to <a href="#SkBitmap_readPixels_3_dst">dst</a>. Copy starts at (<a href="#SkBitmap_readPixels_3_srcX">srcX</a>, <a href="#SkBitmap_readPixels_3_srcY">srcY</a>), and 3044does not exceed <a href="#Bitmap">Bitmap</a> (<a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_height">height</a>). 3045 3046<a href="#SkBitmap_readPixels_3_dst">dst</a> specifies width, height, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="undocumented#Color_Space">Color Space</a>, pixel storage, 3047and row bytes of destination. <a href="#SkBitmap_readPixels_3_dst">dst</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> specifics the gap from one destination 3048row to the next. Returns true if pixels are copied. Returns false if: 3049 3050<table> <tr> 3051 <td><a href="#SkBitmap_readPixels_3_dst">dst</a> pixel storage equals nullptr</td> </tr> <tr> 3052 <td><a href="#SkBitmap_readPixels_3_dst">dst</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> is less than <a href="#SkImageInfo_minRowBytes">SkImageInfo::minRowBytes</a></td> </tr> <tr> 3053 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> 3054</table> 3055 3056Pixels are copied only if pixel conversion is possible. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is 3057<a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, or <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>; <a href="#SkBitmap_readPixels_3_dst">dst</a> <a href="SkImageInfo_Reference#Color_Type">Color Type</a> must match. 3058If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, <a href="#SkBitmap_readPixels_3_dst">dst</a> <a href="undocumented#Color_Space">Color Space</a> must match. 3059If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_alphaType">alphaType</a> is <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>, <a href="#SkBitmap_readPixels_3_dst">dst</a> <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> must 3060match. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorSpace">colorSpace</a> is nullptr, <a href="#SkBitmap_readPixels_3_dst">dst</a> <a href="undocumented#Color_Space">Color Space</a> must match. Returns 3061false if pixel conversion is not possible. 3062<a href="#SkBitmap_readPixels_3_srcX">srcX</a> and <a href="#SkBitmap_readPixels_3_srcY">srcY</a> may be negative to copy only top or left of source. Returns 3063false if <a href="#SkBitmap_width">width</a> or <a href="#SkBitmap_height">height</a> is zero or negative. 3064Returns false ifabs(srcX) >= <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_width">width</a>, 3065or ifabs(srcY) >= <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_height">height</a>. 3066 3067### Parameters 3068 3069<table> <tr> <td><a name="SkBitmap_readPixels_3_dst"> <code><strong>dst </strong></code> </a></td> <td> 3070destination <a href="SkPixmap_Reference#Pixmap">Pixmap</a>: <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, pixels, row bytes</td> 3071 </tr> <tr> <td><a name="SkBitmap_readPixels_3_srcX"> <code><strong>srcX </strong></code> </a></td> <td> 3072column index whose absolute value is less than <a href="#SkBitmap_width">width</a></td> 3073 </tr> <tr> <td><a name="SkBitmap_readPixels_3_srcY"> <code><strong>srcY </strong></code> </a></td> <td> 3074row index whose absolute value is less than <a href="#SkBitmap_height">height</a></td> 3075 </tr> 3076</table> 3077 3078### Return Value 3079 3080true if pixels are copied to <a href="#SkBitmap_readPixels_3_dst">dst</a> 3081 3082### Example 3083 3084<div><fiddle-embed name="e9f70cbc9827097449a386ec7a8a8188"></fiddle-embed></div> 3085 3086### See Also 3087 3088<a href="#SkBitmap_writePixels">writePixels</a><sup><a href="#SkBitmap_writePixels_2">[2]</a></sup><sup><a href="#SkBitmap_writePixels_3">[3]</a></sup> <a href="#SkPixmap_readPixels">SkPixmap::readPixels</a><sup><a href="#SkPixmap_readPixels_2">[2]</a></sup><sup><a href="#SkPixmap_readPixels_3">[3]</a></sup><sup><a href="#SkPixmap_readPixels_4">[4]</a></sup><sup><a href="#SkPixmap_readPixels_5">[5]</a></sup> <a href="#SkCanvas_readPixels">SkCanvas::readPixels</a><sup><a href="#SkCanvas_readPixels_2">[2]</a></sup><sup><a href="#SkCanvas_readPixels_3">[3]</a></sup> <a href="#SkImage_readPixels">SkImage::readPixels</a><sup><a href="#SkImage_readPixels_2">[2]</a></sup> <a href="#SkSurface_readPixels">SkSurface::readPixels</a><sup><a href="#SkSurface_readPixels_2">[2]</a></sup><sup><a href="#SkSurface_readPixels_3">[3]</a></sup> 3089 3090--- 3091 3092<a name="SkBitmap_readPixels_4"></a> 3093 3094<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3095bool readPixels(const SkPixmap& dst) const 3096</pre> 3097 3098Copies a <a href="SkRect_Reference#Rect">Rect</a> of pixels from <a href="#Bitmap">Bitmap</a> to <a href="#SkBitmap_readPixels_4_dst">dst</a>. Copy starts at (0, 0), and 3099does not exceed <a href="#Bitmap">Bitmap</a> (<a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_height">height</a>). 3100 3101<a href="#SkBitmap_readPixels_4_dst">dst</a> specifies width, height, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="undocumented#Color_Space">Color Space</a>, pixel storage, 3102and row bytes of destination. <a href="#SkBitmap_readPixels_4_dst">dst</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> specifics the gap from one destination 3103row to the next. Returns true if pixels are copied. Returns false if: 3104 3105<table> <tr> 3106 <td><a href="#SkBitmap_readPixels_4_dst">dst</a> pixel storage equals nullptr</td> </tr> <tr> 3107 <td><a href="#SkBitmap_readPixels_4_dst">dst</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> is less than <a href="#SkImageInfo_minRowBytes">SkImageInfo::minRowBytes</a></td> </tr> <tr> 3108 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> 3109</table> 3110 3111Pixels are copied only if pixel conversion is possible. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is 3112<a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, or <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>; <a href="#SkBitmap_readPixels_4_dst">dst</a> <a href="SkImageInfo_Reference#Color_Type">Color Type</a> must match. 3113If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, <a href="#SkBitmap_readPixels_4_dst">dst</a> <a href="undocumented#Color_Space">Color Space</a> must match. 3114If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_alphaType">alphaType</a> is <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>, <a href="#SkBitmap_readPixels_4_dst">dst</a> <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> must 3115match. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorSpace">colorSpace</a> is nullptr, <a href="#SkBitmap_readPixels_4_dst">dst</a> <a href="undocumented#Color_Space">Color Space</a> must match. Returns 3116false if pixel conversion is not possible. 3117 3118### Parameters 3119 3120<table> <tr> <td><a name="SkBitmap_readPixels_4_dst"> <code><strong>dst </strong></code> </a></td> <td> 3121destination <a href="SkPixmap_Reference#Pixmap">Pixmap</a>: <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, pixels, row bytes</td> 3122 </tr> 3123</table> 3124 3125### Return Value 3126 3127true if pixels are copied to <a href="#SkBitmap_readPixels_4_dst">dst</a> 3128 3129### Example 3130 3131<div><fiddle-embed name="2260ff6d04708699b6223b4f73fd268e"></fiddle-embed></div> 3132 3133### See Also 3134 3135<a href="#SkBitmap_writePixels">writePixels</a><sup><a href="#SkBitmap_writePixels_2">[2]</a></sup><sup><a href="#SkBitmap_writePixels_3">[3]</a></sup> <a href="#SkPixmap_readPixels">SkPixmap::readPixels</a><sup><a href="#SkPixmap_readPixels_2">[2]</a></sup><sup><a href="#SkPixmap_readPixels_3">[3]</a></sup><sup><a href="#SkPixmap_readPixels_4">[4]</a></sup><sup><a href="#SkPixmap_readPixels_5">[5]</a></sup> <a href="#SkCanvas_readPixels">SkCanvas::readPixels</a><sup><a href="#SkCanvas_readPixels_2">[2]</a></sup><sup><a href="#SkCanvas_readPixels_3">[3]</a></sup> <a href="#SkImage_readPixels">SkImage::readPixels</a><sup><a href="#SkImage_readPixels_2">[2]</a></sup> <a href="#SkSurface_readPixels">SkSurface::readPixels</a><sup><a href="#SkSurface_readPixels_2">[2]</a></sup><sup><a href="#SkSurface_readPixels_3">[3]</a></sup> 3136 3137--- 3138 3139<a name="SkBitmap_writePixels"></a> 3140## writePixels 3141 3142<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3143bool writePixels(const SkPixmap& src, int dstX, int dstY) 3144</pre> 3145 3146Copies a <a href="SkRect_Reference#Rect">Rect</a> of pixels from <a href="#SkBitmap_writePixels_src">src</a>. Copy starts at (<a href="#SkBitmap_writePixels_dstX">dstX</a>, <a href="#SkBitmap_writePixels_dstY">dstY</a>), and does not exceed 3147(<a href="#SkBitmap_writePixels_src">src</a>.<a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_writePixels_src">src</a>.<a href="#SkBitmap_height">height</a>). 3148 3149<a href="#SkBitmap_writePixels_src">src</a> specifies width, height, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="undocumented#Color_Space">Color Space</a>, pixel storage, 3150and row bytes of source. <a href="#SkBitmap_writePixels_src">src</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> specifics the gap from one source 3151row to the next. Returns true if pixels are copied. Returns false if: 3152 3153<table> <tr> 3154 <td><a href="#SkBitmap_writePixels_src">src</a> pixel storage equals nullptr</td> </tr> <tr> 3155 <td><a href="#SkBitmap_writePixels_src">src</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> is less than <a href="#SkImageInfo_minRowBytes">SkImageInfo::minRowBytes</a></td> </tr> <tr> 3156 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> 3157</table> 3158 3159Pixels are copied only if pixel conversion is possible. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is 3160<a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, or <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>; <a href="#SkBitmap_writePixels_src">src</a> <a href="SkImageInfo_Reference#Color_Type">Color Type</a> must match. 3161If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, <a href="#SkBitmap_writePixels_src">src</a> <a href="undocumented#Color_Space">Color Space</a> must match. 3162If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_alphaType">alphaType</a> is <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>, <a href="#SkBitmap_writePixels_src">src</a> <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> must 3163match. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorSpace">colorSpace</a> is nullptr, <a href="#SkBitmap_writePixels_src">src</a> <a href="undocumented#Color_Space">Color Space</a> must match. Returns 3164false if pixel conversion is not possible. 3165<a href="#SkBitmap_writePixels_dstX">dstX</a> and <a href="#SkBitmap_writePixels_dstY">dstY</a> may be negative to copy only top or left of source. Returns 3166false if <a href="#SkBitmap_width">width</a> or <a href="#SkBitmap_height">height</a> is zero or negative. 3167Returns false ifabs(dstX) >= <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_width">width</a>, 3168or ifabs(dstY) >= <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_height">height</a>. 3169 3170### Parameters 3171 3172<table> <tr> <td><a name="SkBitmap_writePixels_src"> <code><strong>src </strong></code> </a></td> <td> 3173source <a href="SkPixmap_Reference#Pixmap">Pixmap</a>: <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, pixels, row bytes</td> 3174 </tr> <tr> <td><a name="SkBitmap_writePixels_dstX"> <code><strong>dstX </strong></code> </a></td> <td> 3175column index whose absolute value is less than <a href="#SkBitmap_width">width</a></td> 3176 </tr> <tr> <td><a name="SkBitmap_writePixels_dstY"> <code><strong>dstY </strong></code> </a></td> <td> 3177row index whose absolute value is less than <a href="#SkBitmap_height">height</a></td> 3178 </tr> 3179</table> 3180 3181### Return Value 3182 3183true if <a href="#SkBitmap_writePixels_src">src</a> pixels are copied to <a href="#Bitmap">Bitmap</a> 3184 3185### Example 3186 3187<div><fiddle-embed name="9b3133a6673d2514d166398adbe1f9f4"></fiddle-embed></div> 3188 3189### See Also 3190 3191<a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> 3192 3193--- 3194 3195<a name="SkBitmap_writePixels_2"></a> 3196 3197<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3198bool writePixels(const SkPixmap& src) 3199</pre> 3200 3201Copies a <a href="SkRect_Reference#Rect">Rect</a> of pixels from <a href="#SkBitmap_writePixels_2_src">src</a>. Copy starts at (0, 0), and does not exceed 3202(<a href="#SkBitmap_writePixels_2_src">src</a>.<a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_writePixels_2_src">src</a>.<a href="#SkBitmap_height">height</a>). 3203 3204<a href="#SkBitmap_writePixels_2_src">src</a> specifies width, height, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="undocumented#Color_Space">Color Space</a>, pixel storage, 3205and row bytes of source. <a href="#SkBitmap_writePixels_2_src">src</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> specifics the gap from one source 3206row to the next. Returns true if pixels are copied. Returns false if: 3207 3208<table> <tr> 3209 <td><a href="#SkBitmap_writePixels_2_src">src</a> pixel storage equals nullptr</td> </tr> <tr> 3210 <td><a href="#SkBitmap_writePixels_2_src">src</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> is less than <a href="#SkImageInfo_minRowBytes">SkImageInfo::minRowBytes</a></td> </tr> <tr> 3211 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> 3212</table> 3213 3214Pixels are copied only if pixel conversion is possible. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is 3215<a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, or <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>; <a href="#SkBitmap_writePixels_2_src">src</a> <a href="SkImageInfo_Reference#Color_Type">Color Type</a> must match. 3216If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, <a href="#SkBitmap_writePixels_2_src">src</a> <a href="undocumented#Color_Space">Color Space</a> must match. 3217If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_alphaType">alphaType</a> is <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>, <a href="#SkBitmap_writePixels_2_src">src</a> <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> must 3218match. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorSpace">colorSpace</a> is nullptr, <a href="#SkBitmap_writePixels_2_src">src</a> <a href="undocumented#Color_Space">Color Space</a> must match. Returns 3219false if pixel conversion is not possible. 3220 3221### Parameters 3222 3223<table> <tr> <td><a name="SkBitmap_writePixels_2_src"> <code><strong>src </strong></code> </a></td> <td> 3224source <a href="SkPixmap_Reference#Pixmap">Pixmap</a>: <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, pixels, row bytes</td> 3225 </tr> 3226</table> 3227 3228### Return Value 3229 3230true if <a href="#SkBitmap_writePixels_2_src">src</a> pixels are copied to <a href="#Bitmap">Bitmap</a> 3231 3232### Example 3233 3234<div><fiddle-embed name="faa5dfa466f6e16c07c124d971f32679"></fiddle-embed></div> 3235 3236### See Also 3237 3238<a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> 3239 3240--- 3241 3242<a name="SkBitmap_writePixels_3"></a> 3243 3244<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3245bool writePixels(const SkPixmap& src, int x, int y, SkTransferFunctionBehavior behavior) 3246</pre> 3247 3248Copies a <a href="SkRect_Reference#Rect">Rect</a> of pixels from <a href="#SkBitmap_writePixels_3_src">src</a>. Copy starts at (0, 0), and does not exceed 3249(<a href="#SkBitmap_writePixels_3_src">src</a>.<a href="#SkBitmap_width">width</a>, <a href="#SkBitmap_writePixels_3_src">src</a>.<a href="#SkBitmap_height">height</a>). 3250 3251<a href="#SkBitmap_writePixels_3_src">src</a> specifies width, height, <a href="SkImageInfo_Reference#Color_Type">Color Type</a>, <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a>, <a href="undocumented#Color_Space">Color Space</a>, pixel storage, 3252and row bytes of source. <a href="#SkBitmap_writePixels_3_src">src</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> specifics the gap from one source 3253row to the next. Returns true if pixels are copied. Returns false if: 3254 3255<table> <tr> 3256 <td><a href="#SkBitmap_writePixels_3_src">src</a> pixel storage equals nullptr</td> </tr> <tr> 3257 <td><a href="#SkBitmap_writePixels_3_src">src</a>.<a href="#SkBitmap_rowBytes">rowBytes</a> is less than <a href="#SkImageInfo_minRowBytes">SkImageInfo::minRowBytes</a></td> </tr> <tr> 3258 <td><a href="undocumented#Pixel_Ref">Pixel Ref</a> is nullptr</td> </tr> 3259</table> 3260 3261Pixels are copied only if pixel conversion is possible. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is 3262<a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, or <a href="SkImageInfo_Reference#SkColorType">kAlpha 8 SkColorType</a>; <a href="#SkBitmap_writePixels_3_src">src</a> <a href="SkImageInfo_Reference#Color_Type">Color Type</a> must match. 3263If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorType">colorType</a> is <a href="SkImageInfo_Reference#SkColorType">kGray 8 SkColorType</a>, <a href="#SkBitmap_writePixels_3_src">src</a> <a href="undocumented#Color_Space">Color Space</a> must match. 3264If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_alphaType">alphaType</a> is <a href="SkImageInfo_Reference#SkAlphaType">kOpaque SkAlphaType</a>, <a href="#SkBitmap_writePixels_3_src">src</a> <a href="SkImageInfo_Reference#Alpha_Type">Alpha Type</a> must 3265match. If <a href="#Bitmap">Bitmap</a> <a href="#SkBitmap_colorSpace">colorSpace</a> is nullptr, <a href="#SkBitmap_writePixels_3_src">src</a> <a href="undocumented#Color_Space">Color Space</a> must match. Returns 3266false if pixel conversion is not possible. Returns false if <a href="#SkBitmap_width">width</a> or <a href="#SkBitmap_height">height</a> 3267is zero or negative. 3268 3269If <a href="#SkBitmap_writePixels_3_behavior">behavior</a> is <a href="#SkTransferFunctionBehavior_kRespect">SkTransferFunctionBehavior::kRespect</a>: converts <a href="#SkBitmap_writePixels_3_src">src</a> 3270pixels to a linear space before converting to <a href="SkImageInfo_Reference#Image_Info">Image Info</a>. 3271If <a href="#SkBitmap_writePixels_3_behavior">behavior</a> is <a href="#SkTransferFunctionBehavior_kIgnore">SkTransferFunctionBehavior::kIgnore</a>: <a href="#SkBitmap_writePixels_3_src">src</a> 3272pixels are treated as if they are linear, regardless of how they are encoded. 3273 3274### Parameters 3275 3276<table> <tr> <td><a name="SkBitmap_writePixels_3_src"> <code><strong>src </strong></code> </a></td> <td> 3277source <a href="SkPixmap_Reference#Pixmap">Pixmap</a>: <a href="SkImageInfo_Reference#Image_Info">Image Info</a>, pixels, row bytes</td> 3278 </tr> <tr> <td><a name="SkBitmap_writePixels_3_x"> <code><strong>x </strong></code> </a></td> <td> 3279column index whose absolute value is less than <a href="#SkBitmap_width">width</a></td> 3280 </tr> <tr> <td><a name="SkBitmap_writePixels_3_y"> <code><strong>y </strong></code> </a></td> <td> 3281row index whose absolute value is less than <a href="#SkBitmap_height">height</a></td> 3282 </tr> <tr> <td><a name="SkBitmap_writePixels_3_behavior"> <code><strong>behavior </strong></code> </a></td> <td> 3283one of: <a href="#SkTransferFunctionBehavior_kRespect">SkTransferFunctionBehavior::kRespect</a>, 3284<a href="#SkTransferFunctionBehavior_kIgnore">SkTransferFunctionBehavior::kIgnore</a></td> 3285 </tr> 3286</table> 3287 3288### Return Value 3289 3290true if <a href="#SkBitmap_writePixels_3_src">src</a> pixels are copied to <a href="#Bitmap">Bitmap</a> 3291 3292### Example 3293 3294<div><fiddle-embed name="9f046f407b01b759cb737d702a994620"></fiddle-embed></div> 3295 3296### See Also 3297 3298<a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> 3299 3300--- 3301 3302<a name="SkBitmap_hasHardwareMipMap"></a> 3303## hasHardwareMipMap 3304 3305<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3306bool hasHardwareMipMap() const 3307</pre> 3308 3309### Return Value 3310 3311true if <a href="#SkBitmap_setHasHardwareMipMap">setHasHardwareMipMap</a> has been called with true 3312 3313### See Also 3314 3315<a href="#SkBitmap_setHasHardwareMipMap">setHasHardwareMipMap</a> 3316 3317--- 3318 3319<a name="SkBitmap_setHasHardwareMipMap"></a> 3320## setHasHardwareMipMap 3321 3322<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3323void setHasHardwareMipMap(bool hasHardwareMipMap) 3324</pre> 3325 3326### Parameters 3327 3328<table> <tr> <td><a name="SkBitmap_setHasHardwareMipMap_hasHardwareMipMap"> <code><strong>hasHardwareMipMap </strong></code> </a></td> <td> 3329sets state</td> 3330 </tr> 3331</table> 3332 3333### See Also 3334 3335<a href="#SkBitmap_hasHardwareMipMap">hasHardwareMipMap</a> 3336 3337--- 3338 3339<a name="SkBitmap_extractAlpha"></a> 3340## extractAlpha 3341 3342<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3343bool extractAlpha(SkBitmap* dst) const 3344</pre> 3345 3346Sets <a href="#SkBitmap_extractAlpha_dst">dst</a> to <a href="#Alpha">Alpha</a> described by pixels. Returns false if <a href="#SkBitmap_extractAlpha_dst">dst</a> cannot be written to 3347or <a href="#SkBitmap_extractAlpha_dst">dst</a> pixels cannot be allocated. 3348 3349Uses <a href="#SkBitmap_HeapAllocator">HeapAllocator</a> to reserve memory for <a href="#SkBitmap_extractAlpha_dst">dst</a> <a href="undocumented#Pixel_Ref">Pixel Ref</a>. 3350 3351### Parameters 3352 3353<table> <tr> <td><a name="SkBitmap_extractAlpha_dst"> <code><strong>dst </strong></code> </a></td> <td> 3354holds <a href="undocumented#Pixel_Ref">Pixel Ref</a> to fill with alpha layer</td> 3355 </tr> 3356</table> 3357 3358### Return Value 3359 3360true if <a href="#Alpha">Alpha</a> layer was constructed in <a href="#SkBitmap_extractAlpha_dst">dst</a> <a href="undocumented#Pixel_Ref">Pixel Ref</a> 3361 3362### Example 3363 3364<div><fiddle-embed name="ab6577df079e6c70511cf2bfc6447b44"></fiddle-embed></div> 3365 3366### See Also 3367 3368<a href="#SkBitmap_extractSubset">extractSubset</a> 3369 3370--- 3371 3372<a name="SkBitmap_extractAlpha_2"></a> 3373 3374<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3375bool extractAlpha(SkBitmap* dst, const SkPaint* paint, SkIPoint* offset) const 3376</pre> 3377 3378Sets <a href="#SkBitmap_extractAlpha_2_dst">dst</a> to <a href="#Alpha">Alpha</a> described by pixels. Returns false if <a href="#SkBitmap_extractAlpha_2_dst">dst</a> cannot be written to 3379or <a href="#SkBitmap_extractAlpha_2_dst">dst</a> pixels cannot be allocated. 3380 3381If <a href="#SkBitmap_extractAlpha_2_paint">paint</a> is not nullptr and contains <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="#SkMaskFilter_filterMask">SkMaskFilter::filterMask</a> 3382generates <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> 3383<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>; 3384(0, 0) unless <a href="undocumented#SkMaskFilter">SkMaskFilter</a> generates mask. 3385 3386### Parameters 3387 3388<table> <tr> <td><a name="SkBitmap_extractAlpha_2_dst"> <code><strong>dst </strong></code> </a></td> <td> 3389holds <a href="undocumented#Pixel_Ref">Pixel Ref</a> to fill with alpha layer</td> 3390 </tr> <tr> <td><a name="SkBitmap_extractAlpha_2_paint"> <code><strong>paint </strong></code> </a></td> <td> 3391holds optional <a href="undocumented#Mask_Filter">Mask Filter</a>; may be nullptr</td> 3392 </tr> <tr> <td><a name="SkBitmap_extractAlpha_2_offset"> <code><strong>offset </strong></code> </a></td> <td> 3393top-left position for <a href="#SkBitmap_extractAlpha_2_dst">dst</a>; may be nullptr</td> 3394 </tr> 3395</table> 3396 3397### Return Value 3398 3399true if <a href="#Alpha">Alpha</a> layer was constructed in <a href="#SkBitmap_extractAlpha_2_dst">dst</a> <a href="undocumented#Pixel_Ref">Pixel Ref</a> 3400 3401### Example 3402 3403<div><fiddle-embed name="e122936b119f20098aace454c2105a12"></fiddle-embed></div> 3404 3405### See Also 3406 3407<a href="#SkBitmap_extractSubset">extractSubset</a> 3408 3409--- 3410 3411<a name="SkBitmap_extractAlpha_3"></a> 3412 3413<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3414bool extractAlpha(SkBitmap* dst, const SkPaint* paint, Allocator* allocator, SkIPoint* offset) const 3415</pre> 3416 3417Sets <a href="#SkBitmap_extractAlpha_3_dst">dst</a> to <a href="#Alpha">Alpha</a> described by pixels. Returns false if <a href="#SkBitmap_extractAlpha_3_dst">dst</a> cannot be written to 3418or <a href="#SkBitmap_extractAlpha_3_dst">dst</a> pixels cannot be allocated. 3419 3420If <a href="#SkBitmap_extractAlpha_3_paint">paint</a> is not nullptr and contains <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="#SkMaskFilter_filterMask">SkMaskFilter::filterMask</a> 3421generates <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 3422class 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 3423position 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 3424mask. 3425 3426### Parameters 3427 3428<table> <tr> <td><a name="SkBitmap_extractAlpha_3_dst"> <code><strong>dst </strong></code> </a></td> <td> 3429holds <a href="undocumented#Pixel_Ref">Pixel Ref</a> to fill with alpha layer</td> 3430 </tr> <tr> <td><a name="SkBitmap_extractAlpha_3_paint"> <code><strong>paint </strong></code> </a></td> <td> 3431holds optional <a href="undocumented#Mask_Filter">Mask Filter</a>; may be nullptr</td> 3432 </tr> <tr> <td><a name="SkBitmap_extractAlpha_3_allocator"> <code><strong>allocator </strong></code> </a></td> <td> 3433method to reserve memory for <a href="undocumented#Pixel_Ref">Pixel Ref</a>; may be nullptr</td> 3434 </tr> <tr> <td><a name="SkBitmap_extractAlpha_3_offset"> <code><strong>offset </strong></code> </a></td> <td> 3435top-left position for <a href="#SkBitmap_extractAlpha_3_dst">dst</a>; may be nullptr</td> 3436 </tr> 3437</table> 3438 3439### Return Value 3440 3441true if <a href="#Alpha">Alpha</a> layer was constructed in <a href="#SkBitmap_extractAlpha_3_dst">dst</a> <a href="undocumented#Pixel_Ref">Pixel Ref</a> 3442 3443### Example 3444 3445<div><fiddle-embed name="3563cb608791d55bb584f38e842f3003"></fiddle-embed></div> 3446 3447### See Also 3448 3449<a href="#SkBitmap_extractSubset">extractSubset</a> 3450 3451--- 3452 3453<a name="SkBitmap_peekPixels"></a> 3454## peekPixels 3455 3456<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3457bool peekPixels(SkPixmap* pixmap) const 3458</pre> 3459 3460Copies <a href="#Bitmap">Bitmap</a> pixel address, row bytes, and <a href="SkImageInfo_Reference#Image_Info">Image Info</a> to pixmap, if address 3461is available, and returns true. If pixel address is not available, return 3462false and leave pixmap unchanged. 3463 3464pixmap contents become invalid on any future change to <a href="#Bitmap">Bitmap</a>. 3465 3466### Parameters 3467 3468<table> <tr> <td><a name="SkBitmap_peekPixels_pixmap"> <code><strong>pixmap </strong></code> </a></td> <td> 3469storage for pixel state if pixels are readable; otherwise, ignored</td> 3470 </tr> 3471</table> 3472 3473### Return Value 3474 3475true if <a href="#Bitmap">Bitmap</a> has direct access to pixels 3476 3477### Example 3478 3479<div><fiddle-embed name="0cc2c6a0dffa61a88711534bd3d43b40"> 3480 3481#### Example Output 3482 3483~~~~ 3484------ 3485-xxx-- 3486x---x- 3487----x- 3488---x-- 3489--x--- 3490--x--- 3491------ 3492--x--- 3493--x--- 3494------ 3495~~~~ 3496 3497</fiddle-embed></div> 3498 3499### See Also 3500 3501<a href="#SkBitmap_pixmap">pixmap</a> <a href="#SkBitmap_installPixels">installPixels</a><sup><a href="#SkBitmap_installPixels_2">[2]</a></sup><sup><a href="#SkBitmap_installPixels_3">[3]</a></sup> <a href="#SkBitmap_readPixels">readPixels</a><sup><a href="#SkBitmap_readPixels_2">[2]</a></sup><sup><a href="#SkBitmap_readPixels_3">[3]</a></sup><sup><a href="#SkBitmap_readPixels_4">[4]</a></sup> <a href="#SkBitmap_writePixels">writePixels</a><sup><a href="#SkBitmap_writePixels_2">[2]</a></sup><sup><a href="#SkBitmap_writePixels_3">[3]</a></sup> 3502 3503--- 3504 3505<a name="SkBitmap_validate"></a> 3506## validate 3507 3508<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3509void validate() const; 3510</pre> 3511 3512Asserts if internal values are illegal or inconsistent. Only available if 3513SK_DEBUG is defined at compile time. 3514 3515### See Also 3516 3517<a href="#SkImageInfo_validate">SkImageInfo::validate()</a> 3518 3519--- 3520 3521<a name="SkBitmap_toString"></a> 3522## toString 3523 3524<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3525void toString(SkString* str) const; 3526</pre> 3527 3528Creates string representation of <a href="#Bitmap">Bitmap</a>. The representation is read by 3529internal debugging tools. The interface and implementation may be 3530suppressed by defining SK_IGNORE_TO_STRING. 3531 3532### Parameters 3533 3534<table> <tr> <td><a name="SkBitmap_toString_str"> <code><strong>str </strong></code> </a></td> <td> 3535storage for string representation</td> 3536 </tr> 3537</table> 3538 3539### Example 3540 3541<div><fiddle-embed name="6018d98695245510839a318caabba9c9"> 3542 3543#### Example Output 3544 3545~~~~ 3546bitmap dimensions (6, 11) 3547~~~~ 3548 3549</fiddle-embed></div> 3550 3551### See Also 3552 3553<a href="#SkPaint_toString">SkPaint::toString</a> 3554 3555--- 3556 3557