Module: $RCSfile: gdcmFileHelper.cxx,v $
Language: C++
- Date: $Date: 2006/07/04 07:58:51 $
- Version: $Revision: 1.106 $
+ Date: $Date: 2007/04/12 13:22:49 $
+ Version: $Revision: 1.111 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
/**
- * \brief Accesses an existing DataEntry through it's (group, element)
- * and modifies it's content with the given value.
+ * \brief Accesses an existing DataEntry through its (group, element)
+ * and modifies its content with the given value.
* @param content new value (string) to substitute with
* @param group group number of the Dicom Element to modify
* @param elem element number of the Dicom Element to modify
/**
- * \brief Accesses an existing DataEntry through it's (group, element)
- * and modifies it's content with the given value.
+ * \brief Accesses an existing DataEntry through its (group, element)
+ * and modifies its content with the given value.
* @param content new value (void* -> uint8_t*) to substitute with
* @param lgth new value length
* @param group group number of the Dicom Element to modify
case JPEG:
SetWriteFileTypeToJPEG();
break;
+
+ case JPEG2000:
+ SetWriteFileTypeToJPEG2000();
+ break;
}
-
+
// --------------------------------------------------------------
// Special Patch to allow gdcm to re-write ACR-LibIDO formated images
//
}
bool check = CheckWriteIntegrity(); // verifies length
- if (WriteType == JPEG ) check = true;
+ if (WriteType == JPEG || WriteType == JPEG2000) check = true;
if (check)
{
check = FileInternal->Write(fileName,WriteType);
if ( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files
vr = "OB";
// For non RAW data. Mainly JPEG
- if( WriteType == JPEG )
+ if( WriteType == JPEG || WriteType == JPEG2000)
{
vr = "OW";
}
Archive->Push(0x0002,0x0102);
}
+ /**
+ * \brief Sets in the File the TransferSyntax to 'JPEG2000'
+ */
+void FileHelper::SetWriteFileTypeToJPEG2000()
+{
+ std::string ts = Util::DicomString(
+ Global::GetTS()->GetSpecialTransferSyntax(TS::JPEG2000Lossless) );
+
+ DataEntry *tss = CopyDataEntry(0x0002,0x0010,"UI");
+ tss->SetString(ts);
+
+ Archive->Push(tss);
+ tss->Delete();
+}
+
/**
* \brief Sets in the File the TransferSyntax to 'JPEG'
*/
//0002 0016 AE 1 Source Application Entity Title
//0002 0100 UI 1 Private Information Creator
//0002 0102 OB 1 Private Information
+
+ // Push out 'ACR-NEMA-special' entries, if any
+ Archive->Push(0x0008,0x0001); // Length to End
+ Archive->Push(0x0008,0x0010); // Recognition Code
+ Archive->Push(0x0028,0x0005); // Image Dimension
// Create them if not found
// Always modify the value
std::ostringstream s;
// check 'Bits Allocated' vs decent values
int nbBitsAllocated = FileInternal->GetBitsAllocated();
- if ( nbBitsAllocated == 0 || nbBitsAllocated > 32)
+ if ( nbBitsAllocated == 0 || nbBitsAllocated > 32
+ || ( nbBitsAllocated > 8 && nbBitsAllocated <16) )
{
CopyMandatoryEntry(0x0028,0x0100,"16","US");
gdcmWarningMacro("(0028,0100) changed from "
<< " for consistency purpose");
}
+ // check Pixel Representation (default it as 0 -unsigned-)
+
+ DataEntry *e_0028_0103 = FileInternal->GetDataEntry(0x0028, 0x0103);
+ if ( !e_0028_0103 )
+ {
+ gdcmWarningMacro("PixelRepresentation (0028,0103) is supposed to be mandatory");
+ CopyMandatoryEntry(0x0028, 0x0103,"0","US");
+ }
+ else
+ {
+ int sign = (int)e_0028_0103->GetValue(0);
+ if (sign !=1 && sign !=0)
+ {
+ gdcmWarningMacro("PixelRepresentation (0028,0103) is supposed to be =1 or =0");
+ CopyMandatoryEntry(0x0028, 0x0103,"0","US");
+ }
+ }
+
std::string pixelSpacing = FileInternal->GetEntryString(0x0028,0x0030);
if ( pixelSpacing == GDCM_UNFOUND )
{