GetBinaryValue Example for Delphi
var
uCount: Cardinal;
n: Cardinal;
nRet: Integer;
nLen: Integer;
byteVal: Byte;
cByte: AnsiChar;
sBytes: String;
begin
LEADDicom1.EnableMethodErrors := false;
{ move to the root element }
LEADDicom1.MoveFirstElement(false);
LEADDicom1.MoveRootElement();
Label1.Caption := '';
{ insert some bytes into the element }
sBytes := 'This is a Test 1234!';
nLen := Length(sBytes);
LEADDicom1.BinaryValueCount := nLen;
For n := 0 To nLen – 1 do
begin
cByte := sBytes[n+1];
byteVal := Ord(cByte);
LEADDicom1.BinaryValues[n] := byteVal;
end;
{ set the bytes }
nRet := LEADDicom1.SetBinaryValue(nLen);
If nRet <> SUCCESS Then
begin
ShowMessage('Error Number: ' + IntToStr(LEADDicom1.Error));
Exit;
end;
LEADDicom1.BinaryValueCount := 0; { free the values }
{ get the byte count }
uCount := LEADDicom1.CurrentElement.Length;
ShowMessage('There are ' + IntToStr(uCount) + ' bytes!');
{ get the bytes }
nRet := LEADDicom1.GetBinaryValue(uCount);
If nRet = SUCCESS Then
For n := 0 To LEADDicom1.BinaryValueCount - 1 do
{ display each byte: a char separated by a space }
Label1.Caption := Label1.Caption + ' ' + Chr(LEADDicom1.BinaryValues[n]);
LEADDicom1.EnableMethodErrors := true;
ShowMessage('wait');
End;