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
 "BeginSelectImages" and "EndSelectImages"
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

izaque

Brazil
95 Posts

Posted - Feb 28 2012 :  13:07:31  Show Profile  Reply
Hi, after using "BeginSelectImages" and "EndSelectImages" when I add an image with the command line "iPosicao: = ImageEnMView1.AppendImage" occurs the following message:
I scan the first image, and when I scan the second image it throws an exception:

Component ImageEnMView1.AppendImage;
List index out of bounds (-1)

I also can not select the first image before the second scan.
How do I proceed?

OS Windows 7 Ultimate 64bit SP1, 3.1.2 ImageEn
I 5 Core, 4GB Memory, 4GB Memory Paging

fab

1310 Posts

Posted - Feb 28 2012 :  13:40:24  Show Profile  Reply
Hi,
between BeginSelectImages and EndSelectionImages only SelectedImage[] can be used. They are useful only to select multiple images using SelectedImage[] property.
You should not call AppendImage or any other method between them.
Go to Top of Page

izaque

Brazil
95 Posts

Posted - Feb 28 2012 :  13:52:23  Show Profile  Reply
Exactly, but I did not do it, I loaded all the images and EndSelectImages BeginSelectImages between, and after that, I click a button that scans images, using the the line "iPosicao: ImageEnMView1.AppendImage =", and it occurs only in the second scanned image, does not occur in the first scanned image. This problem does not occur when not using the BeginSelectImages and EndSelectImages. It is as if ImageEnMView is locked after I use the Begin and EndSelect, because it also can not select the first scanned image.
Go to Top of Page

fab

1310 Posts

Posted - Feb 28 2012 :  14:13:23  Show Profile  Reply
I'm sorry, I cannot understand very well. Could you post just few lines of code that replicate this problem?
Go to Top of Page

izaque

Brazil
95 Posts

Posted - Feb 28 2012 :  14:35:49  Show Profile  Reply
Sorry my English, I'm Brazilian!

This is the code I load all the images:


iemvThumb.Clear;
ievImagem.Clear;
gbImagem.Caption := '';

// izaque - 23/02/2012 - 8097
if (bUtilizaLeituraSomenteTiff) then
iemvThumb.BeginSelectImages; // Here I start to load images

for iContador := 1 to 9999 do
begin
sArquivoOrigem := NomeImagem(sPastaImagens, iContador);
if (FileExists(sArquivoOrigem)) then
begin
sArquivoDestino := NomeImagemScanner(iContador);
if CopyFile(PChar(sArquivoOrigem), PChar(sArquivoDestino), FALSE) then
begin
// izaque - 23/02/2012 - 8097
if not(bUtilizaLeituraSomenteTiff) then
begin
iPosicao := iemvThumb.AppendImage; / / Here I add pictures, get index, SetImageFromFile
iemvThumb.SetImageFromFile(iPosicao, sArquivoDestino); / / Problem with "Out Of Memory"
iemvThumb.ImageBottomText[iPosicao].Caption := 'Página ' + IntToStr(iPosicao + 1);
end
else iemvThumb.MIO.LoadFromFileTIFF(sArquivoDestino);
end
else raise Exception.Create('Não foi possível copiar a imagem ' + sArquivoOrigem + #13 +
'para a pasta ' + sPastaScanner + ' !');
end
else Break;
end;

if (iemvThumb.ImageCount > 0) then
begin
iemvThumb.SelectedImage := 0;
iemvThumbImageSelect(Self, 0);

// izaque - 23/02/2012 - 8097
if (bUtilizaLeituraSomenteTiff) then
begin
for i := 0 to iemvThumb.ImageCount - 1 do
iemvThumb.ImageBottomText.Caption := 'Página ' + IntToStr(i + 1);
iemvThumb.EndSelectImages; // Here I finish loading the images
//iemvThumb.Deselect;
iemvThumb.SelectedImage := 0;
iemvThumbImageSelect(Self, iemvThumb.SelectedImage);
end;
end;
iemvThumb.SetFocus;



------------------------------------------------------------------
[i]This is the code that scans the image:


// This code is independent, I'm only scanning.

