| Author |
Topic  |
|
|
andyhill
  
Australia
170 Posts |
Posted - Jan 26 2026 : 18:46:40
|
I have some code gleaned from this forum and modified so as to fetch jpg frames and assemble them into GIF Files. ie is global.
I am having unknown errors *** HERE *** (iImageEnMView.MIO.SaveToFileGIF seems to be locked into a loop always writing to disc ?).
if UniMainModule.MyQuery1.FieldByName('MediaID').AsInteger = 1 then begin
//////////////////////////////////////////////////////////////////
iFilename:= 'C:\RAD-12\UniGUI\ImageMiner\Win64\Debug\temp\'+ClientName+IntToStr(ID)+'.gif';
iImageEnMView:= TImageEnMView.Create(nil);
bsF:= TEDBBlobStream.Create(TBlobField(UniMainModule.MyQuery1.FieldByName('JpgFrames')), bmRead);
bsF.Seek(0, soFromBeginning);
bsP:= TEDBBlobStream.Create(TBlobField(UniMainModule.MyQuery1.FieldByName('JpgFramePos')), bmRead);
bsP.Seek(0, soFromBeginning);
pp:= 0;
bsP.Position:= pp;
//////////////////////////////////////////////////////////////////
while bsP.Position < bsP.Size do begin
bsP.Read(pp, sizeof(pp));
bsF.Position:= pp;
ie.Clear;
ie.IO.LoadFromStreamJpeg(bsF);
////////////////////////////////////////////////////////////////
iWidth:= ie.IEBitmap_Width;
iHeight:= ie.IEBitmap_Height;
try
iIEBitmap:= TIEBitmap.Create(iWidth, iHeight, ie24RGB); // iexDefs
ie.IEBitmap.AssignTo(iIEBitmap);
iIndex:= iImageEnMView.AppendImage;
iImageEnMView.SetIEBitmap(iIndex, iIEBitmap);
try
iImageEnMView.MIO.Params[iIndex].GIF_ImageIndex:= iIndex;
iImageEnMView.ReleaseBitmap(iIndex);
except
end;
finally
iIEBitmap.Free;
end;
end; // while
bsF.Free;
bsP.Free;
//////////////////////////////////////////////////////////////////
*** HERE (NO EXCEPTION - CRASHES INTERNALLY) ***
try
iImageEnMView.MIO.SaveToFileGIF(iFilename);
iImageEnMView.Free;
except
on E: Exception do begin
iImageEnMView.Free;
ShowMessage(E.Message);
end;
end;
end else begin
//////////////////////////////////////////////////////////////////
WinFQFileName:= 'C:\RAD-12\UniGUI\ImageMiner\Win64\Debug\temp\'+ClientName+IntToStr(ID)+'.jpg';
bsF:= TEDBBlobStream.Create(TBlobField(UniMainModule.MyQuery1.FieldByName('JpgFrame')), bmRead);
bsF.Seek(0, soFromBeginning);
ie.Clear;
ie.IO.LoadFromStreamJpeg(bsF);
ie.IO.SaveToFile(WinFQFileName);
bsF.Free;
end; // Media
Andy |
|
|
xequte
    
39327 Posts |
Posted - Jan 27 2026 : 20:13:26
|
Hi Andy
Sorry, I'm out of the office for a few days. Can you try recreating a simple demo that reproduces the issue (working only only local files) so I can look at it when I'm back in the office.
Nigel Xequte Software www.imageen.com
|
 |
|
|
andyhill
  
Australia
170 Posts |
Posted - Jan 27 2026 : 21:24:16
|
The jpg images can be fetched and saved as individual files: image-00.jpg, image-01.jpg, image-02.jpg ... etc. and display normally.
I feel that the AppendImage needs time to be processed internally before moving on to the next image (hundreds of images are iterated), can you give me a ready check before I move onto the next frame ?
Andy |
 |
|
|
andyhill
  
Australia
170 Posts |
Posted - Jan 28 2026 : 00:45:50
|
I tried 200 jpg frames - crashes
100 jpg frames - crashes
50 jpg frames - crashes
20 jpg frames WORKS ???
Andy |
 |
|
|
xequte
    
39327 Posts |
Posted - Jan 28 2026 : 21:23:21
|
Hi Andy
I'm back in the office now, and I can see an issue in your code. It looks like you are calling ReleaseBitmap(), which should only be called after GetBitmap():
http://www.imageen.com/help/TImageEnMView.ReleaseBitmap.html
Also, this code...
iWidth:= ie.IEBitmap_Width;
iHeight:= ie.IEBitmap_Height;
try
iIEBitmap:= TIEBitmap.Create(iWidth, iHeight, ie24RGB); // iexDefs
ie.IEBitmap.AssignTo(iIEBitmap);
iIndex:= iImageEnMView.AppendImage;
iImageEnMView.SetIEBitmap(iIndex, iIEBitmap);
try
iImageEnMView.MIO.Params[iIndex].GIF_ImageIndex:= iIndex;
iImageEnMView.ReleaseBitmap(iIndex);
except
end;
finally
iIEBitmap.Free;
end;
Can be simplified to:
iIndex:= iImageEnMView.AppendImage( ie.IEBitmap );
iImageEnMView.MIO.Params[iIndex].GIF_ImageIndex:= iIndex;
Nigel Xequte Software www.imageen.com
|
 |
