fpexif: Display tag IDs in the metadata_viewer example.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6800 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-01-24 14:34:35 +00:00
parent a77fb8ddbf
commit 58158dbc14
3 changed files with 114 additions and 2 deletions

View File

@ -8,6 +8,7 @@ object MainForm: TMainForm
ClientWidth = 926
OnCreate = FormCreate
OnDestroy = FormDestroy
ShowHint = True
LCLVersion = '2.1.0.0'
object ShellPanel: TPanel
Left = 0
@ -22,6 +23,7 @@ object MainForm: TMainForm
object ShellTreeView: TShellTreeView
Left = 0
Height = 269
Hint = 'Navigate to the folder with your images.'
Top = 0
Width = 274
Align = alTop
@ -47,7 +49,8 @@ object MainForm: TMainForm
end
object ShellListView: TShellListView
Left = 0
Height = 273
Height = 250
Hint = 'Select the image for which you want to see the metadata'
Top = 274
Width = 274
Align = alClient
@ -65,6 +68,7 @@ object MainForm: TMainForm
object PreviewImage: TImage
Left = 0
Height = 144
Hint = 'Thumbnail image embedded in the image file'
Top = 547
Width = 274
Align = alBottom
@ -72,6 +76,32 @@ object MainForm: TMainForm
Proportional = True
Stretch = True
end
object Panel4: TPanel
Left = 0
Height = 23
Top = 524
Width = 274
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 23
ClientWidth = 274
TabOrder = 3
object Label1: TLabel
AnchorSideLeft.Control = Panel4
AnchorSideTop.Control = Panel4
AnchorSideTop.Side = asrCenter
Left = 8
Height = 15
Top = 4
Width = 94
BorderSpacing.Left = 8
BorderSpacing.Top = 4
BorderSpacing.Bottom = 4
Caption = 'Thumbnail image'
ParentColor = False
end
end
end
object Splitter2: TSplitter
Left = 274
@ -136,6 +166,10 @@ object MainForm: TMainForm
Caption = 'Group'
Width = 120
end
item
Caption = 'Tag ID'
Width = 60
end
item
Caption = 'Property'
Width = 220
@ -172,6 +206,7 @@ object MainForm: TMainForm
AnchorSideTop.Side = asrCenter
Left = 0
Height = 19
Hint = 'Try to decode information in the MakerNote tag if possible'
Top = 1
Width = 127
Caption = 'Decode MakerNotes'
@ -179,6 +214,37 @@ object MainForm: TMainForm
State = cbChecked
TabOrder = 0
end
object CbShowTagIDs: TCheckBox
AnchorSideLeft.Control = CbDecodeMakerNotes
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CbDecodeMakerNotes
AnchorSideTop.Side = asrCenter
Left = 135
Height = 19
Hint = 'Show the numerical ID of every tag'
Top = 1
Width = 88
BorderSpacing.Left = 8
Caption = 'Show tag IDs'
Checked = True
OnChange = CbShowTagIDsChange
State = cbChecked
TabOrder = 1
end
object CbShowParentTagID: TCheckBox
AnchorSideLeft.Control = CbShowTagIDs
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CbDecodeMakerNotes
AnchorSideTop.Side = asrCenter
Left = 231
Height = 19
Hint = 'Show the ID of the parent tag.'#13#10'List will be updated when the next file is loaded.'
Top = 1
Width = 94
BorderSpacing.Left = 8
Caption = 'with parent ID'
TabOrder = 2
end
end
end
object PgImage: TTabSheet
@ -247,6 +313,7 @@ object MainForm: TMainForm
AnchorSideTop.Side = asrCenter
Left = 144
Height = 23
Hint = 'New date to be assigned to the selected image'
Top = 6
Width = 152
BorderSpacing.Left = 5
@ -260,6 +327,7 @@ object MainForm: TMainForm
AnchorSideTop.Side = asrCenter
Left = 304
Height = 25
Hint = 'Replaces the image date.'
Top = 5
Width = 66
AutoSize = True

View File

