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