if (iemvImagensScanner.MIO.Acquire(ieaTWain)) then
begin
CursorVelho := Screen.Cursor;
Screen.Cursor := crHourGlass;
try
for iContador := 0 to iemvImagensScanner.ImageCount - 1 do
begin
if (rbPretoBranco.Checked) then
iemvImagensScanner.MIO.Params[iContador].TIFF_Compression := ioTIFF_G4FAX
else begin
// izaque - 23/02/2012 - 8097
iemvImagensScanner.MIO.Params[iContador].TIFF_Compression := ioTIFF_JPEG;
iemvImagensScanner.MIO.Params[iContador].JPEG_DCTMethod := ioJPEG_ISLOW;
iemvImagensScanner.MIO.Params[iContador].TIFF_JPEGColorSpace := ioJPEG_YCbCrK; //ioJPEG_RGB
iemvImagensScanner.MIO.Params[iContador].BitsPerSample := 8;
iemvImagensScanner.MIO.Params[iContador].SamplesPerPixel := 3;
iemvImagensScanner.MIO.Params[iContador].TIFF_JPEGQuality := iQualidadeJpeg;
end;
end;

iemvImagensScanner.MIO.SaveToFileTIFF(sArquivoOrigem);
Application.ProcessMessages;

for iContador := 0 to iemvImagensScanner.ImageCount - 1 do
begin
iPaginaScanneada := iPaginaScanneada + 1;
sArquivoDestino := NomeImagemScanner(iPagina + iPaginaScanneada);
ExtractTIFFImageFile(sArquivoOrigem, sArquivoDestino, iContador);
Application.ProcessMessages;
end;
finally
Screen.Cursor := CursorVelho;
end;
end;

if (iPaginaScanneada = 0) then
raise Exception.Create('Nenhuma imagem foi scanneada !');

CursorVelho := Screen.Cursor;
Screen.Cursor := crHourGlass;
try
// Copia as imagens para o servidor de imagens
for iContador := iPagina + 1 to iPagina + iPaginaScanneada do
begin
// Procura a imagem scanneada
sArquivoOrigem := NomeImagemScanner(iContador);
if (FileExists(sArquivoOrigem)) then
begin
// Copia a imagems para o servidor de imagens
sArquivoDestino := NomeImagem(sPastaImagens, iContador);
if (CopyFile(PChar(sArquivoOrigem), PChar(sArquivoDestino), FALSE)) then
begin
// Inclui a imagem no thumbnail
iemvThumb.Update;
iemvThumb.Refresh;
iPosicao := iemvThumb.AppendImage;
iemvThumb.SetImageFromFile(iPosicao, sArquivoOrigem);
iemvThumb.ImageBottomText[iPosicao].Caption := 'Página ' + IntToStr(iPosicao + 1);

// izaque - 28/02/2012
iemvThumb.SelectedImage := iPosicao;

// Grava os dados da imagem
GravarImagens(iContador)
end
else raise Exception.Create('Não foi possível copiar a imagem ' + sArquivoOrigem + #13 +
'para a pasta ' + sPastaImagens + ' !');
Application.ProcessMessages;
end
else Break;
end;
Go to Top of Page

izaque

Brazil
95 Posts

Posted - Feb 28 2012 :  14:50:24  Show Profile  Reply
I'm using "BeginSelecImages" and "EndSelectImages" because I have a problem of "Out Of Memory" when I load several images with iemvThumb.SetImageFromFile (.., ..), about 100 files, each with 413KB. Then try to circumvent this problem by using ImageEnMView.Mio.LoadFromFileTiff ();

iemvThumb.MIO.LoadFromFileTIFF (sArquivoDestino);

With LoadFromFileTIFF, can carry up to 8000 images with 413KB each, though without exception "Out Of Memory". But if I do not use the BeginSelectImages EndSelectImages and 8000 can not load images, only 6000 images.

Excuse me the trouble!
Go to Top of Page

fab

1310 Posts

Posted - Feb 28 2012 :  15:26:10  Show Profile  Reply
Wow, very "few" lines...
However I see:

if (bUtilizaLeituraSomenteTiff) then
iemvThumb.BeginSelectImages; // Here I start to load images
...etc...etc..
iPosicao := iemvThumb.AppendImage;
...and...
iemvThumb.MIO.LoadFromFileTIFF

