{{DISPLAYTITLE:_DONTBLEND}}
The [[_DONTBLEND]] statement turns off 32 bit alpha blending for the current image or screen mode where [[_BLEND]] is default.


{{PageSyntax}}
: '''_DONTBLEND''' [{{Parameter|imageHandle&amp;}}]


{{Parameters}}
* If {{Parameter|imageHandle&amp;}} is omitted, it is assumed to be the current [[_DEST]]ination write page.


''Usage:''
* If {{Parameter|imageHandle&amp;}} is not valid, an [[ERROR Codes|Invalid handle]] error will occur.
* [[_DONTBLEND]] is faster than the default [[_BLEND]] unless you really need to use it in 32 bit!
* '''32 bit screen surface backgrounds(black) have zero [[_ALPHA]] so that they are transparent when placed over other surfaces.'''
: Use [[CLS]] or [[_DONTBLEND]] to make a new surface background [[_ALPHA]] 255 or opague.


''Example 1:'' Use _DONTBLEND when you want the 32 bit screen surface to be opaque so that it covers up other backgrounds. [[CLS]] works too.
{{CodeStart}} '' ''
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(1280, 720, 32)
'{{Cl|CLS}}
{{Cl|_DONTBLEND}} '&lt;&lt;&lt; comment out to see the difference

{{Cl|LINE}} (100, 100)-(500, 500), {{Cl|_RGB32}}(255, 255, 0), BF

b&amp; = SaveBackground&amp;

{{Cl|PRINT}} &quot;This is just test junk&quot;
{{Cl|PRINT}}
{{Cl|PRINT}} &quot;Hit any key and the text should disappear, leaving us our pretty yellow box.&quot;
{{Cl|SLEEP}}
RestoreBackground b&amp;

{{Cl|END}}

{{Cl|FUNCTION}} SaveBackground&amp;
SaveBackground&amp; = {{Cl|_COPYIMAGE}}(0)
{{Cl|END FUNCTION}}

{{Cl|SUB}} RestoreBackground (Image {{Cl|AS}} {{Cl|LONG}})
{{Cl|_PUTIMAGE}} (200, 200), Image, 0
{{Cl|END SUB}} '' ''
{{CodeEnd}}


''Example 2:'' Turning off blending to create transparency.
{{CodeStart}}

{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
alphaSprite&amp; = {{Cl|_NEWIMAGE}}(64, 64, 32)

{{Cl|_DONTBLEND}} alphaSprite&amp;   ' turn off alpha-blending

'Create a simple sprite with transparency
{{Cl|_DEST}} alphaSprite&amp;
{{Cl|FOR}} y = 0 {{Cl|TO}} 63
  {{Cl|FOR}} x = 0 {{Cl|TO}} 63
    alpha = {{Cl|SQR}}((x - 32) ^ 2 + (y - 32) ^ 2) / 32
    {{Cl|IF}} alpha &lt; 0 {{Cl|THEN}} alpha = 0
    alpha = (1 - alpha * alpha) 'parabolic curve
    {{Cl|PSET}} (x, y), {{Cl|_RGBA32}}(255, 255, 255, alpha * 255)
  {{Cl|NEXT}}
{{Cl|NEXT}}

'Make a simple background texture
{{Cl|_DEST}} 0
{{Cl|FOR}} y = 1 {{Cl|TO}} 479
  {{Cl|FOR}} x = 0 {{Cl|TO}} 639
    {{Cl|PSET}} (x, y), {{Cl|_RGB32}}(x {{Cl|AND (boolean)|AND}} 255, y {{Cl|AND (boolean)|AND}} 255, (x {{Cl|XOR (boolean)|XOR}} y) {{Cl|AND (boolean)|AND}} 255)
  {{Cl|NEXT}}
{{Cl|NEXT}}

'Store background so we can show moveable objects on it
background&amp; = {{Cl|_COPYIMAGE}}

'Treat my alpha values as transparency
{{Cl|_BLEND}} alphaSprite&amp;

ph = 0
{{Cl|DO}}:  {{Cl|_LIMIT}} 60
  x = 320 - 250 * {{Cl|COS}}(ph) - ({{Cl|_WIDTH (function)|_WIDTH}}(alphaSprite&amp;) \ 2)
  y = 240 - 150 * {{Cl|COS}}(ph * 1.3) - ({{Cl|_HEIGHT}}(alphaSprite&amp;) \ 2)
  ph = ph + 0.03
  {{Cl|_PUTIMAGE}} , background&amp;, 0
  {{Cl|_PUTIMAGE}} (x, y), alphaSprite&amp;, 0
  {{Cl|_DISPLAY}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|LEN}}({{Cl|INKEY$}}) '' ''
{{CodeEnd}}{{small|Code by Zom-B}}
''Explanation:'''To make the alpha image, turn alpha blending off. Otherwise PSET blends the pixel to instead of making the sprite transparent.


{{PageSeeAlso}}
* [[_BLEND]]
* [[_BLEND (function)]]
* [[Images]]


{{PageNavigation}}