Difference between revisions of "LOADIMAGE"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 1: Line 1:
The '''_LOADIMAGE''' function returns an image handle for a graphic file image.  
+
The '''_LOADIMAGE''' function loads an image into memory and returns an image handle for a graphic file image.  
  
  
Line 8: Line 8:
 
{{PageDescription}}
 
{{PageDescription}}
 
* File types supported:  BMP, JPG, PNG, GIF, PNM, XPM, XCF, PCX, TIF, LBM, and TGA. A path can also be given.
 
* File types supported:  BMP, JPG, PNG, GIF, PNM, XPM, XCF, PCX, TIF, LBM, and TGA. A path can also be given.
* The ''Mode&'' can be a legacy SCREEN mode, 256 colors or 32 bit or omitted if using the current screen mode.
+
* The ''Mode&'' can imitate a legacy SCREEN mode or designate 256(8 bit)or 32 bit or omitted if using the current screen mode.
 +
* Some images may not load when a mode value is designated. Try loading it without a ''mode&'' designation.
 +
* Images can be made into a program [[SCREEN (statement)|SCREEN]] or page adopting the size and palette settings or placed using [[_PUTIMAGE]].
 
* When you are in SCREEN 0 a ''mode&'' '''must''' be designated. When loading an [[_ICON]] use 32 for the mode.
 
* When you are in SCREEN 0 a ''mode&'' '''must''' be designated. When loading an [[_ICON]] use 32 for the mode.
 
* Returns -1 as an invalid handle if it could not load the image. Valid {{KW|LONG}} handle returns are less than -1.
 
* Returns -1 as an invalid handle if it could not load the image. Valid {{KW|LONG}} handle returns are less than -1.
* Some images may not load when a mode value is designated. Try loading it without a ''mode&'' designation.
+
* '''It is IMPORTANT to free unused or discarded images with [[_FREEIMAGE]] to prevent PC memory overflow errors!'''
* It is IMPORTANT to free unused or discarded images with {{KW|_FREEIMAGE}} to prevent memory overflow errors!
 
  
  
Line 52: Line 53:
  
 
{{PageSeeAlso}}
 
{{PageSeeAlso}}
*{{KW|_FREEIMAGE}}, {{KW|_PUTIMAGE}}, {{KW|_NEWIMAGE}}, {{KW|_COPYIMAGE}}, {{KW|_PRINTIMAGE}} (printer)
+
*[[_FREEIMAGE]], [[_PUTIMAGE]], [[_NEWIMAGE]], [[_COPYIMAGE]], [[_PRINTIMAGE]] (printer)
*{{KW|_PALETTECOLOR (function)}}, {{KW|_COPYPALETTE}}, {{KW|_ICON}}
+
*[[_PALETTECOLOR (function)]], [[_COPYPALETTE]], [[_ICON]]
*{{KW|SCREEN (statement)}}
+
*[[SCREEN (statement)]]
*{{KW|Bitmaps}}, {{KW|Icons and Cursors}}, {{KW|GIF Images}}, {{KW|JPG Images}}
+
*[[Bitmaps]], [[Icons and Cursors]], [[GIF Images]], [[JPG Images]]
  
  

Revision as of 21:14, 1 February 2011

The _LOADIMAGE function loads an image into memory and 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, and TGA. A path can also be given.
  • The Mode& can imitate a legacy SCREEN mode or designate 256(8 bit)or 32 bit or omitted if using the current screen mode.
  • Some images may not load when a mode value is designated. Try loading it without a mode& designation.
  • Images can be made into a program SCREEN or page adopting the size and palette settings or placed using _PUTIMAGE.
  • When you are in SCREEN 0 a mode& must be designated. 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 PC 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