data: file_tab type standard table of x255 ,
width type i,
height type i,
filelen type i,
xstr type xstring,
str type string,
off type i,
moff type i,
mlen type i,
mod type i ,
file_off type i.
start-of-selection.
call function 'GUI_UPLOAD'
exporting
filename = 'C:\2DOGS.JPG'
filetype = 'BIN'
importing
filelength = filelen
tables
data_tab = file_tab
exceptions
others = 17.
call function 'SCMS_BINARY_TO_XSTRING'
exporting
input_length = filelen
importing
buffer = xstr
tables
binary_tab = file_tab.
str = xstr.
if xstr+0(2) = 'FFD8'. "JPG File
off = 0.
while sy-subrc = 0.
find 'FFC0' in section offset off of str match offset moff match length mlen.
if sy-subrc = 0.
off = moff + mlen.
mod = moff mod 2.
if mod = 0.
file_off = moff.
endif.
endif.
endwhile.
file_off = file_off / 2 + 5 .
height = xstr+file_off(2).
file_off = file_off + 2.
width = xstr+file_off(2) .
write 'JPG File'.
elseif xstr+0(2) = '424D'. "BMP File
width = xstr+19(1) * 256 + xstr+18(1) .
height = xstr+23(1) * 256 + xstr+22(1).
write 'bmp file'.
else.
write 'File type error'.
exit.
endif.
write: / width no-gap, '*' ,height no-gap.
评论