mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: Exif - convert string date time to TDateTime
This commit is contained in:
parent
1761ce3c67
commit
f11df0168b
2 changed files with 29 additions and 7 deletions
|
|
@ -57,10 +57,11 @@ type
|
|||
FImageWidth: UInt16;
|
||||
FImageHeight: UInt16;
|
||||
FOrientation: UInt16;
|
||||
FDateTimeOriginal: String;
|
||||
FDateTimeOriginal: TDateTime;
|
||||
private
|
||||
procedure Reset;
|
||||
function ReadString(Offset, Count: Int32): String;
|
||||
function ReadDateTime(Offset, Count: Int32): TDateTime;
|
||||
procedure ReadTag(var ATag: TTag);
|
||||
function DoImageFileDirectory: Boolean;
|
||||
public
|
||||
|
|
@ -70,7 +71,7 @@ type
|
|||
property ImageWidth: UInt16 read FImageWidth;
|
||||
property ImageHeight: UInt16 read FImageHeight;
|
||||
property Orientation: UInt16 read FOrientation;
|
||||
property DateTimeOriginal: String read FDateTimeOriginal;
|
||||
property DateTimeOriginal: TDateTime read FDateTimeOriginal;
|
||||
end;
|
||||
|
||||
resourcestring
|
||||
|
|
@ -96,7 +97,7 @@ begin
|
|||
FOrientation:= 0;
|
||||
FMake:= EmptyStr;
|
||||
FModel:= EmptyStr;
|
||||
FDateTimeOriginal:= EmptyStr;
|
||||
FDateTimeOriginal:= 0;
|
||||
end;
|
||||
|
||||
function TExifReader.ReadString(Offset, Count: Int32): String;
|
||||
|
|
@ -115,6 +116,27 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function TExifReader.ReadDateTime(Offset, Count: Int32): TDateTime;
|
||||
var
|
||||
S: String;
|
||||
SystemTime: TSystemTime;
|
||||
begin
|
||||
S:= ReadString(Offset, Count);
|
||||
try
|
||||
SystemTime.Millisecond:= 0;
|
||||
// Data format is "YYYY:MM:DD HH:MM:SS"
|
||||
SystemTime.Year:= StrToDWord(Copy(S, 1, 4));
|
||||
SystemTime.Month:= StrToDWord(Copy(S, 6, 2));
|
||||
SystemTime.Day:= StrToDWord(Copy(S, 9, 2));
|
||||
SystemTime.Hour:= StrToDWord(Copy(S, 12, 2));
|
||||
SystemTime.Minute:= StrToDWord(Copy(S, 15, 2));
|
||||
SystemTime.Second:= StrToDWord(Copy(S, 18, 2));
|
||||
Result:= SystemTimeToDateTime(SystemTime);
|
||||
except
|
||||
Result:= 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TExifReader.ReadTag(var ATag: TTag);
|
||||
begin
|
||||
Self.ReadBuffer(ATag, SizeOf(TTag));
|
||||
|
|
@ -189,7 +211,7 @@ begin
|
|||
case ATag.ID of
|
||||
$9003: // Date/Time of original image taken
|
||||
begin
|
||||
FDateTimeOriginal:= ReadString(ATag.Offset, ATag.Count);
|
||||
FDateTimeOriginal:= ReadDateTime(ATag.Offset, ATag.Count);
|
||||
end;
|
||||
// Image pixel width
|
||||
$A002: if FImageWidth = 0 then FImageWidth := ATag.Offset;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ begin
|
|||
AddField(rsImageWidth, ft_numeric_32);
|
||||
AddField(rsImageHeight, ft_numeric_32);
|
||||
AddField(rsOrientation, ft_numeric_32);
|
||||
AddField(rsDateTimeOriginal, ft_string);
|
||||
AddField(rsDateTimeOriginal, ft_datetime);
|
||||
end;
|
||||
|
||||
procedure TExifWdx.CallContentSetDefaultParams;
|
||||
|
|
@ -135,7 +135,7 @@ begin
|
|||
2: if FExif.ImageWidth > 0 then Result:= FExif.ImageWidth;
|
||||
3: if FExif.ImageHeight > 0 then Result:= FExif.ImageHeight;
|
||||
4: if FExif.Orientation > 0 then Result:= FExif.Orientation;
|
||||
5: if Length(FExif.DateTimeOriginal) > 0 then Result:= FExif.DateTimeOriginal;
|
||||
5: if FExif.DateTimeOriginal > 0 then Result:= FExif.DateTimeOriginal;
|
||||
end;
|
||||
finally
|
||||
LeaveCriticalSection(FMutex);
|
||||
|
|
@ -155,7 +155,7 @@ begin
|
|||
2: if FExif.ImageWidth > 0 then Result:= IntToStr(FExif.ImageWidth);
|
||||
3: if FExif.ImageHeight > 0 then Result:= IntToStr(FExif.ImageHeight);
|
||||
4: if FExif.Orientation > 0 then Result:= IntToStr(FExif.Orientation);
|
||||
5: Result:= FExif.DateTimeOriginal;
|
||||
5: Result:= DateTimeToStr(FExif.DateTimeOriginal);
|
||||
end;
|
||||
finally
|
||||
LeaveCriticalSection(FMutex);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue