+ dbg.Verbose(1, "gdcmHeader::FindVR:", "Falsely explicit vr file");
+ fseek(fp, PositionOnEntry, SEEK_SET);
+ // When this element is known in the dictionary we shall use, e.g. for
+ // the semantics (see the usage of IsAnInteger), the vr proposed by the
+ // dictionary entry. Still we have to flag the element as implicit since
+ // we know now our assumption on expliciteness is not furfilled.
+ // avoid .
+ if ( ElVal->IsVrUnknown() )
+ ElVal->SetVR("Implicit");
+ ElVal->SetImplicitVr();
+}
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Determines if the Transfer Syntax was allready encountered
+ * and if it corresponds to a ImplicitVRLittleEndian one.
+ *
+ * @return True when ImplicitVRLittleEndian found. False in all other cases.
+ */
+bool gdcmHeader::IsImplicitVRLittleEndianTransferSyntax(void) {
+ ElValue* Element = PubElVals.GetElementByNumber(0x0002, 0x0010);
+ if ( !Element )
+ return false;
+ LoadElementValueSafe(Element);
+ string Transfer = Element->GetValue();
+ if ( Transfer == "1.2.840.10008.1.2" )
+ return true;
+ return false;
+}
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Determines if the Transfer Syntax was allready encountered
+ * and if it corresponds to a ExplicitVRLittleEndian one.
+ *
+ * @return True when ExplicitVRLittleEndian found. False in all other cases.
+ */
+bool gdcmHeader::IsExplicitVRLittleEndianTransferSyntax(void) {
+ ElValue* Element = PubElVals.GetElementByNumber(0x0002, 0x0010);
+ if ( !Element )
+ return false;
+ LoadElementValueSafe(Element);
+ string Transfer = Element->GetValue();
+ if ( Transfer == "1.2.840.10008.1.2.1" )
+ return true;
+ return false;
+}
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Determines if the Transfer Syntax was allready encountered
+ * and if it corresponds to a DeflatedExplicitVRLittleEndian one.
+ *
+ * @return True when DeflatedExplicitVRLittleEndian found. False in all other cases.
+ */
+bool gdcmHeader::IsDeflatedExplicitVRLittleEndianTransferSyntax(void) {
+ ElValue* Element = PubElVals.GetElementByNumber(0x0002, 0x0010);
+ if ( !Element )
+ return false;
+ LoadElementValueSafe(Element);
+ string Transfer = Element->GetValue();
+ if ( Transfer == "1.2.840.10008.1.2.1.99" )
+ return true;
+ return false;
+}
+
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Determines if the Transfer Syntax was allready encountered
+ * and if it corresponds to a Explicit VR Big Endian one.
+ *
+ * @return True when big endian found. False in all other cases.
+ */
+bool gdcmHeader::IsExplicitVRBigEndianTransferSyntax(void) {
+ ElValue* Element = PubElVals.GetElementByNumber(0x0002, 0x0010);
+ if ( !Element )
+ return false;
+ LoadElementValueSafe(Element);
+ string Transfer = Element->GetValue();
+ if ( Transfer == "1.2.840.10008.1.2.2" )
+ return true;
+ return false;
+}
+
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Determines if the Transfer Syntax was allready encountered
+ * and if it corresponds to a JPEGBaseLineProcess1 one.
+ *
+ * @return True when JPEGBaseLineProcess1found. False in all other cases.
+ */
+bool gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(void) {
+ ElValue* Element = PubElVals.GetElementByNumber(0x0002, 0x0010);
+ if ( !Element )
+ return false;
+ LoadElementValueSafe(Element);
+ string Transfer = Element->GetValue();
+ if ( Transfer == "1.2.840.10008.1.2.4.50" )
+ return true;
+ return false;
+}
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Determines if the Transfer Syntax was allready encountered
+ * and if it corresponds to a JPEGExtendedProcess2-4 one.
+ *
+ * @return True when JPEGExtendedProcess2-4 found. False in all other cases.
+ */
+bool gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(void) {
+ ElValue* Element = PubElVals.GetElementByNumber(0x0002, 0x0010);
+ if ( !Element )
+ return false;
+ LoadElementValueSafe(Element);
+ string Transfer = Element->GetValue();
+ if ( Transfer == "1.2.840.10008.1.2.4.51" )
+ return true;
+ return false;
+}
+
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Determines if the Transfer Syntax was allready encountered
+ * and if it corresponds to a JPEGExtendeProcess3-5 one.
+ *
+ * @return True when JPEGExtendedProcess3-5 found. False in all other cases.
+ */
+bool gdcmHeader::IsJPEGExtendedProcess3_5TransferSyntax(void) {
+ ElValue* Element = PubElVals.GetElementByNumber(0x0002, 0x0010);
+ if ( !Element )
+ return false;
+ LoadElementValueSafe(Element);
+ string Transfer = Element->GetValue();
+ if ( Transfer == "1.2.840.10008.1.2.4.52" )
+ return true;
+ return false;
+}
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Determines if the Transfer Syntax was allready encountered
+ * and if it corresponds to a JPEGSpectralSelectionProcess6-8 one.
+ *
+ * @return True when JPEGSpectralSelectionProcess6-8 found. False in all other cases.
+ */
+bool gdcmHeader::IsJPEGSpectralSelectionProcess6_8TransferSyntax(void) {
+ ElValue* Element = PubElVals.GetElementByNumber(0x0002, 0x0010);
+ if ( !Element )
+ return false;
+ LoadElementValueSafe(Element);
+ string Transfer = Element->GetValue();
+ if ( Transfer == "1.2.840.10008.1.2.4.53" )
+ return true;
+ return false;
+}
+
+//
+// Euhhhhhhh
+// Il y en a encore DIX-SEPT, comme ça.
+// Il faudrait trouver qq chose + rusé ...
+//
+// --> probablement TOUS les supprimer (Eric dixit)
+//
+
+
+void gdcmHeader::FixFoundLength(ElValue * ElVal, guint32 FoundLength) {
+ // Heuristic: a final fix.
+ if ( FoundLength == 0xffffffff)
+ FoundLength = 0;
+ ElVal->SetLength(FoundLength);
+}
+
+guint32 gdcmHeader::FindLengthOB(void) {
+ // See PS 3.5-2001, section A.4 p. 49 on encapsulation of encoded pixel data.
+ guint16 g;
+ guint16 n;
+ long PositionOnEntry = ftell(fp);
+ bool FoundSequenceDelimiter = false;
+ guint32 TotalLength = 0;
+ guint32 ItemLength;
+
+ while ( ! FoundSequenceDelimiter) {
+ g = ReadInt16();
+ n = ReadInt16();
+ if (errno == 1)
+ return 0;
+ TotalLength += 4; // We even have to decount the group and element
+ if ( g != 0xfffe ) {
+ dbg.Verbose(1, "gdcmHeader::FindLengthOB: ",
+ "wrong group for an item sequence.");
+ errno = 1;
+ return 0;
+ }
+ if ( n == 0xe0dd )
+ FoundSequenceDelimiter = true;
+ else if ( n != 0xe000) {
+ dbg.Verbose(1, "gdcmHeader::FindLengthOB: ",
+ "wrong element for an item sequence.");
+ errno = 1;
+ return 0;
+ }
+ ItemLength = ReadInt32();
+ TotalLength += ItemLength + 4; // We add 4 bytes since we just read
+ // the ItemLength with ReadInt32
+ SkipBytes(ItemLength);
+ }