Difference between revisions of "LOADIMAGE"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 17: Line 17:
 
''Example 1:''  Already in SCREEN 13 and want computer to match the 32-bit jpg/etc.  
 
''Example 1:''  Already in SCREEN 13 and want computer to match the 32-bit jpg/etc.  
 
colors to the current palette:
 
colors to the current palette:
 
+
{{CodeStart}} '' ''
{{CodeStart}}
 
 
 
 
{{Cl|SCREEN (statement)|SCREEN}} 13
 
{{Cl|SCREEN (statement)|SCREEN}} 13
 
i& = {{Cl|_LOADIMAGE}}("mypic.jpg")  
 
i& = {{Cl|_LOADIMAGE}}("mypic.jpg")  
{{Cl|_PUTIMAGE}}, i&
+
{{Cl|_PUTIMAGE}}, i& '' ''
 +
{{CodeEnd}}
  
{{CodeEnd}}
 
  
 
''Example 2:'' Already in SCREEN 13 but want to load an 8-bit image and adopt its  
 
''Example 2:'' Already in SCREEN 13 but want to load an 8-bit image and adopt its  
 
palette as the current palette:
 
palette as the current palette:
 
+
{{CodeStart}} '' ''
{{CodeStart}}
 
 
 
 
{{Cl|SCREEN (statement)|SCREEN}} 13
 
{{Cl|SCREEN (statement)|SCREEN}} 13
 
i& = {{Cl|_LOADIMAGE}}("mypic256col.bmp", 256)
 
i& = {{Cl|_LOADIMAGE}}("mypic256col.bmp", 256)
 
{{Cl|_COPYPALETTE}} i&, 0
 
{{Cl|_COPYPALETTE}} i&, 0
{{Cl|_PUTIMAGE}}, i&
+
{{Cl|_PUTIMAGE}}, i& '' ''
 +
{{CodeEnd}}
  
{{CodeEnd}}
 
  
 
''Example 3:'' Want to display an image in 32-bit color using its resolution:
 
''Example 3:'' Want to display an image in 32-bit color using its resolution:
 
+
{{CodeStart}} '' ''
{{CodeStart}}
 
 
 
 
i& = {{Cl|_LOADIMAGE}}("mypic.jpg", 32)
 
i& = {{Cl|_LOADIMAGE}}("mypic.jpg", 32)
{{Cl|SCREEN (statement)|SCREEN}} i&
+
{{Cl|SCREEN (statement)|SCREEN}} i& '' ''
 
 
 
{{CodeEnd}}
 
{{CodeEnd}}
  
  
 
''See Examples:''
 
''See Examples:''
 
 
*{{KW|SAVEIMAGE}} (QB64 Image to Bitmap SUB by Galleon)
 
*{{KW|SAVEIMAGE}} (QB64 Image to Bitmap SUB by Galleon)
  

Revision as of 18:38, 10 January 2011

The _LOADIMAGE function returns an image handle for a graphic file image.


Syntax

handle& = _LOADIMAGE& (filename$[, mode&])


Description

  • File types supported: BMP, JPG, PNG, GIF, PNM, XPM, XCF, PCX, TIF, LBM, TGA,
  • Mode& can be 256 colors or 32 bit or omitted if using the current screen mode.
  • When you are in SCREEN 0 then a mode& must be used. When loading an _ICON use 32 for the mode.
  • Returns -1 as an invalid handle if it could not load the image. Valid LONG handle returns are less than -1.
  • It is IMPORTANT to free unused or discarded images with _FREEIMAGE to prevent memory overflow errors!


Examples

Example 1: Already in SCREEN 13 and want computer to match the 32-bit jpg/etc. colors to the current palette:

SCREEN 13 i& = _LOADIMAGE("mypic.jpg") _PUTIMAGE, i&


Example 2: Already in SCREEN 13 but want to load an 8-bit image and adopt its palette as the current palette:

SCREEN 13 i& = _LOADIMAGE("mypic256col.bmp", 256) _COPYPALETTE i&, 0 _PUTIMAGE, i&


Example 3: Want to display an image in 32-bit color using its resolution:

i& = _LOADIMAGE("mypic.jpg", 32) SCREEN i&


See Examples:

  • SAVEIMAGE (QB64 Image to Bitmap SUB by Galleon)


See also





Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page