fpexif: Fix IPTC string tag writing error.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9011 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-11-06 16:41:26 +00:00
parent 2053c444cb
commit 3040781187

View File

@ -423,7 +423,9 @@ const
procedure WriteString(AIptcTag: TIptcTag; AText: PChar; ALength: Integer);
var
byteAdded: Boolean;
len: Integer;
begin
len := ALength;
if odd(ALength) then begin
inc(ALength);
byteAdded := true;
@ -433,7 +435,7 @@ const
if ALength < 32768 then begin
AIptcTag.Size := NtoBE(word(ALength));
AStream.WriteBuffer(AIptcTag, SizeOf(AIptcTag));
AStream.WriteBuffer(AText^, ALength);
AStream.WriteBuffer(AText^, len);
end
else
// "Extended" dataset
@ -442,13 +444,13 @@ const
AIptcTag.Size := NtoBE($8002);
AStream.WriteBuffer(AIptcTag, SizeOf(AIptcTag));
WriteWord(AStream, NtoBE(word(ALength)));
AStream.WriteBuffer(AText^, ALength);
AStream.WriteBuffer(AText^, len);
end else begin
// Size is 4, but we must set highest bit to mark tag as being extended.
AIptcTag.Size := $8004;
AStream.WriteBuffer(AIptcTag, SizeOf(AIptcTag));
WriteDWord(AStream, NtoBE(ALength));
AStream.WriteBuffer(AText^, ALength);
AStream.WriteBuffer(AText^, len);
end;
if byteAdded then // Write 0 to added byte
WriteByte(AStream, 0);