Advertisement
qaisjp

ffs

Jun 22nd, 2013 (edited)
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function loadImage ( filename )
  2.   if ( not images[filename] ) then
  3.     local path = ""
  4.     if ( filename:sub ( 1, 4 ) ~= "img/" and filename:sub ( filename, 1, 1 ) ~= ":" ) then
  5.       path = "img/"
  6.     end
  7.     local ext = string.lower ( filename:sub ( #filename - 2 ) )
  8.     if ( ext == "yuv" ) then
  9.       local file = fileOpen ( path .. filename, true )
  10.       fileSetPos ( file, 4 )
  11.       local contents = string.char ( 137 ) .. "PNG" .. fileRead ( file, fileGetSize ( file ) )
  12.       fileClose ( file )
  13.       images[filename] = dxCreateTexture ( contents )
  14.     elseif ( ext == "tif" ) then
  15.       local file = fileOpen ( path .. filename, true )
  16.       local contents = string.char ( 255, 216, 255, 224 ) .. fileRead ( file, fileGetSize ( file ) )
  17.       fileClose ( file )
  18.       images[filename] = dxCreateTexture ( contents )
  19.     else
  20.       images[filename] = filename
  21.     end
  22.   end
  23.   return images[filename]
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement