Hi,
there isn't a method to save the selected area directly to a file or stream.
SaveSelectionToStream saves the selection data (coordinates, etc...) but not the selected pixels.
For this reason it is necessary to use a temporary buffer to contain the selected area. There are several ways to do it. The simplest is to use Undo mechanism:
// note: CropSel() returns the whole image when no selection exists
ImageEnView1.Proc.CropSel();
ImageEnView1.IO.SaveToStreamJpeg(aStream);
ImageEnView1.Proc.Undo();
Another way uses a temporary TIEBitmap (here named "bmp"):
if ImageEnView1.Selected then
begin
bmp := TIEBitmap.Create(ImageEnView1.SelectedRect.width, ImageEnView1.SelectedRect.height);
ImageEnView1.CopySelectionToIEBitmap(bmp);
bmp.Write(aStream, ioJPEG);
bmp.free;
end;
note1: exceptions handling not shown.
note2: ioJPEG defined in imageenio unit.