Image Update

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Post Reply
Andrew McIsaac
Active Poster
Active Poster
Posts: 17
Joined: Fri Nov 06, 2020 12:36 am

Image Update

Post by Andrew McIsaac »

Good evening,
Working with C++ Ent. 10.4 on Windows 10 Pro.
Multidevice - Windows 32 bit.

I have a SQLite database that has a column of image names with Path and File Name.

I "SELECT" the image filename through a query.
file_name_d = Form_Display->FDQuery_Display->FieldByName("File_Name")->AsString; // File_Name has dir as well = D:\blah blah blah\file.jpg

The image is updated by
Image_P1->Bitmap->LoadFromFile(file_name_d);
Image_P1->Repaint();

I can cycle through, and put next image as Image_P1 ...
This works well, until It develops an out of memory error ...

Is there a way to clean / wipe any memory of the image before recycling it ?

Thank you.
Andrew
Lena
BCBJ Master
BCBJ Master
Posts: 715
Joined: Sun Feb 06, 2011 1:28 pm

Re: Image Update

Post by Lena »

Code: Select all

Image1->Picture->Bitmap->FreeImage();
Image1->Picture->Bitmap = NULL; 
?
Andrew McIsaac
Active Poster
Active Poster
Posts: 17
Joined: Fri Nov 06, 2020 12:36 am

Re: Image Update

Post by Andrew McIsaac »

I will try tonight
Thank you
Andrew McIsaac
Active Poster
Active Poster
Posts: 17
Joined: Fri Nov 06, 2020 12:36 am

Re: Image Update

Post by Andrew McIsaac »

No, this didn't resolve.
rlebeau
BCBJ Author
BCBJ Author
Posts: 1759
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA
Contact:

Re: Image Update

Post by rlebeau »

Lena wrote: Wed Nov 25, 2020 4:40 am

Code: Select all

Image1->Picture->Bitmap->FreeImage();
Image1->Picture->Bitmap = NULL; 
That will only work in VCL, not in FMX. There is no Picture property in FMX's TImage, and FMX's TBitmap does not have a FreeImage() method (it does have a FreeHandle() method, though).
Remy Lebeau (TeamB)
Lebeau Software
rlebeau
BCBJ Author
BCBJ Author
Posts: 1759
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA
Contact:

Re: Image Update

Post by rlebeau »

Andrew McIsaac wrote: Tue Nov 24, 2020 1:45 am The image is updated by
Image_P1->Bitmap->LoadFromFile(file_name_d);
Image_P1->Repaint();

I can cycle through, and put next image as Image_P1 ...
This works well, until It develops an out of memory error ...

Is there a way to clean / wipe any memory of the image before recycling it ?
Are you sure that is the real problem? I would consider it a major bug if LoadFromFile() did not perform all necessary cleanups before loading the new file.

Does this exhibit the same problem?

Code: Select all

TBitmap *Bmp = new TBitmap(file_name_d);
try {
    Image_P1->Bitmap = Bmp;
    // or: Image_P1->Bitmap->Assign(Bmp);
}
__finally {
    delete Bmp;
}
Image_P1->Repaint();
Remy Lebeau (TeamB)
Lebeau Software
Andrew McIsaac
Active Poster
Active Poster
Posts: 17
Joined: Fri Nov 06, 2020 12:36 am

Re: Image Update

Post by Andrew McIsaac »

Thank you,
I will try tonight.
Andrew McIsaac
Active Poster
Active Poster
Posts: 17
Joined: Fri Nov 06, 2020 12:36 am

Re: Image Update

Post by Andrew McIsaac »

Still having difficulties.

I have a new computer - with lots of memory - so I know that is not the issue.

Program starts and appears to be running well -then craps out - last run was at about the 240th image being displayed.

FMX.Surfaces at
procedure TBitmapSurface.SetSize(const AWidth, AHeight: Integer; const APixelFormat: TPixelFormat);

ReallocMem(FBits, NumOfBytes); is highlighted.

Error is Exception class EOutofMemory with Message 'Out of Memory'

This program worked well - same code for Windows 64 bit - but keeps crapping out on Windows 32 bit. The only difference now is I want a database (SQLite) to store the image names. Earlier - version just listed names into a ListBox.
I would prefer 64 bit, but there are no solutions ? for FireDac database - on a Standalone Executable for 64 bit.
( my other posting )

Frustrating -
on 32 bit database is great - but images fail
64 bit images are good, but no DB.

Ideas ?

Thank you.
Andrew
Andrew McIsaac
Active Poster
Active Poster
Posts: 17
Joined: Fri Nov 06, 2020 12:36 am

Re: Image Update

Post by Andrew McIsaac »

If I run my program on 64 Bit, with
Project Options :
Packages | Runtime Packages | Link with runtime packages = true
and
C++ Linker | Link with Dynamoc RTL = true

Then my program runs exactly the way I want, tested - went through 1400 images perfectly.
Problem is this is not a stand alone executable anymore, and cannot be distributed as is.

This ties to my other post - how to make FireDac portable on Win64 ?

Any ideas
Thank you.
Andrew
Post Reply