GetBinaryValue Example for C++Builder
Cardinal uCount, n, nLen;
int nRet;
char byteVal, cByte;
char szTmp[512];
AnsiString sBytes;
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 = sBytes.Length();
LEADDicom1->BinaryValueCount = nLen;
for(n = 0; n<nLen; n++)
{
cByte = sBytes[n+1];
byteVal = cByte;
LEADDicom1->BinaryValues[n] = byteVal;
}
/* set the bytes */
nRet = LEADDicom1->SetBinaryValue(nLen);
if(nRet != SUCCESS)
{
ShowMessage("Error Number: " + IntToStr(LEADDicom1->Error));
return;
}
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)
for(n = 0; n<LEADDicom1->BinaryValueCount; n++)
{
/* display each byte: a char separated by a space */
szTmp[0] = LEADDicom1->BinaryValues[n];
szTmp[1] = '\0';
Label1->Caption = Label1->Caption + " " + szTmp;
}
LEADDicom1->EnableMethodErrors = true;
ShowMessage("wait");