1--- 2title: 'SkBlendMode Overview' 3linkTitle: 'SkBlendMode Overview' 4 5weight: 260 6--- 7 8Describes how destination <a href='undocumented#Pixel'>pixel</a> is replaced 9with a combination of itself and source <a href='undocumented#Pixel'>pixel</a>. 10<a href='#Blend_Mode'>Blend_Mode</a> may use source, destination, or both. 11<a href='#Blend_Mode'>Blend_Mode</a> may operate on each 12<a href='https://api.skia.org/SkColor_8h.html'>Color</a> component 13independently, or may allow all source <a href='undocumented#Pixel'>pixel</a> 14components to contribute to one destination 15<a href='undocumented#Pixel'>pixel</a> component. 16 17<a href='#Blend_Mode'>Blend_Mode</a> does not use adjacent pixels to determine 18the outcome. 19 20<a href='#Blend_Mode'>Blend_Mode</a> uses source and read destination 21<a href='https://api.skia.org/SkColor_8h.html#a918cf5a3a68406ac8107f6be48fb906e'>Alpha</a> 22to determine written destination 23<a href='https://api.skia.org/SkColor_8h.html#a918cf5a3a68406ac8107f6be48fb906e'>Alpha</a>; 24both source and destination 25<a href='https://api.skia.org/SkColor_8h.html#a918cf5a3a68406ac8107f6be48fb906e'>Alpha</a> 26may also affect written destination 27<a href='https://api.skia.org/SkColor_8h.html'>Color</a> components. 28 29Regardless of how 30<a href='https://api.skia.org/SkColor_8h.html#a918cf5a3a68406ac8107f6be48fb906e'>Alpha</a> 31is encoded in source and destination <a href='undocumented#Pixel'>pixel</a>, 32nearly all <a href='#Image_Info_Color_Type'>Color_Types</a> treat it as ranging 33from zero to one. And, nearly all <a href='#Blend_Mode'>Blend_Mode</a> 34algorithms limit the output so that all results are also zero to one. 35 36Two exceptions are 37<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kPlus'>kPlus</a> 38and 39<a href='https://api.skia.org/SkImageInfo_8h.html#a9ac0b62b3d2c6c7e1a80db557243f93e'>kRGBA_F16_SkColorType</a>. 40 41<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kPlus'>kPlus</a> 42permits computing 43<a href='https://api.skia.org/SkColor_8h.html#a918cf5a3a68406ac8107f6be48fb906e'>Alpha</a> 44and <a href='https://api.skia.org/SkColor_8h.html'>Color</a> component values 45larger than one. For <a href='#Image_Info_Color_Type'>Color_Types</a> other than 46<a href='https://api.skia.org/SkImageInfo_8h.html#a9ac0b62b3d2c6c7e1a80db557243f93e'>kRGBA_F16_SkColorType</a>, 47resulting 48<a href='https://api.skia.org/SkColor_8h.html#a918cf5a3a68406ac8107f6be48fb906e'>Alpha</a> 49and component values are clamped to one. 50 51<a href='https://api.skia.org/SkImageInfo_8h.html#a9ac0b62b3d2c6c7e1a80db557243f93e'>kRGBA_F16_SkColorType</a> 52permits values outside the zero to one range. It is up to the client to ensure 53that the result is within the range of zero to one, and therefore well-defined. 54 55<a name='Porter_Duff'></a> 56 57<a href='https://graphics.pixar.com/library/Compositing/paper.pdf'>Compositing 58Digital Images</a></a> describes 59<a href='#Blend_Mode_Overview_Porter_Duff'>Porter_Duff</a> modes 60<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kClear'>kClear</a> 61through 62<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kXor'>kXor</a>. 63 64Drawing a <a href='https://api.skia.org/classSkBitmap.html'>bitmap</a> with 65transparency using <a href='#Blend_Mode_Overview_Porter_Duff'>Porter_Duff</a> 66compositing is free to clear the destination. 67 68![Porter_Duff](https://fiddle.skia.org/i/819903e0bb125385269948474b6c8a84_raster.png) 69 70Draw geometry with transparency using 71<a href='#Blend_Mode_Overview_Porter_Duff'>Porter_Duff</a> compositing does not 72combine transparent source pixels, leaving the destination outside the geometry 73untouched. 74 75![Porter_Duff](https://fiddle.skia.org/i/8f320c1e94e77046e00f7e9e843caa27_raster.png) 76 77<a name='Lighten_Darken'></a> 78 79Modes 80<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kPlus'>kPlus</a> 81and 82<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kScreen'>kScreen</a> 83use simple arithmetic to lighten or darken the destination. Modes 84<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kOverlay'>kOverlay</a> 85through 86<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kMultiply'>kMultiply</a> 87use more complicated algorithms to lighten or darken; sometimes one mode does 88both, as described by <a href='https://en.wikipedia.org/wiki/Blend_modes'>Blend 89Modes</a></a> . 90 91![Lighten_Darken](https://fiddle.skia.org/i/23a33fa04cdd0204b2490d05e340f87c_raster.png) 92 93<a name='Modulate_Blend'></a> 94 95<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kModulate'>kModulate</a> 96is a mashup of 97<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kSrcATop'>kSrcATop</a> 98and 99<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kMultiply'>kMultiply</a>. 100It multiplies all components, including 101<a href='https://api.skia.org/SkColor_8h.html#a918cf5a3a68406ac8107f6be48fb906e'>Alpha</a>; 102unlike 103<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kMultiply'>kMultiply</a>, 104if either source or destination is transparent, result is transparent. 105<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kModulate'>kModulate</a> 106uses <a href='undocumented#Premultiply'>Premultiplied</a> values to compute the 107product; 108<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kMultiply'>kMultiply</a> 109uses <a href='undocumented#Unpremultiply'>Unpremultiplied</a> values to compute 110the product. 111 112![Modulate_Blend](https://fiddle.skia.org/i/877f96610ab7638a310432674b04f837_raster.png) 113 114<a name='Color_Blends'></a> 115 116Modes 117<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kHue'>kHue</a>, 118<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kSaturation'>kSaturation</a>, 119<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kColor'>kColor</a>, 120and 121<a href='https://api.skia.org/SkBlendMode_8h.html#ad96d76accb8ff5f3eafa29b91f7a25f0'>SkBlendMode</a>::<a href='#SkBlendMode_kLuminosity'>kLuminosity</a> 122convert source and destination pixels using all components 123<a href='https://api.skia.org/SkColor_8h.html'>color</a> information, using 124<a href='https://www.w3.org/TR/compositing-1/#blendingnonseparable'>non-separable 125blend modes</a></a> . 126 127![Color_Blends](https://fiddle.skia.org/i/630fe21aea8369b307231f5bcf8b2d50_raster.png) 128