Difference between revisions of "ALPHA"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 14: Line 14:
 
* If the image specified by {{Parameter|imageHandle&}} does not use a palette, {{Parameter|colour&}} is the color value used to retrieve the alpha level.
 
* If the image specified by {{Parameter|imageHandle&}} does not use a palette, {{Parameter|colour&}} is the color value used to retrieve the alpha level.
 
* If {{Parameter|imageHandle&}} is an invalid handle, an [[ERROR Codes|Illegal function call]] error will occur.
 
* If {{Parameter|imageHandle&}} is an invalid handle, an [[ERROR Codes|Illegal function call]] error will occur.
*_RED32, _GREEN32, _BLUE32 and _ALPHA32 are all equivalent to _RED, _GREEN, _BLUE and _ALPHA but they are highly optimized and only accept a 32-bit color (B8:G8:R8:A8). Using these in your code (opposed to dividing then ANDing 32-bit color values manually) makes your code easy to read also.
+
*[[_RED32]], [[_GREEN32]], [[_BLUE32]] and [[_ALPHA32]] are all equivalent to [[_RED]], [[_GREEN]], [[_BLUE]] and [[_ALPHA]] but they are highly optimized and only accept a 32-bit color (B8:G8:R8:A8). Using these in your code (opposed to dividing then ANDing 32-bit color values manually) makes your code easy to read also.
 
* '''NOTE: Default 32 bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0)! Use [[CLS]] to make the black opaque!'''
 
* '''NOTE: Default 32 bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0)! Use [[CLS]] to make the black opaque!'''
  
Line 36: Line 36:
 
* [[_RED32]], [[_GREEN32]]. [[_BLUE32]]
 
* [[_RED32]], [[_GREEN32]]. [[_BLUE32]]
 
* [[_CLEARCOLOR]], [[_CLEARCOLOR (function)]]
 
* [[_CLEARCOLOR]], [[_CLEARCOLOR (function)]]
* [[COLOR]], [[Images]]
+
* [[CLS]], [[COLOR]], [[Images]]
  
  
 
{{PageNavigation}}
 
{{PageNavigation}}

Revision as of 09:17, 17 June 2011

The _ALPHA function returns the alpha channel transparency level of a color value used on a screen page or image.


Syntax

result& = _ALPHA(colour& [, imageHandle&])


Description

  • If imageHandle& is omitted, it is assumed to be the current write page.
  • If the image specified by imageHandle& uses a palette, colour& is the palette index of the color value used.
    • Color values that match the clear color set by _CLEARCOLOR have an alpha level of 0 (zero).
    • Color values that don't match the clear color have an alpha level of 255.
    • If colour& value is outside of the range 0 to 255, an Illegal function call error will occur.
  • If the image specified by imageHandle& does not use a palette, colour& is the color value used to retrieve the alpha level.
  • If imageHandle& is an invalid handle, an Illegal function call error will occur.
  • _RED32, _GREEN32, _BLUE32 and _ALPHA32 are all equivalent to _RED, _GREEN, _BLUE and _ALPHA but they are highly optimized and only accept a 32-bit color (B8:G8:R8:A8). Using these in your code (opposed to dividing then ANDing 32-bit color values manually) makes your code easy to read also.
  • NOTE: Default 32 bit backgrounds are clear black or _RGBA(0, 0, 0, 0)! Use CLS to make the black opaque!


Example: Finding the transparency of a 32 bit screen mode's background.

SCREEN _NEWIMAGE(640, 480, 32) x = POINT(1, 1) PRINT "Alpha ="; _ALPHA(x); "Press a key to use CLS!" K$ = INPUT$(1) CLS x = POINT(1, 1) PRINT "CLS Alpha ="; _ALPHA(x)

Explanation: You need to set the ALPHA value to 255 using CLS to make the black background opaque!


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page