Try this:
procedure TForm1.SaveSelection1Click(Sender: TObject);
// Save the selection to a TIFF file
var
iIEBitmap: TIEBitmap;
iImageEnIO: TImageEnIO;
iFilename: string;
begin
// Test for selection
if ImageEnView1.Selected then
begin
// Create the TIEBitmap to hold the selection
iIEBitmap := TIEBitmap.Create;
try
// Copy the selection to the iIEBitmap
ImageEnView1.CopySelectionToIEBitmap(iIEBitmap);
// Create iImageEnIO to save the IEBitmap to a file
iImageEnIO := TImageEnIO.Create(nil);
try
// Set iIEBitmap as the AttachedIEBitmap
iImageEnIO.AttachedIEBitmap := iIEBitmap;
// Build the save picture dialog filter
SavePictureDialog1.Filter := '';
SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'TIF Bitmap (*.tif; *.tiff)|*.tif;*.tiff|';
SavePictureDialog1.FilterIndex := IEFileTypeToGraphicFilterIndex(ImageEnView1.IO.Params.FileType);
SavePictureDialog1.FileName := 'Selection.tif';
SavePictureDialog1.DefaultExt := '.tif';
SavePictureDialog1.Title := 'Save Selection As- ' + SavePictureDialog1.FileName;
if SavePictureDialog1.Execute then
begin
if SavePictureDialog1.FileName <> '' then
begin
Screen.Cursor := crHourGlass;
try
iFilename := SavePictureDialog1.FileName;
// Set the file type as TIFF
iImageEnIO.Params.FileType := ioTIFF;
// Show the IOPreviews Dialog
if iImageEnIO.DoPreviews([ppAUTO]) then
// Save the iIEBitmap as a TIFF
iImageEnIO.SaveToFileTIFF(iFilename);
// Deselect the selection
ImageEnView1.DeSelect;
finally
Screen.Cursor := crDefault;
end;
end;
end;
finally
// Free iImageEnIO
iImageEnIO.Free;
end;
finally
// Free iIEBitmap
iIEBitmap.Free;
end;
end
else
begin
MessageDlg('Please make a selection.', mtWarning, [mbOK], 0);
end;
end;
William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html