public void Save( System.IO.FileInfo _FileName )
{
XmlDocument Doc = new XmlDocument();
XmlElement Root = Doc.CreateElement( "CameraCalibration" );
Doc.AppendChild( Root );
// Set reference image data
XmlElement ImageRefElement = Doc.CreateElement( "ImageReference" );
Root.AppendChild( ImageRefElement );
ImageRefElement.SetAttribute( "Name", m_ReferenceImageName != null ? m_ReferenceImageName : "unknown" );
ImageRefElement.SetAttribute( "Width", m_ReferenceImageWidth.ToString() );
ImageRefElement.SetAttribute( "Height", m_ReferenceImageHeight.ToString() );
m_CameraShotInfos.Save( ImageRefElement );
// Set thumbnail
XmlElement ThumbnailElement = Doc.CreateElement( "Thumbnail" );
ImageRefElement.AppendChild( ThumbnailElement );
ThumbnailElement.SetAttribute( "Width", m_Thumbnail.GetLength(0).ToString() );
ThumbnailElement.SetAttribute( "Height", m_Thumbnail.GetLength(1).ToString() );
byte[] PackedThumbnail = new byte[m_Thumbnail.Length];
for ( int Y=0; Y < m_Thumbnail.GetLength(1); Y++ )
for ( int X=0; X < m_Thumbnail.GetLength(0); X++ )
PackedThumbnail[m_Thumbnail.GetLength(0)*Y+X] = m_Thumbnail[X,Y];
string PackedThumbnailString = System.Convert.ToBase64String( PackedThumbnail );
XmlCDataSection ThumbnailCData = Doc.CreateCDataSection( PackedThumbnailString );
ThumbnailElement.AppendChild( ThumbnailCData );
// Write reflectance infos
XmlElement ReflectanceProbesElement = Doc.CreateElement( "ReflectanceProbes" );
Root.AppendChild( ReflectanceProbesElement );
foreach ( Probe P in m_Reflectances )
{
XmlElement ProbeElement = Doc.CreateElement( "Probe" );
ReflectanceProbesElement.AppendChild( ProbeElement );
ProbeElement.SetAttribute( "StandardReflectance", P.StandardReflectance.ToString() );
P.Save( ProbeElement );
}
Doc.Save( _FileName.FullName );
}