|
|
andyhill
  
Australia
170 Posts |
Posted - Jan 30 2026 : 23:57:43
|
Nigel, it did not fix the problem ? Same Problem.
Even changed code to iIndex:= iImageEnMView.AppendImage( ie.IEBitmap ); iImageEnMView.MIO.Params[iIndex].GIF_ImageIndex:= iIndex;
I sent you my sample images, did you test with them ?
200 frames should not be an issue, jpg data added to ImageEnMView should not be an issue ?
Andy
Andy |
 |
|
|
xequte
    
39327 Posts |
Posted - Jan 31 2026 : 03:38:10
|
Hi Andy
Are you able to create a code sample that reproduces the issue without using a database?
Nigel Xequte Software www.imageen.com
|
 |
|
|
andyhill
  
Australia
170 Posts |
Posted - Jan 31 2026 : 13:18:28
|
Nigel, I gave you personally the individual images a few days ago, the code to load them as individual files is below.
SAME CRASH, iImageEnMView.MIO.SaveToFileGIF NEVER RETURNS (STUCK IN WRITING TO DISC LOOP).
////////////////////////////////////////////////////////////////////////
ie:= TImageEnView.Create(nil);
iImageEnMView:= TImageEnMView.Create(nil);
////////////////////////////////////////////////////////////////////////
CurDir:= GetCurrentDir;
if SetCurrentDir('C:\RAD-12\UniGUI\ImageMiner\Win64\Debug\temp') = True then begin
//////////////////////////////////////////////////////////////////////
Found:= FindFirst('*.jpg', faAnyFile, sRec);
try
while Found = 0 do begin
if (sRec.Name[1] <> '.') then begin
if (sRec.Attr and faDirectory) <> faDirectory then begin
//////////////////////////////////////////////////////////////
try
ie.Clear;
ie.IO.LoadFromFileJpeg(PChar(sRec.Name));
iIndex:= iImageEnMView.AppendImage(ie.IEBitmap);
iImageEnMView.MIO.Params[iIndex].GIF_ImageIndex:= iIndex;
FoundImage:= True;
except
end;
end; // faDirectory
end; // '.'
//////////////////////////////////////////////////////////////////
Found:= FindNext(sRec);
end; // while
finally
FindClose(sRec);
end;
end; // SetCurrentDir
SetCurrentDir(CurDir);
ie.Free;
////////////////////////////////////////////////////////////////////////
// Save Gif
try
if FoundImage = True then begin
iImageEnMView.MIO.SaveToFileGIF('C:\RAD-12\UniGUI\ImageMiner\Win64\Debug\temp\Images.gif');
end;
iImageEnMView.Free;
except
on E: Exception do begin
s:= E.Message;
iImageEnMView.Free;
end;
end;
Andy |
 |
|
|
andyhill
  
Australia
170 Posts |
Posted - Jan 31 2026 : 16:28:47
|
Even tried this (below), SAME CRASH !
iImageEnMView:= TImageEnMView.Create(nil);
FoundImage:= False;
try
iImageEnMView.MIO.LoadFromFileZIP('C:\RAD-12\UniGUI\ImageMiner\200-jpg-images.zip');
FoundImage:= True;
finally
if FoundImage = True then begin
iImageEnMView.MIO.SaveToFileGIF('C:\RAD-12\UniGUI\ImageMiner\Win64\Debug\temp\Images.gif');
end;
iImageEnMView.Free;
end;
Andy |
 |
|
|
xequte
    
39327 Posts |
Posted - Jan 31 2026 : 18:51:51
|
Hi Andy
Have you actually confirmed that it is stuck in a write loop, e.g. is progress advancing:
procedure TForm1.ImageEnMView1Progress(Sender: TObject; per: Integer);
begin
ProgressBar1.Position := per;
end;
...
iImageEnMView.OnProgress := ImageEnMView1Progress;
When I run your code on the zip, it takes quite a long time (about 8 minutes) but successfully creates a huge gif file of around 50MB.
Nigel Xequte Software www.imageen.com
|
 |
|
|
andyhill
  
Australia
170 Posts |
Posted - Jan 31 2026 : 20:53:10
|
OK, I will test, I may have bailed out to early ...
My apologies, you were right Nigel, it took a very very very long time (too long in fact to be of value).
Ideally I would have liked jpg >>> mp4 (not gif). Also I need to control the playback frame speed.
So can you provide hints on how to speed all of this up (simplify pallet options / colour depth options / memory magic / ???) as well as setting the playback speed ?
Andy |
 |
|
|
xequte
    
39327 Posts |
Posted - Feb 01 2026 : 15:32:15
|
Hi Andy
GIF is not a great format for this, even optimized it is over 26MB. As you say, MP4 would be better. Image to video is not a big area for ImageEn, naturally. You can output images to AVI easy enough and then you could run an external tool over the file to convert to MP4, e.g. FFMPEG.
Nigel Xequte Software www.imageen.com
|
 |
|
| |
Topic  |
|