QBasic / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

File Infomation Viewer

June 18 2003 at 3:11 AM
JT  (Login JT_Man)

 
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ JT's File Infomation Viewer ³
' ³ June 15, 2003 - 11:07am ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
'

DECLARE SUB ReadMPEG (HEADER&)
DECLARE FUNCTION SDBC$ (a&)
DECLARE SUB ReadWAV ()
DECLARE SUB ReadID3 ()
DECLARE SUB ReadRiff ()
DECLARE SUB ReadEXE ()
DECLARE SUB ReadGIF ()
DECLARE SUB ReadBMP ()
c$ = COMMAND$


HEADER$ = SPACE$(128)
OPEN c$ FOR BINARY AS #1
GET #1, , HEADER$
CLS

'More file ino types coming soon....

IF MID$(HEADER$, 1, 2) = "BM" THEN ReadBMP
IF MID$(HEADER$, 1, 3) = "ID3" THEN ReadID3
IF MID$(HEADER$, 1, 2) = "MZ" THEN ReadEXE
IF MID$(HEADER$, 1, 6) = "GIF87a" THEN ReadGIF
IF MID$(HEADER$, 1, 6) = "GIF89a" THEN ReadGIF
IF MID$(HEADER$, 1, 4) = "RIFF" THEN ReadRiff
IF MID$(HEADER$, 7, 4) = "JFIF" THEN
PRINT : PRINT
COLOR 15: PRINT "JPEG Image File": COLOR 7: PRINT "(Jpeg File data coming soon)"
END IF
CLOSE 1

SUB ReadBMP
SEEK #1, 1
BMPHeader$ = SPACE$(54)
GET #1, , BMPHeader$
PRINT
PRINT
IF CVL(MID$(BMPHeader$, 15, 4)) = 40 THEN COLOR 15: PRINT "Windows BMP Image File " + CHR$(34) + ".BMP" + CHR$(34)
IF CVL(MID$(BMPHeader$, 15, 4)) = 12 THEN COLOR 15: PRINT "OS/2 BMP Image File " + CHR$(34) + ".BMP" + CHR$(34)
PRINT
COLOR 9: PRINT "Image Width: ", : COLOR 7: PRINT CVL(MID$(BMPHeader$, 19, 4))
COLOR 9: PRINT "Image Height:", : COLOR 7: PRINT CVL(MID$(BMPHeader$, 23, 4))

COLOR 9: PRINT "Color Depth:", : COLOR 7: PRINT CVI(MID$(BMPHeader$, 29, 2)); "bit ("; CLNG(2 ^ CVI(MID$(BMPHeader$, 29, 2))); "colors )"
COLOR 9: PRINT "Image Size: ", : COLOR 7: PRINT CVL(MID$(BMPHeader$, 35, 4)); "Bytes"
COLOR 7: PRINT : PRINT
END SUB

SUB ReadEXE
SEEK #1, 1
PRINT : PRINT
GET #1, &H19, exetype%
IF exetype% >= &H40 THEN COLOR 15: PRINT "Windows Executable " + CHR$(34) + ".EXE" + CHR$(34)
IF exetype% < &H40 THEN COLOR 15: PRINT "MS-DOS Executable " + CHR$(34) + ".EXE" + CHR$(34)
COLOR 7
IF exetype% >= &H40 THEN
GET #1, &H3D, d%
SEEK #1, d% + 1: dd% = d%
GET #1, , Signature%
GET #1, , b%': LinkerVersion! = VAL(STR$(ASC(MID$(b$, 1, 1))) + "." + STR$(ASC(MID$(b$, 2, 1))))
SEEK #1, &H3F + dd% + 1

GET #1, , d%
winver% = ASC(MID$(MKI$(d%), 2, 1))
win$ = "Non-Windows (MS-DOS)"
SELECT CASE winver%
CASE 1
win$ = "Any Windows"
CASE 3
win$ = "Windows 3 / 3.1"
CASE 4
win$ = "Windows 95 / 98 / NT4"
CASE 5
win$ = "Windows 2000 / XP"

END SELECT
COLOR 9: PRINT "Expected OS Version: "; : COLOR 7: PRINT win$
COLOR 7
PRINT "(more to come soon)"
PRINT : PRINT
END IF
' 228 268
' 1505 91


END SUB

DEFINT A-Z
SUB ReadGIF
SEEK #1, 1
a$ = " ": GET #1, , a$
GET #1, , TotalX%: GET #1, , TotalY%
g$ = " ": GET #1, , g$: a% = ASC(g$)

PRINT
PRINT
IF a$ = "GIF87a" THEN COLOR 15: PRINT "Compuserve Graphics interchange format image " + CHR$(34) + ".GIF" + CHR$(34)
IF a$ = "GIF89a" THEN COLOR 15: PRINT "Compuserve Graphics interchange format image + transperency " + CHR$(34) + ".GIF" + CHR$(34)
PRINT
COLOR 9: PRINT "Image Width: ", : COLOR 7: PRINT TotalX%
COLOR 9: PRINT "Image Height:", : COLOR 7: PRINT TotalY%
COLOR 9: PRINT "Colors Used:", : COLOR 7: PRINT a%

PRINT : PRINT

END SUB

DEFSNG A-Z
SUB ReadID3
WIDTH 80, 50
COLOR 15: PRINT "MP3 Sound File " + CHR$(34) + ".mp3" + CHR$(34): COLOR 7
PRINT

id3$ = SPACE$(8192)
GET #1, 1, id3$