As already specified, you cannot do it.
Which is the actual size of your images (413KB is the compressed size) in pixels and its bit depth?

I have no problems executing a loop like this:

for i:=1 to 10000 do
ImageEnMView1.AppendImage('test.tiff');

Where test.tiff is a black/white image of 2550x4200x1bpp, using version 4.1.0. It allocates about 70MB of memory and a cache file on disk which contains the actual images.
Go to Top of Page

izaque

Brazil
95 Posts

Posted - Feb 29 2012 :  04:33:23  Show Profile  Reply
The current image size is 413KB and 24 bits, compressed with TIFF_Compression: = ioTIFF_JPEG and TIFF_JPEGColorSpace: = ioJPEG_YCbCrK;
Since the question of BeginSelectImages and EndSelectImages, which may be? If I use the EndSelectImages the ImageEnMView should not unlock? Is there a command to force it to unlock? I'll be attaching the picture this time. I do not know why, but the properties of the image does not show the compression method. Please rename the file "R00007921.png" to R00007921.tif

Go to Top of Page

izaque

Brazil
95 Posts

Posted - Feb 29 2012 :  04:44:48  Show Profile  Reply
for i: = 1 to 10000 in
begin
iPosicao: = iemvThumb.AppendImage;
iemvThumb.SetImageFromFile (iPosicao, sArquivoOrigem) / / Problem "Out Of Memory" in this line
end;

Please test with the image of the replica before.
Go to Top of Page

fab

1310 Posts

Posted - Feb 29 2012 :  04:56:03  Show Profile  Reply
You should consider to use LockUpdate/UnLockUpdate instead of BeginSelectImages/EndSelectImages.

However, your image (2550x3510x3) requires about 25MB to be stored. 8000 images require 195GB. Do you have this space free?
You should use another way to compose this big tiff, maybe processing a page at the time without loading them in TImageEnMView. For example TImageEnView.IO has InsertToFileTIFF for this.
Go to Top of Page

izaque

Brazil
95 Posts

Posted - Feb 29 2012 :  07:31:34  Show Profile  Reply
I do not understand why the 195GB, but I have this space. But unfortunately, this is how our client should be told.

I tried using LockUpdate and UnlockUpdate, but the same happened with the BeginSelect ..
He does not unlock the component, I can scan without the error that occurred in the line "iPosicao: = iemvThumb.AppendImage," but I can not unlock the component, and after the "UnlockUpdate" I used iemvThumb.Update and iemvThumb.Refresh and not resolved. Do you have any idea Fabrízio?

Thanks.
Go to Top of Page

fab

1310 Posts

Posted - Feb 29 2012 :  09:33:06  Show Profile  Reply
quote:
I do not understand why the 195GB, but I have this space.


25MB per image Multiplied by 8000 = 195GB


quote:
I tried using LockUpdate and UnlockUpdate, but the same happened with the BeginSelect ..
He does not unlock the component, I can scan without the error that occurred in the line "iPosicao: = iemvThumb.AppendImage," but I can not unlock the component, and after the "UnlockUpdate" I used iemvThumb.Update and iemvThumb.Refresh and not resolved. Do you have any idea Fabrízio?


I'm sorry, no. Using version 4.1.0 and a simple loading loop I can load even 10000 images of 25MB each one, without problems. Even surrounding the loop among LockUpdate and UnLockUpdate it works.
Go to Top of Page

izaque

Brazil
95 Posts

Posted - Feb 29 2012 :  09:53:27  Show Profile  Reply
I do not know why, but when I use EndSelectImages again, works there, he unlocked the screen.

Thanks Fabrizio.
Go to Top of Page

izaque

Brazil
95 Posts

Posted - Feb 29 2012 :  10:02:30  Show Profile  Reply
Correcting again this way:
iemvThumb.EndSelectImages;
iemvThumb.EndSelectImages;
Go to Top of Page

fab

1310 Posts

Posted - Feb 29 2012 :  10:29:41  Show Profile  Reply
EndSelectImages, other than finishing selection it also calls Update().

I don't know if above helps you.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: