ReadTagMemory example for Delphi
procedure TForm1.Button1Click(Sender: TObject);
const
DATACOUNT= 4;
var
nRet: L_INT;
LogoPosition: L_UINT16; { my private tag }
vTagData: Variant;
vSavedData: Variant;
hFileInMemory: L_HANDLE; { memory handle for the file }
nMemSize: L_INT32; { size of the file in memory }
begin
LogoPosition:= $8001;
vTagData:= VarArrayCreate ([0,DATACOUNT-1], varWord);
vTagData[0]:= 5;
vTagData[1]:= 5;
vTagData[2]:= 24;
vTagData[3]:= 37;
{ Set the tag data to be saved }
LEADImage1.SetTag(LogoPosition, TAG_SSHORT, DATACOUNT, vTagData );
{ Save the image as a TIFF file in memory }
LEADImage1.SaveMemory( hFileInMemory, FILE_TIF, LEADImage1.BitmapBits, 0, nMemSize );
{ Get the tagged data }
nRet:= LEADImage1.ReadTagMemory( hFileInMemory, nMemSize, 1, LogoPosition );
if ( nRet = SUCCESS ) then
begin
{ Display a message showing the data }
if ( (LEADImage1.GetTagType(LogoPosition) = TAG_SSHORT) And (LEADImage1.GetTagCount(LogoPosition) = DATACOUNT) ) then
begin
vSavedData:= LEADImage1.GetTagData(0);
ShowMessage ( 'X = ' + IntToStr(vSavedData[0]) + Chr(13) +
'Y = ' + IntToStr(vSavedData[1]) + Chr(13) +
'nWidth = ' + IntToStr(vSavedData[2]) + Chr(13) +
'nHeight = ' + IntToStr(vSavedData[3]) );
end;
end;
{ Free memory that we no longer need }
if ( hFileInMemory <> 0 ) then
GlobalFree ( hFileInMemory );
end;