- // create 'Referenced SOP Instance UID'
- DataEntry *e_0008_0018 = FileInternal->GetDataEntry(0x0008, 0x0018);
-// DataEntry *e_0008_1155 = DataEntry::New(
-// Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1155) );
- DataEntry *e_0008_1155 = DataEntry::New(0x0008, 0x1155, "UI");
- e_0008_1155->SetString( e_0008_0018->GetString());
- sqi->AddEntry(e_0008_1155);
- e_0008_1155->Delete();
-
- sis->AddSQItem(sqi,1);
- sqi->Delete();
-
- // temporarily replaces any previous 'Source Image Sequence'
- Archive->Push(sis);
- sis->Delete();
-
- // FIXME : is 'Image Type' *really* depending on the presence of 'SOP Class UID'?
- if ( ContentType == FILTERED_IMAGE)
- // the user *knows* he just modified the pixels
- // the image is no longer an 'Original' one
- CopyMandatoryEntry(0x0008,0x0008,"DERIVED\\PRIMARY","CS");
+ // create 'Referenced SOP Class UID' from 'SOP Class UID'
+
+ DataEntry *e_0008_1150 = DataEntry::New(0x0008, 0x1150, "UI");
+ e_0008_1150->SetString( e_0008_0016->GetString());
+ sqi->AddEntry(e_0008_1150);
+ e_0008_1150->Delete();
+
+ // create 'Referenced SOP Instance UID' from 'SOP Instance UID'
+ // DataEntry *e_0008_0018 = FileInternal->GetDataEntry(0x0008, 0x0018);
+
+ DataEntry *e_0008_1155 = DataEntry::New(0x0008, 0x1155, "UI");
+ e_0008_1155->SetString( e_0008_0018->GetString());
+ sqi->AddEntry(e_0008_1155);
+ e_0008_1155->Delete();
+
+ sis->AddSQItem(sqi,1);
+ sqi->Delete();
+
+ // temporarily replaces any previous 'Source Image Sequence'
+ Archive->Push(sis);
+ sis->Delete();
+ // FIXME : is 'Image Type' *really* depending on the presence of 'SOP Class UID'?
+
+ if ( ContentType == FILTERED_IMAGE) // the user *knows* he just modified the pixels
+ {
+ DataEntry *e_0008_0008 = FileInternal->GetDataEntry(0x0008, 0x0008);
+ if ( e_0008_0008)
+ {
+ std::string imageType = e_0008_0008->GetString();
+ std::string::size_type p = imageType.find("ORIGINAL");
+ if (p == 0) // image is ORIGINAL one
+ {
+ // the image is no longer an 'Original' one
+ CopyMandatoryEntry(0x0008,0x0008,"DERIVED\\PRIMARY","CS");
+ }
+ // if Image Type was not ORIGINAL\..., we keep it.
+ }
+ else // 0008_0008 was missing, wee add it.
+ {
+ CopyMandatoryEntry(0x0008,0x0008,"DERIVED\\PRIMARY","CS");
+ }
+ }