ImageEn Forum
ImageEn Forum
Profile | Join | Active Topics | Search | Forum FAQ
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn Support and Discussion Forum
 "BeginSelectImages" and "EndSelectImages"

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

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

  Attach a photo to your post
 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
izaque Posted - Feb 28 2012 : 13:07:31
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
14   L A T E S T    R E P L I E S    (Newest First)
fab Posted - Feb 29 2012 : 10:29:41
EndSelectImages, other than finishing selection it also calls Update().

I don't know if above helps you.
izaque Posted - Feb 29 2012 : 10:02:30
Correcting again this way:
iemvThumb.EndSelectImages;
iemvThumb.EndSelectImages;
izaque Posted - Feb 29 2012 : 09:53:27
I do not know why, but when I use EndSelectImages again, works there, he unlocked the screen.

Thanks Fabrizio.
fab Posted - Feb 29 2012 : 09:33:06
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.
izaque Posted - Feb 29 2012 : 07:31:34
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.
fab Posted - Feb 29 2012 : 04:56:03
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.
izaque Posted - Feb 29 2012 : 04:44:48
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.
izaque Posted - Feb 29 2012 : 04:33:23
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

fab Posted - Feb 28 2012 : 15:26:10
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.
izaque Posted - Feb 28 2012 : 14:50:24
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!
izaque Posted - Feb 28 2012 : 14:35:49
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;
fab Posted - Feb 28 2012 : 14:13:23
I'm sorry, I cannot understand very well. Could you post just few lines of code that replicate this problem?
izaque Posted - Feb 28 2012 : 13:52:23
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.
fab Posted - Feb 28 2012 : 13:40:24
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.