SavePBI
SavePBI Filename$, ImageIndex
 
Parameters:

    Filename$ = The name and path of the file you wish to save
    ImageIndex = The Index of the image you wish to save.
Returns: NONE
 

      * SavePBI will save and compress an image (in memory) to a file using an estimated chunk size. So the image saver tries to guess a suitable chunk size from the source images size. If you wanted to control the chunk size manually, then use the SavePBIex command instead.

      The chunk size refers to how the image will be broken down and stored in the output file. The PBI format is designed around the concept of colour reductions and chunk matching. The colour reduction tries to represent each section at the lowest bit rate possible, without losing colour accuracy. We call this the bit density, which can range from a lowest density of 1 bit all the way to 32 bit. On average most game images rarely need more than 8bit to 16bit density. The wonderful thing about PBI is that each zone can be of a different density, So areas with few colours take up less space than areas packed with unique colours.

      PBI formated files can be loaded using the normal LoadImage commands



FACTS:


      * PBI format is a lossless 32bit (ARGB) image format.

      * PBI format supports ALPHA channel.

      * PBI format is only available in PlayBASIC, so you can protect your image media by simply converting it to PBI.

      * PBI files generally load faster than other formats such as BMP,TGA,PNG,JPG.

      * PBI was designed to give light compression of images, that load quicker and archive well. Meaning the distribution size of your final game can be dramatically smaller with some fined tuned PBI conversions of your images. So the interesting thing about PBI files, is they tend to ZIP / RAR well very, often much better than storing them as BMP/TGA or PNG files. So if your after the smallest distribution size for your final game, then that's well worth experimenting.

      * Check the forums FAQ's for more of the in and outs of the formats development.





Mini Tutorial:


      This example includes the library, locates an image file that's should be found in the Help files (but might not) and then save this image out to your windows temp folder, reloads it and displays it.


  
  
; include the PlayBASIC Image Format library
  #Include "PBI"
  
; Try and locate a image from the help files
  path$=ProgramDir$()+"\Help\Commands/Media/Animations\Star\"
  
; Get the location of the star animation from in the help files
  Filename$=Path$+"star0001.bmp"
  
  
; check if the file exists
  If FileExist(Filename$)
     
   ; Load the image into memory using FreeImage.
     ThisImage=LoadNewImage(Filename$,2)
     
   ; draw this new image image to the screen
     DrawImage ThisImage,100,100,false
     
     
   ; Save this Image out to disc
     SaveName$=TempDir$()+GetFileName$(Filename$)
   ; Replace the BMP extensions with .PBI
     SaveName$=Replace$(SaveName$,".BMP",".PBI")
     
   ;               SavePBI  to the temp folder
     SavePBI SAveName$,ThisImage
     
     
   ; check if the file saved ??
     If FileExist(SaveName$)
        
      ; load the newly saved PBI as an FX image
        SameIMage=LoadNewImage(SAveName$,2)
        
      ; render to the screen
        DrawImage SameIMage,200,100,false
        
     EndIf
     
     
  Else
     
     Print "Couldn't find file:"
     Print Filename$
     
  EndIf
  
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  
  
  




 
Related Info: FreeImage_SaveBMP | FreeImage_SaveJPG | LoadImage | SaveBitmap :
 


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