PresentationStates are normally saved as external files but sometimes people may want to store them within the associated DicomImage.

Following sample code shows a quick way how to do it.

DicomObjects.NET

 DicomDataSet ps = image.PresentationState; 
 DicomDataSetCollection psSequence = new DicomDataSetCollection();
 psSequence.Add(ps);
 int group = 19; // use private DICOM tag to store Presentation State
 int element = 1020;
 image.DataSet.Add(group, element, "SQ", psSequence);
And to pull out PresentationState out of DicomImage:

 int group = 19;
 int element = 1020;
 DicomDataSetCollection psSequence = image.DataSet[group, element].Value as DicomDataSetCollection;
 if(psSequence.Any())
	image.PresentationState = psSequence.First();

DicomObjects.COM

Dim ps As DicomDataSet
Dim sq As New DicomDataSets
Set ps = DicomImage.PresentationState
sq.Add ps
DicomImage.Attributes.AddExplicit group, element, "SQ", sq
And to pull out PresentationState out of DicomImage:

Dim ps As DicomDataSet
Dim sq As New DicomDataSets
Set sq = DicomImage.Attributes(group, element).value 
Set ps = sq(1) 
DicomImage.PresentationState = ps

Plase NOTE there is NO standard DICOM data element where you can store Presentation State data, so a good practice is to use Private Data Element. It is of course extremely unlikely that any other application will find/use your presentation state if handlied this way, so this really is a “hack” which is not recommended and should be avoided if possible