2013/02/14

Image File Loader

Display all supported image files sequentially. At that time, it displays each type.
// Graphic file display
// for X-BASIC for iOS v1.7 later
width(64)
//
vpriority(TPAGE,GPAGE0,GPAGE1,GPAGE2,GPAGE3)
vpage(B_TPAGE or B_GPAGE0 or B_GPAGE1 or B_GPAGE2 or B_GPAGE3,YES)
apage(GPAGE0)
//
// get all file list
dim str fileList(256):// max file
int allcnt
int i,ret
str ext
//
// extension (case sensitive)
// Regular expression
ext="PIC|pic|PNG|png|JPG|jpg|CUT|cut":
allcnt=files(fileList,"",ext,YES,FILES_FILE,YES)
if allcnt<=0 then {
 locate(0,0)
 print localizedString("画像ファイルがありません":"Graphic file not found.")
} else {
 for i=0 to allcnt-1
  locate(0,0):print fileList(i)
  wipe()
  str pext=pathExtension(fileList(i))
  strupr(pext)
  switch pext
   case "PIC"
    ret=picLoader(128,128,fileList(i))
    if ret<>0 then {
     locate(0,1):print "Error=";ret
    }
    break
   case "CUT"
    ret=cutLoader(128,128,fileList(i))
    if ret<>0 then {
     locate(0,1):print "Error=";ret
    }
    break
   default:
    ret=imgLoad(128,128,0,0,fileList(i))
    break
  endswitch
  hitKey()
 next
}
end
//---------
func hitKey()
 setFunctionKey(0,localizedString("ここを押してください","Hit This Button"),'!')
 displayFunctionKey(YES,0,0)
 while inkey()=0
 endwhile
 cls()
 displayFunctionKey(NO,0,0)
endfunc
//---------
func str localizedString(js;str,es;str)
 if isLocalizeJapan() then return(js)
 return (es)
endfunc
//---------
Zip file including sample image files is here : XBpicloader.zip

picLoader.bas

picLoaderSc.bas

No comments:

Post a Comment