File Types

BlitzPlus Forums/BlitzPlus Beginners Area/File Types

JBR(Posted 2007) [#1]
Hi,

file_in$ = requestfile$( "Load File", "jpg,bmp,png" )
loadimage file_in$

Because the above also includes 'All Files' I'd only like to load if jpg,bmp,png files.
i.e. is there a way to check the type of a file?

Thanks
Jim


b32(Posted 2007) [#2]
You could check the extention ?
file_in$ = Trim$(Lower$(file_in$))
if right$(file_in$, 4) = ".jpg" then print "This is a .jpg"

Else, you could read the file itself and look for the header: BMP starts with BM something, JPG starts with 2 bytes, then JFIF.
ff = ReadFile("c:\_xfiles\grass.bmp")

For i = 0 To 10
c = ReadByte(ff)
Print Chr$(c)
Next

CloseFile ff
WaitKey()
End



Matty(Posted 2007) [#3]
As far as I know this

FileName$=RequestFile("Image File","jpg;*.png;*.bmp")



will only let you search for files with extensions jpg,bmp or png - I don't get an option for 'all files'.


JBR(Posted 2007) [#4]
Thanks guys,

I used both methods as 'RequestFile' still allows the user to select file type as All Files from the lower menu.

Thanks
Jim