Hi, excuse the typo
This snippet provides an example of how to use a source code file I call the 'image code' which has been made to manage your images and provide image functionality frequently used in user interfaces.
It is currently a
WIP so more functions are soon to be added.
Here are a few of them ready to be used:
GetImageByFile - Get the image ID of the image loaded with the specified file
ImageBorderPaste - Create a border out a repeated image, and wrap it around a pasted one
ImageBorderPaste( iImage, iBorderImage, iX, iY, iOptions )
LoadTexture or LoadMatrixTexture - Load and apply textures
LoadTexture( iForObject, sFile$, iStage, bDuplicatesAllowed as boolean)
LoadMatrixTexture( iMatrix, sFile$, iAccross, iDown, bDuplicatesAllowed as boolean)
LoadImage or LoadNormalImage - Load image if not already loaded
LoadTexture( iForObject, sFile$, iStage, bDuplicatesAllowed as boolean)
LoadNormalImage( sFile$ )
Plus more...
Download the code and demos here with Media files
Demo Snippet
global TargetSyncRate = 60
global Delta#, FPS#
global CurrentDemo
autocam off
global MainObject = 1
make object sphere MainObject, 1, 48, 48
move object up MainObject, 0.7
//-------------
` Load texture for object, no need to apply it
LoadTexture( MainObject, "Texture1.jpg", 0, 1 )
color backdrop rgb( 20,30,70 )
make matrix 1, 200, 200, 50, 50
position matrix 1, -100, 0, -100
hide mouse
//-------------
` Load matrix texture and apply it
LoadMatrixTexture( 1, "Texture2.jpg", 1, 1, 1)
//-------------
` Load background image
global Backimage : Backimage = LoadImage( "bm_minibackground.png", IMAGE_TYPE_NORMAL, 1 )
` or
` global Backimage : Backimage = LoadImage( "bm_minibackground.png", 1 )
` or
` global Backimage : Backimage = LoadNormalImage( "bm_minibackground.png" )
global MyImage : MyImage = LoadImage( "image1.png", IMAGE_TYPE_NORMAL, 1 )
global MyBorderImage: MyBorderImage = LoadImage( "image2.png", IMAGE_TYPE_NORMAL, 1 )
//-------------
` This image will not be loaded again, but it shall be reapplied
DuplicateAllowed = 0
LoadTexture( MainObject, "Texture1.jpg", 0, DuplicateAllowed )
sync on : sync rate TargetSyncRate
set text font "Tahoma" : set text size 12
position camera 0, 2, -3
do
set cursor 0,0
paste image Backimage, 0, 0, 1
BorderEngine()
DoBorderDemo()
BorderFunctionInfo()
BorderInfo()
sync
loop
function BorderEngine()
ink rgb(10,20,40), 0
FPS# = screen fps()
Delta# = FPS# / TargetSyncRate
set text size 20
print " FPS: "; FPS#; " | Delta: "; str$( Delta#, 2 )
endfunction
function BorderFunctionInfo()
set text size 13
ink rgb(200,225,255), 0
text 200, 310, "Main image is " + str$(_image( MyImage ).fileSize / 1024 ) + " kb in file size"
text 200, 320, "Total images pasted in the last ImageBorderPaste() call was " + str$( DBorderElementPastes )
endfunction
function BorderInfo()
set cursor 330, 420
ink rgb(50,150,200), 0
text 340, 400, "Dark Basic Professional Example"
set text size 32
text 340, 415, "Image Kit - Borders"
endfunction
function DoBorderDemo()
set text size 13
lock pixels
ink rgb(200,225,255), 0
Paste Image MyImage, 180, 20
text 180, 5, "Standard Paste"
BorderPaste( MyImage, 340, 20, 1, 0 )
text 340, 5, "Border Paste"
BorderPaste( MyImage, 500, 20, 3, 1 )
text 500, 5, "Transparent Thickness 3"
ImageBorderPaste( MyImage, MyBorderImage, 180, 170, 0)
text 180, 155, "Image Border Paste"
ImageBorderPaste( MyImage, MyBorderImage, 340, 170, IBORDER_IMAGE_TRANSPARENT+IBORDER_BELOW+IBORDER_BOTTOM_TRANSPARENT+IBORDER_ALL_SIDES)
text 340, 155, "Below with transparent bottom"
ImageBorderPaste( MyImage, MyBorderImage, 500, 170, IBORDER_ABOVE+IBORDER_TOP+IBORDER_BOTTOM+IBORDER_ALL_TRANSPARENT)
text 500, 155, "Paste Top & Bottom"
unlock pixels
endfunction