@ -16,9 +16,12 @@ type
TMainForm = class(TForm)
BtnChangeDate: TButton;
CbDecodeMakerNotes: TCheckBox;
CbShowTagIDs: TCheckBox;
CbShowParentTagID: TCheckBox;
EdChangeDate: TEdit;
FilenameInfo: TLabel;
Image: TImage;
Label1: TLabel;
LblChangeDate: TLabel;
Messages: TMemo;
PageControl1: TPageControl;
@ -26,6 +29,7 @@ type
Panel2: TPanel;
Panel3: TPanel;
DateTimePanel: TPanel;
Panel4: TPanel;
PreviewImage: TImage;
ImageList: TImageList;
Splitter3: TSplitter;
@ -39,6 +43,7 @@ type
Splitter1: TSplitter;
Splitter2: TSplitter;
procedure BtnChangeDateClick(Sender: TObject);
procedure CbShowTagIDsChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
@ -74,6 +79,8 @@ uses
IniFiles, Math, StrUtils, DateUtils,
fpeGlobal, fpeTags, fpeExifData, fpeIptcData;
const
TAG_ID_CAPTION = 'Tag ID';
function CalcIniName: String;
begin
@ -124,6 +131,26 @@ begin
FImgInfo.SaveToFile(fn);
end;
procedure TMainForm.CbShowTagIDsChange(Sender: TObject);
var
c: TListColumn;
i: Integer;
begin
TagListView.BeginUpdate;
try
c := nil;
for i:=0 to TagListView.Columns.Count-1 do
if TagListView.Columns[i].Caption = TAG_ID_CAPTION then begin
c := TagListView.Columns[i];
break;
end;
if c <> nil then
c.Visible := CbShowTagIDs.Checked;;
finally
TagListView.EndUpdate;
end;
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
try
@ -169,6 +196,10 @@ begin
item := TagListView.Items.Add;
item.Data := lTag;
item.Caption := 'EXIF.' + NiceGroupNames[lTag.Group];
if CbShowParentTagID.Checked then
item.SubItems.Add(Format('$%.04x:$%.04x', [lTag.TagIDRec.Parent, lTag.TagIDRec.Tag]))
else
Item.SubItems.Add(Format('$%.04x', [lTag.TagIDRec.Tag]));
item.SubItems.Add(lTag.Description);
item.SubItems.Add(lTag.AsString);
end;
@ -233,6 +264,7 @@ var
i, W, H, L, T: Integer;
rct: TRect;
s: String;
b: Boolean;
begin
ini := TIniFile.Create(CalcIniName);
try
@ -263,6 +295,16 @@ begin
if w <> 0 then
TagListView.Columns[i].Width := w;
end;
b := ini.ReadBool('TagList', 'ShowTagIDs', true);
for i:=0 to TagListView.Columns.Count-1 do
if TagListView.Columns[i].Caption = TAG_ID_CAPTION then
TagListView.Columns[2].Visible := b;
CbShowTagIDs.Checked := b;
b := ini.ReadBool('TagList', 'ShowParentTagID', false);
CbShowParentTagID.Checked := b;
finally
ini.Free;
end;
@ -295,6 +337,9 @@ begin
ini.WriteString('MainForm', 'Path', ShellTreeView.Path);
ini.WriteInteger('MainForm', 'LeftPanelWidth', ShellPanel.Width);
ini.WriteInteger('MainForm', 'TreeHeight', ShellTreeView.Height);
ini.WriteBool('TagList', 'ShowTagIDs', CbShowTagIDs.Checked);
ini.WriteBool('TagList', 'ShowParentTagID', CbShowParentTagID.Checked);
for i:=0 to TagListView.Columns.Count-1 do
ini.WriteInteger('TagList', 'ColWidth'+IntToStr(i), TagListView.Columns[i].Width);
finally

View File

@ -297,7 +297,6 @@ end;
// Reads the image file directory (IFD) starting at the current stream position
// and adds the found tags to the specified group
//------------------------------------------------------------------------------
//procedure TBasicExifReader.ReadIFD(AStream: TStream; AGroup: TTagGroup);
procedure TBasicExifReader.ReadIFD(AStream: TStream; AParent: TTagID);
var
numRecords: Word;