private void buttonSaveCalibratedImage_Click( object sender, EventArgs e )
{
if ( m_Texture == null )
{ // No image loaded you moron!
MessageBox( "Can't save calibrated texture as no capture has been done yet!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
return;
}
string ImageNamePNG = System.IO.Path.GetFileNameWithoutExtension( m_ImageFileName.FullName ) + ".png";
string OldFileName = GetRegKey( "LastCalibratedTextureFilename", System.IO.Path.Combine( System.IO.Path.GetDirectoryName( m_ImageFileName.FullName ), ImageNamePNG ) );
saveFileDialogCalibratedImage.InitialDirectory = System.IO.Path.GetDirectoryName( OldFileName );
// saveFileDialogCalibratedImage.FileName = System.IO.Path.GetFileName( OldFileName );
saveFileDialogCalibratedImage.FileName = ImageNamePNG;
if ( saveFileDialogCalibratedImage.ShowDialog( this ) != DialogResult.OK )
return;
SetRegKey( "LastCalibratedTextureFilename", saveFileDialogCalibratedImage.FileName );
//////////////////////////////////////////////////////////////////////////
// Save actual image
try
{
System.IO.FileInfo TargetFileName = new System.IO.FileInfo( saveFileDialogCalibratedImage.FileName );
string Extension = System.IO.Path.GetExtension( TargetFileName.FullName ).ToUpper();
CalibratedTexture.TARGET_FORMAT Format = CalibratedTexture.TARGET_FORMAT.PNG16;
switch ( Extension )
{
case ".PNG": Format = CalibratedTexture.TARGET_FORMAT.PNG16; break;
case ".TIF":
case ".TIFF":
Format = CalibratedTexture.TARGET_FORMAT.TIFF;
break;
default:
throw new Exception( "Unsupported file extension!" );
}
m_Texture.SavePack( TargetFileName, Format );
}
catch ( Exception _e )
{
MessageBox( "An error occurred while saving the calibrated image:\r\n\r\n", _e );
}
}