SetTag example for Delphi
procedure TForm1.SetAndReadClick(Sender: TObject);
var
myArray : Variant;
begin
// initialize the array
myArray := VarArrayCreate([0,3],varByte);
myArray[0] := 1;
myArray[1] := 2;
myArray[2] := 3;
myArray[3] := 127;
// set a tag using one of the following:
LEADImage1.SetTag (32768, TAG_BYTE, 4, myArray);
// Write the tag
LEADImage1.WriteTag(PCHAR(Edit1.Text) , 1);
ReadTagClick(self);
LEADImage1.SetTag(32768, TAG_ASCII, 0, 'My text string');
LEADImage1.WriteTag(PCHAR(Edit1.Text) , 1);
ReadTagClick(self);
end;
procedure TForm1.ReadTagClick(Sender: TObject);
begin
// read the tag back
LEADImage1.ReadTag(PCHAR(Edit1.Text), 1, 32768);
GetAndDisplayTag(0);
end;
procedure TForm1.GetAndDisplayTag(lTag: Integer);
var
myVar : Variant;
Msg : string;
i : LongInt;
count : LongInt;
begin
// This sub will get a certain tag and display it according to the tag type.
myVar := LEADImage1.GetTagData (lTag);
count := LEADImage1.GetTagCount (lTag);
Msg := 'Type = ' + IntToStr((LEADImage1.GetTagType (lTag)));
Msg := Msg + #10 + #13 + 'count = ' + IntToStr(count);
if (LEADImage1.GetTagType(lTag) = TAG_ASCII) then
Msg := Msg + #10 + #13 + 'Data = ' + myVar
else if (LEADImage1.GetTagType(lTag) = TAG_RATIONAL) or (LEADImage1.GetTagType(lTag) = TAG_SRATIONAL) then
for i := 0 to count - 1 do
Msg := Msg + #10 + #13 + 'Data(' + IntToStr(i) + ') = ' + IntTostr(myVar[i * 2]) + '/' + IntToStr(myVar[i * 2 + 1])
Else
for i := 0 to count - 1 do
Msg := Msg + #10 + #13 + 'Data(' + IntToStr(i) + ') = ' + VarToStr(myVar[i]);
MessageBox(Handle,pChar(Msg),'test',0);
end;