ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Using SaveSelectionToStream

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
JensFudge Posted - Sep 01 2011 : 06:20:39
Hi

I am wondering why there isnt a SaveSelectionToStreamJpeg method..

Basically this is what I am trying to accomplish:

aStream := TMemoryStream.Create;
if ImageEnView1.Selected then
ImageEnView1.SaveSelectionToStream(aStream)
else
ImageEnView1.io.SaveToStreamJpeg(aStream);

The stream I will later add to a Blobfield in a database.
It works perfectly with SaveToStreamJpeg, but I get garbage using SaveSelectionToStream.

I have set the MouseInteract.select to true

How would one accomplish this?

Thanks for a great set of components!!

Jens Fudge
2   L A T E S T    R E P L I E S    (Newest First)
JensFudge Posted - Sep 06 2011 : 06:36:19
Thanks, worked perfectly

Jens Fudge
fab Posted - Sep 01 2011 : 06:44:21
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.