LoadAFxImage
LoadAFxImage Filename$, ImageNumber
 
Parameters:

    Filename$ = The Filename and path of the image you wish to load
    ImageNumber = The Image Number where you wish to store this picture
Returns: NONE
 

     LoadAFxImage reads an picture file from disc into PlayBasics image memory. The AFX image format retains the pictures Alpha Channel. When rendered AFX formatted images don't use the mask colour (ImageMaskColour) to as a global transparency, rather they use the ALPHA channel intensities stored within each pixel as a level of transparency for each pixel.

      The Alpha intensities ranges from zero to 255. Zero being completely transparent and 255 being opaque (solid). Setting the alpha level of a pixel to say 127, will give an approximate 50/50 blend of the source pixel to the background pixel. Since the each pixel within the image has an alpha component, we can use different alpha levels through the image. Some parts of the image can be completely transparent, some can be translucent and others opaque.

      The common usage would be when images are drawn with anti aliased edges. In such images the paint rendering software softens the alpha channel on the edges around an image. So when it's drawn the image edges blend with the background giving us a smoother finish.




FACTS:


     * LoadAFxImage supports it's own PBI format plus various popular image formats that can include Alpha, such as BMP, TGA, PNG (See Images tutorial for image formats). LoadAFxImage prefers the images stored in 32bit for the best results.

     * Images loaded with LoadAFxImage are stored in your computers System memory. You must provide this command with the full folder path and filename of the image you wish to load, as well as a free (not currently in use) image index.


     * AFX formatted images are most suitable for real time rotation and pixel related effects. They also withstand breaks in service from your operating system, such as, when the user presses ALT-TAB, or when the OS decides to hibernate while your program is running. Which would destroy images stored in Video Memory.

     * LoadAFxImage does not change PlayBASIC current graphics output. So if you want to redirect drawing operations onto a freshly loaded image, you'll have to do this manually with RenderToImage command.


      LoadAFxImage is an named alternate to using the LoadImage function and setting the Format parameter to 8 (AFX format). Eg LoadImage Filename$,Index,8 is functionality the same as LoadAFxImage Filename$,Index , some programmers just prefer to use the FX version for code readability.


      * Note: We highly recommended you read the Images tutorials also!




Mini Tutorial:


      This examples loads n image from disc into image slot (index) #1 in memory, displays it to the screen at position 100x,100y, then waits for the user to press a key before ending.


  
; Load an image into image slot #1
  LoadAFxImage "ThisPictureYouWishToLoad.bmp",1
  
; Draw the Loaded image to the screen
  DrawImage 1,100,100,true
  
; Display the Screen and waits for user to press a key
  Sync
  WaitKey
  




 
Example Source: Download This Example
  // The filename of the image
  FileName$="..\../Media/PlayBasicSig.png"
  
  // Load the image as AFX format
  LoadAFxImage Filename$,1
  
  
  // Load the image as FX format
  LoadFxImage Filename$,2
  
  
  // Clear the screen
  Cls RGB(120,130,160)
  
  
  // Draw the AFX image to the display
  DrawImage 1,150,100,true
  
  
  // Draw the FX image to the display
  DrawImage 2,150,300,true
  
  
  // Show the screen and wait for a key press
  Sync
  Waitke
 
Related Info: CreateFxImage | CreateFxImageEx | CreateImage | DeleteImage | DrawImage | GetFreeImage | LoadFxImage | LoadImage | LoadNewAFxImage | LoadNewFXImage | LoadNewImage | NewFxImage | NewImage | RenderToImage | SaveBitmap :
 


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