LoadFxImage
LoadFxImage 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 data
Returns: NONE
 

      LoadFxImage reads an picture file from disc into PlayBasics image 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.

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



FACTS:


      * LoadFxImage supports various popular image formats including BMP, TGA JPEG, PNG as well PlayBASIC very own Image Format called PBI

      * Images loaded with LoadFxImage are stored in your computers System memory (FX format). The FX format doesn't support Alpha Channel. If you need Alpha either use LoadAFXImage or optional format parmeter in LoadImage to tell PB what format the image should be loaded in.

      * FX 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.

      * LoadFxImage 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.

      * LoadFxImage (and variants) can now load PBI / BMP / TGA + PNG's files directly from memory. To do so, the address of the data is given as a String in place of the filename with an & symbol prefix. eg LoadImage "&"+Str$(Ptr),Index - They can also be automatically loaded from the resource buffer. See #AddResource and look at the LoadNewImage command for an example.

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






Mini Tutorial:


     This examples loads an 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
  LoadFxImage "ThePictureYouWishToLoad.bmp",1
  
; Draw the Loaded image to the screen
  DrawImage 1,100,100,0
  
; Display the Screen and waits for user to press a key
  Sync
  WaitKey
  




 
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
  LoadFxImage Filename$,1
  
  
  SetFPS 30
  
  Do
     
     // Clear the screen
     Cls RGB(60,40,50)
     
     
     Max=12
     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+8
        
     Next
     
     
   ; Display the screen and wait for a key press
     Sync
  Loop
  
  
  
 
Related Info: CreateFxImage | CreateFxImageEx | CreateImage | DeleteImage | DrawImage | GetFreeImage | LoadImage | LoadNewFXImage | LoadNewImage | NewFxImage | NewImage | RenderToImage | SaveBitmap :
 


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