ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Problem in saving lots of ROI to files
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

zhengyuanyi27

35 Posts

Posted - Dec 29 2019 :  00:28:20  Show Profile  Reply
I am using Imageenmview1 to load thousands of images and use ImageEnvect1 to display the image.I want to save the same range of ROI to file for each image which is loaded into the ImageenMview1.
I wrote the following program and it works well if I loads only a few hundreds of images. While I met the following problem when I tried to load thousands of images into Imageenmview1. It seems that I got the same ROI image from the same image after the program executed at a certain number of images.
To make it more clear, the problem is: For example, I load 1000 different images into Imaggenmview1. The following program could save the ROI of Imageenvect1 which load the image from Imageenmview1 to file very well before it comes to No. 231 image. After No. 231 image, all the ROI images saved are the same image. It seems athe after No. 231 image, the Imageenvect1 can't load image from Imageenmview1 and stops at No. 231, thus all the ROI images after No.231 keeps the same.
Might it be caused by full of cache memory? If yes, how to overcome this problem.
Thanks a lot.

for I := sf to ef do
begin
          ImageEnMView1.SelectedImage:=i;
ImageEnVect1.Bitmap.Assign(ImageEnMView1.GetBitmap(ImageEnMView1.SelectedImage));
          Imageenvect1.Update;
          imageenvect1.CopySelectionToBitmap(tempImageEnVect.Bitmap) ;
          tempImageEnVect.Update;
          tempImageEnVect.IO.SaveToFile(imagedir+'\sel_'+inttostr(i)+'.JPG');
          caption:=inttostr(i)+'/'+inttostr(ef);
end;

xequte

5390 Posts

Posted - Jan 01 2020 :  17:41:13  Show Profile  Reply
Hi

I can't see any specifically wrong with the code, you'd need to email me a demo that reproduces it.

However there are more efficient ways to do this that will probably resolve the problem, for example (assuming a rectangular ROI), something like (untested):


bmp := TIEBitmap.create( selWidth, SelHeight );
for I := sf to ef do
begin
  ImageEnMView1.GetTIEBitmap( i ).CopyRectTo( bmp, selX, selY, 0, 0, selWidth, SelHeight );
  bmp.Write( imagedir+'\sel_'+inttostr(i)+'.JPG' );
  ImageEnMView1.ReleaseBitmap( i, False );
  caption := inttostr(i)+'/'+inttostr(ef);
end;
bmp.Free;


See also: https://www.imageen.com/help/TIEBitmap.CopyRectTo.html


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

zhengyuanyi27

35 Posts

Posted - Jul 19 2020 :  05:06:31  Show Profile  Reply
Dear Nigel,
Thanks a lot.
Your code works perfect and the efficiency is greatly improved.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: