Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loadImage ( filename )
- if ( not images[filename] ) then
- local path = ""
- if ( filename:sub ( 1, 4 ) ~= "img/" and filename:sub ( filename, 1, 1 ) ~= ":" ) then
- path = "img/"
- end
- local ext = string.lower ( filename:sub ( #filename - 2 ) )
- if ( ext == "yuv" ) then
- local file = fileOpen ( path .. filename, true )
- fileSetPos ( file, 4 )
- local contents = string.char ( 137 ) .. "PNG" .. fileRead ( file, fileGetSize ( file ) )
- fileClose ( file )
- images[filename] = dxCreateTexture ( contents )
- elseif ( ext == "tif" ) then
- local file = fileOpen ( path .. filename, true )
- local contents = string.char ( 255, 216, 255, 224 ) .. fileRead ( file, fileGetSize ( file ) )
- fileClose ( file )
- images[filename] = dxCreateTexture ( contents )
- else
- images[filename] = filename
- end
- end
- return images[filename]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement