PrepareAFXimage
PrepareAFXimage ImageNumber
 
Parameters:

    ImageNumber = The index identifier of this image
Returns: NONE
 

     PrepareAFXimage converts an image into a new pixel format that support alpha channel. Once converted it can be used with real time effects like Alpha Blending and Rotation just to name a few.

      We highly recommended reading the Images and Sprites tutorials



FACTS:


      * AFX format images are always 32bit, with a ARGB Pixel Format.

      * AFX formatted images are stored in system memory. These images use ALPHA channel transparency. Alpha Channel overrides MaskColour and lets you control the transparency of each pixel within the image.


 
Example Source: Download This Example
; Init a variable FileName$ to store the
; location and name of the image we wish to load
  FileName$="..\../Media/bubble_64x64.bmp"
  
; Load this file into IMage slot #1
  LoadImage Filename$,1
  
  
  //  Convert Image #1 to AFX image.
  PrepareAFXImage 1
  
  // Since the image was loaded without Alpha the channel,
  //  we'll create our own, just for fun.
  
  RenderToImage 1
  For ylp=0 To GetImageHeight(1)-1
     For xlp=0 To GetImageWidth(1)-1
        ThisRGB=Point(Xlp,ylp) & $00ffffff
        Alpha=255-(ylp*4)     ;     RgbGreyScale(Thisrgb)+40
        If thisRGB
           DotC Xlp,ylp,Alpha* $1000000 + ThisRgb
        EndIf
     Next
  Next
  
  
  RenderToScreen
  
  
  Screen=NewFXImage(GetScreenWidth(),GetScreenHeight())
  
  
;     setfps 30
  
  Do
     RenderToImage Screen
     
     // Clear the screen
     c1=RGB(250,40,50)
     c2=RGB(160,240,50)
     ShadeBox 0,0,GetScreenWidth(),GetScreenHeight(),c1,c2,c1,c2
     
     Max=5
     BaseAngle#=WrapAngle(Baseangle#,1)
     For lp=1 To Max
        // calc the angle that this ball will be
        Angle#=BaseAngle#+(lp*(360.0/max))
        
        // calc the screen position
        x#=GetScreenWidth()/2
        y#=GetScreenHeight()/2
        x#=x#+Cos(Angle#)*200
        y#=y#+Sin(Angle#)*180
        
        // draw rotated image with Bi-linear filtering
        DrawRotatedImage 1,x#,y#,angle#,2,2,-32,-32,true
        
     Next
     
     
   ;
     
     RenderToScreen
     DrawImage screen,0,0,false
     
   ; Display the screen and wait for a key press
     Sync
  Loop
  
 
Related Info: CreateFxImage | CreateFxImageEx | DrawAlphaImage | DrawRotatedImage | LoadFxImage | NewFxImage | PrepareFXimage :
 


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