JPGの幅と高さを取得するコードは次のとおりです。
//JPG
li_file = FileOpen(as_file_name, StreamMode!, Read! )
If li_file = -1 Then Return 0
li_read = FileRead (li_file, lb_data)
If String (BlobMid (lb_Data, 1,3)) = Char (255) + Char (216) + Char (255) Then //JPG
ll_DataLen = Len(lb_Data)
ll_DataPos = 3
ll_FilePos = 3
lb_LoopFlag = true
Do While lb_LoopFlag
ll_DataPos = ll_DataPos + 1
ll_FilePos = ll_FilePos + 1
li_Char1 = Asc (String (BlobMid(lb_Data, ll_DataPos, 1)))
li_Char2 = Asc (String (BlobMid(lb_Data, ll_DataPos + 1, 1)))
If li_Char1 = 255 And li_Char2 <> 255 Then
If li_Char2 >= 192 And li_Char2 <= 195 Then
al_width = Asc (String (BlobMid (lb_Data, ll_DataPos + 7,1))) * 256 + Asc (String (BlobMid (lb_Data, ll_DataPos + 8,1)))
al_height= Asc (String (BlobMid (lb_Data, ll_DataPos + 5,1))) * 256 + Asc (String (BlobMid (lb_Data, ll_DataPos + 6,1)))
lb_LoopFlag= False
Else
ll_FilePos = ll_FilePos + Asc (String (BlobMid(lb_Data, ll_DataPos + 3, 1))) + Asc (String (BlobMid(lb_Data, ll_DataPos + 2, 1))) + 1
If ll_FilePos > ll_FileLength Then
Exit
Else
FileSeek(li_file, ll_FilePos)
FileRead(li_file, lb_Data)
ll_DataLen = Len(lb_Data)
ll_DataPos = 0
End If
End If
End If
If ll_DataPos = ll_DataLen - 9 And lb_LoopFlag = True Then
ll_FilePos = ll_FilePos - 9
FileSeek(li_file, ll_FilePos)
FileRead(li_file, lb_Data)
ll_DataLen = Len(lb_Data)
ll_DataPos = 0
End If
If ll_FilePos >= ll_FileLength Then
lb_LoopFlag = False
End If
Loop
End If
GIFの場合:
al_width = Asc(String (BlobMid (lb_Data, 7,1))) + Asc (String (BlobMid (lb_Data, 8,1))) * 256
al_height = Asc (String (BlobMid (lb_Data, 9,1))) + Asc (String (BlobMid (lb_Data, 10,1))) * 256