|
LoadNewImage | ||
ImageIndex = LoadNewImage(Filename$, [Format =1]) | ||
Parameters: Filename$ = The Filename and path of the Image you wish to load [Format =1] = Format of loaded image, format defaults to Video (1), use 2 for FX and 8 for AFX |
||
Returns: ImageIndex = The Image Index where this picture data was load to |
||
LoadNewImage reads an Image file from disc into your computers memory. Unlike LoadImage all you need to provide LoadNewImage is the path and filename of the Image, It will return the ImageIndex for you. Image Types: PlayBASIC has various types of Image types, each one suited for different uses. 1 = Video - Image is created in Video Memory 2 = FX - System Memory Image 8 = AFX - System Memory Image With Alpha Channel To learn more about images, we recommend you read the CreateImage and Images tutorials FACTS: * LoadNewImage supports various popular image formats including BMP, TGA JPEG, PNG as well PlayBASIC very own Image Format called PBI * LoadNewImage does not change PlayBASIC current graphics output. So if you want to redirect drawing operations to an Image, you'll have to do this manually with RenderToImage. * Note: We highly recommended you read the Images tutorials also! * LoadNewImage (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 Index=LoadNewImage( "&"+Str$(Ptr)) - They can also be automatically loaded from the resource buffer. See #AddResource and Example #2 bellow Mini Tutorial #1: This examples loads an Image from disc into a free Image index, displays it to the screen at 100x,100y then waits for the user to press a key before ending
Sample Output Mini Tutorial #2: LoadNewImage From Memory This example shows how we can use the LoadNewImage command to load from memory and not just disc. To demonstrate this, we first need to store an image in memory to load. The image load from memory routines expect a pointer to a the size of the image (stored as an integer) followed by the the image data. So an images that's 10000 bytes long, requires an integer header making it 10004 bytes in memory. In order to load it, we would give the loader the address of the size integer and as long as the image data is after in, it should load ok. Loading images from memory is normally used for data security purposes, which is where a programmer would store first pre-process their media files and store them in an encrypted/scrambled state. The program/game then loads the encrypted media files into memory, decrypts/descrambles the data in memory and then loads that media from memory directly. This saves ever having to store the decrypted media data in a temporary state on disc.
|
||
Example Source: Download This Example
|
Related Info: | CreateImage | DeleteImage | DrawImage | LoadAFxImage | LoadFxImage | LoadImage | LoadNewAFxImage | LoadNewFXImage | NewImage | RenderToImage | SaveBitmap : |
|
|||||||||||||||||||||||||||||||||||||||
(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com |