BlitImageAlphaBlendImages
BlitImageAlphaBlendImages ThisImage, Xpos, Ypos, BlendImage, AlphaLevel#
 
Parameters:

    ThisImage = The Index of the image you wish to draw
    Xpos = The X coordinate to draw this image
    Ypos = The Y coordinate to draw this image
    BlendImage = The index of the image to you wish to Alpha Subtract from the primary image before drawing
    AlphaLevel# = The amount of blending between the two image. Range from 0 to 1
Returns: NONE
 

     BlitImageAlphaBlendImages is most similar to the DrawAlphaImage function, except it has merge processing. What it does, is it takes two images (of the same size) and uses Variable Alpha Blending to blend them together before drawing the resulting blended pixels out. The Pixels are calculated by using the Alpha level parameter. Which controls amount of colour from either image that ends up in the output. The level ranges between 0 to 1, so setting it to 0.5 means we'll get a 50% blend between both. Regardless of blend level though neither source image is modified during the process.


      To create equivalent functionally, you'd need three images. The two images you wish to draw blended and third to store the temporary blended state. So we'd first copy the src image #1 to image 3, then blend src image 2 onto image 3 and finally draw image 3 to it's destination.


      The combined processing is not just to save you a few lines of code, it's actually a more optimal way of performing this action.



FACTS:


     * BlitImageAlphaBlendImages is only intend for drawing FX or AFX formatted surfaces.

     * BlitImageAlphaBlendImages doesn't support mask & alpha channel transparency.



 
Example Source: Download This Example
; Load a bigger font
  LoadFont "veranda",1,36
  
  
; Inlude the Blit Image functions
  #Include "BlitImage"
  
; Create an FX image the size of the screen
  MyImage=NewFXImage(GetScreenWidth(),GetScreenHeight())
  
  
; Create a second  FX image the size of the screen
; we'll be using to blend with our other image
  Backdrop=NewFXImage(GetScreenWidth(),GetScreenHeight())
  
; fill the backdrop with something so we can see it
  Tile=LoadNewFxImage("..\../Media/bg22.jpg")
  RenderToImage Backdrop
  TileImage Tile,0,0,false
  
  
; Set Fps of the program
  SetFPS 30
  
  
  Col=$803030
  
  
; Start of Demo loop
  Do
     
   ; redirect all drawing to this image
     RenderToImage MyImage
     
     
     If MouseButton()<>0 Then Col=RndRGB()
     
   ; draw a circle at the mouses current position
     CircleC MouseX(),MouseY(),100true,Col
     
   ; redirect all drawing to screen back buffer
     RenderToScreen
     
     
   ; Compoute blend level betwen the two images
     Alpha#=0.5+Sin(BlendAngle#)*0.5
     BlendAngle#=WrapAngle(BlendAngle#,5)
     
     
   ; To do combined Blit (copy) our Image.  This
   ; version Alpha Blends the pixels in the blend
   ; image (MyImage) from the backdrop image.
   ; The amount of blending is controlled via the Alpha parameter
     BlitImageAlphaBlendImages(BackDrop,0,0,MyImage,Alpha#)
     
     
   ; Display Message
     Text 0,0,"Cross Fading via BlitImageAlphaBlendImages"
     
   ; flip the back buffer to the front, so the user can see it
     Sync
     
  Loop
  
  
  
  
  
  
 
Related Info: BlitImageAlpha50Colour | BlitImageClear | Box | DrawAlphaImage | DrawImage | InkMode :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com