K
Kingron
Unregistered / Unconfirmed
GUEST, unregistred user!
Sony F717生成的JPG文件里面,包含了光圈、快门速度、白平衡、时间、焦距等等信息,
我想写一个程序来读取这些信息,考察自己拍照片的水平,这些信息目前已知包含在JPEG的E1段里面,
同时E1段里面包含了数略图信息,我分析了一下目前可以读取缩略图信息,并显示,但是其他信息就不知道了。
下面是关于缩略图的代码:
unit SonyInterface;
interface
uses
Windows, Jpeg, Classes, SysUtils;
type
TSonyDSCHeader = packed record
Format_Desc: array[0..5] of char; { Image Format : Exif , for F717 }
Format_Version: array[0..3] of char; { Image Format Version : 2.2, for F717 }
Unknown1: array[0..$A1] of char;
Sony_Flag: array[0..5] of char; { Flag : Sony }
Device_Flag: array[0..9] of char; { Device : CyberShot }
Unknown2: array[0..29] of char;
DateTime: array[0..19] of char; { DateTime }
Unknown3: array[0..640] of char;
end;
function GetDSCInfo(const FileName: string; out Info: TSonyDSCHeader; Preview: TJPEGImage): Boolean;
implementation
{ TSonyCyberShot }
function GetDSCInfo;
const
SOI_SONY = $E1FFD8FF;
SOI = $D8FF; { JPEG File Flag of Start }
EOI = $D9FF; { JPEG File Flag of End }
SONY = $E1FF; { Sony define Flag }
HEADER_LEN = 881;
var
Flag: DWord;
L, H: Byte;
Len: Word;
Ms: TMemoryStream;
Fs: TFileStream;
begin
Result := False;
FS := TFileStream.Create(FileName, fmOpenRead);
with FS do
try
Read(Flag, SizeOf(Flag));
if Flag <> SOI_SONY then Exit;
Read(H, SizeOf(H));
Read(L, SizeOf(L));
Len := MakeWord(L, H);
Read(Info,Sizeof(Info));
Ms := TMemoryStream.Create;
Ms.CopyFrom(Fs, Len - HEADER_LEN);
Ms.Position := 0;
Preview.LoadFromStream(MS);
Ms.Free;
Result := True;
finally
Free;
end;
end;
end.
///Demo
procedure TForm1.Button2Click(Sender: TObject);
var
Info: TSonyDSCHeader;
Img : TJPEGImage;
begin
Img := TJPEGImage.Create;
with OpenDialog1 do
if Execute then
if GetDSCInfo(FileName,Info,Img) then
Image1.Picture.Assign(Img);
Img.Free;
end;
任何资料、信息、提示都万分感谢!
我想写一个程序来读取这些信息,考察自己拍照片的水平,这些信息目前已知包含在JPEG的E1段里面,
同时E1段里面包含了数略图信息,我分析了一下目前可以读取缩略图信息,并显示,但是其他信息就不知道了。
下面是关于缩略图的代码:
unit SonyInterface;
interface
uses
Windows, Jpeg, Classes, SysUtils;
type
TSonyDSCHeader = packed record
Format_Desc: array[0..5] of char; { Image Format : Exif , for F717 }
Format_Version: array[0..3] of char; { Image Format Version : 2.2, for F717 }
Unknown1: array[0..$A1] of char;
Sony_Flag: array[0..5] of char; { Flag : Sony }
Device_Flag: array[0..9] of char; { Device : CyberShot }
Unknown2: array[0..29] of char;
DateTime: array[0..19] of char; { DateTime }
Unknown3: array[0..640] of char;
end;
function GetDSCInfo(const FileName: string; out Info: TSonyDSCHeader; Preview: TJPEGImage): Boolean;
implementation
{ TSonyCyberShot }
function GetDSCInfo;
const
SOI_SONY = $E1FFD8FF;
SOI = $D8FF; { JPEG File Flag of Start }
EOI = $D9FF; { JPEG File Flag of End }
SONY = $E1FF; { Sony define Flag }
HEADER_LEN = 881;
var
Flag: DWord;
L, H: Byte;
Len: Word;
Ms: TMemoryStream;
Fs: TFileStream;
begin
Result := False;
FS := TFileStream.Create(FileName, fmOpenRead);
with FS do
try
Read(Flag, SizeOf(Flag));
if Flag <> SOI_SONY then Exit;
Read(H, SizeOf(H));
Read(L, SizeOf(L));
Len := MakeWord(L, H);
Read(Info,Sizeof(Info));
Ms := TMemoryStream.Create;
Ms.CopyFrom(Fs, Len - HEADER_LEN);
Ms.Position := 0;
Preview.LoadFromStream(MS);
Ms.Free;
Result := True;
finally
Free;
end;
end;
end.
///Demo
procedure TForm1.Button2Click(Sender: TObject);
var
Info: TSonyDSCHeader;
Img : TJPEGImage;
begin
Img := TJPEGImage.Create;
with OpenDialog1 do
if Execute then
if GetDSCInfo(FileName,Info,Img) then
Image1.Picture.Assign(Img);
Img.Free;
end;
任何资料、信息、提示都万分感谢!