COLOR 3: PRINT "ID3v2 Tag Info"
COLOR 9: PRINT "Track: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "TRCK") + 11, CVL(MID$(id3$, INSTR(id3$, "TRCK") + 7, 4)) - 1)
COLOR 9: PRINT "Title: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "TIT2") + 11, CVL(MID$(id3$, INSTR(id3$, "TIT2") + 7, 4)) - 1)
COLOR 9: PRINT "Artist: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "TPE1") + 11, CVL(MID$(id3$, INSTR(id3$, "TPE1") + 7, 4)) - 1)
COLOR 9: PRINT "Album: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "TALB") + 11, CVL(MID$(id3$, INSTR(id3$, "TALB") + 7, 4)) - 1)
COLOR 9: PRINT "Year: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "TYER") + 11, CVL(MID$(id3$, INSTR(id3$, "TYER") + 7, 4)) - 1)
COLOR 9: PRINT "Genre: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "TCON") + 11, CVL(MID$(id3$, INSTR(id3$, "TCON") + 7, 4)) - 1)
COLOR 9: PRINT "Commments: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "COMM") + 11, CVL(MID$(id3$, INSTR(id3$, "COMM") + 7, 4)) - 1)
COLOR 9: PRINT "Composer: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "TCOM") + 11, CVL(MID$(id3$, INSTR(id3$, "TCOM") + 7, 4)) - 1)
COLOR 9: PRINT "Original Artist: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "TOPE") + 11, CVL(MID$(id3$, INSTR(id3$, "TOPE") + 7, 4)) - 1)
COLOR 9: PRINT "Copyright: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "TCOP") + 11, CVL(MID$(id3$, INSTR(id3$, "TCOP") + 7, 4)) - 1)
COLOR 9: PRINT "URL: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "WXXX") + 11, CVL(MID$(id3$, INSTR(id3$, "WXXX") + 7, 4)) - 1)
COLOR 9: PRINT "Encoded By: "; : COLOR 7: PRINT MID$(id3$, INSTR(id3$, "TENC") + 11, ASC(MID$(id3$, INSTR(id3$, "TENC") + 7, 1)) - 1)
PRINT
COLOR 3: PRINT "MPEG Header at: "; : COLOR 7: PRINT INSTR(id3$, CHR$(255)) - 1

PRINT : PRINT "Searching File For a Header..."
'Search file
FOR q = 1 TO 8100

'Get the 4-byte header
temp1& = CVL(MID$(id3$, q, 4))
t$ = ""
FOR i = 11 TO 0 STEP -1
IF temp1& MOD 2 = 1 THEN
t$ = t$ + "1": temp1& = INT(temp1& / 2)
ELSE
t$ = t$ + "0": temp1& = INT(temp1& / 2)
END IF
NEXT
IF INSTR(t$, "0") <= 0 THEN q& = q: EXIT FOR
NEXT
PRINT q&
t& = CVL(MID$(id3$, q&, 4))

ReadMPEG (t&)


END SUB

SUB ReadMPEG (HEADER&)


'Get the 4-byte header
temp1& = HEADER&
t$ = ""
FOR i = 32 TO 0 STEP -1
IF temp1& MOD 2 = 1 THEN
t$ = t$ + "1": temp1& = INT(temp1& / 2)
ELSE
t$ = t$ + "0": temp1& = INT(temp1& / 2)
END IF
NEXT
'FOR i = 32 TO 1 STEP -1: r$ = r$ + MID$(t$, i, 1): NEXT

PRINT t$


END SUB

SUB ReadRiff
SEEK #1, 9
r$ = SPACE$(8)
GET #1, 9, r$

IF MID$(r$, 1, 4) = "WAVE" THEN
ReadWAV


END IF

IF MID$(r$, 1, 3) = "AVI" THEN
COLOR 15: PRINT "AVI Video File": COLOR 7
END IF
END SUB

SUB ReadWAV
COLOR 15: PRINT "WAVE Sound File " + CHR$(34) + ".WAV" + CHR$(34)
head$ = SPACE$(58)
GET #1, 1, head$
audioFormat% = CVI(MID$(head$, 21, 2))

SELECT CASE audioFormat%
CASE 1
COLOR 9: PRINT "Sound Format: "; : COLOR 7: PRINT "PCM"
CASE 2
COLOR 9: PRINT "Sound Format: "; : COLOR 7: PRINT "Microsoft ADPCM"
CASE 17
COLOR 9: PRINT "Sound Format: "; : COLOR 7: PRINT "IMA ADPCM"
CASE 34
COLOR 9: PRINT "Sound Format: "; : COLOR 7: PRINT "DSP Group Truespeech"
CASE 49
COLOR 9: PRINT "Sound Format: "; : COLOR 7: PRINT "GSM 6.10"
CASE 85
COLOR 9: PRINT "Sound Format: "; : COLOR 7: PRINT "MPEG Layer 3 (MP3)"
CASE ELSE
COLOR 9: PRINT "Sound Format: "; : COLOR 7: PRINT "Unknown Format"
END SELECT

COLOR 9: PRINT "Channels: "; : COLOR 7: PRINT CVI(MID$(head$, 23, 2)); : IF CVI(MID$(head$, 23, 2)) = 2 THEN PRINT " (Stereo)" ELSE PRINT " (Mono)"
COLOR 9: PRINT "Freq: "; : COLOR 7: PRINT CVL(MID$(head$, 25, 4)); "Khz"
COLOR 9: PRINT "Bits Per Sample: "; : COLOR 7: PRINT CVI(MID$(head$, 35, 2))
COLOR 9: PRINT "Kb / Second: "; : COLOR 7: PRINT INT(CVL(MID$(head$, 29, 4)) / 1024); "kb"


length! = CVL(MID$(head$, 5, 4)) / CVL(MID$(head$, 29, 4))
COLOR 9: PRINT "Length: "; : COLOR 7: PRINT USING "###.##"; length!;
PRINT " seconds"


END SUB

 
 Respond to this message   
 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement