Board index » delphi » problemns with tbitmap savetofile method

problemns with tbitmap savetofile method

Im building an application and i need to create aprox. 250 .bmp files, some
of them
are really big (around 30 MB).
I receive the message eoutofresources during execution.

Im using windows nt 4.
I can check the amount of memory my program uses but thats not he problem,
i think the problem is that i use too many windows handlers.

My code is like this:

 My bitmap:= Tbitmap.Create;
 I fill the bitmap object using the canvas property

I save the bitmap using MyBitmap.SaveToFile;
MyBitmap.ReleaseHandle;
MyBitmap.free;

I dont know what im doing worng, but i allways receive the outofresources
message.
I test my program with the same series of bmp creation and the error
message come in different moments, sometime at the beginning of the series,
sometimes at the end.

Maybe the free method of the tbitmap class is not working good.

Maybe I should create the bmp using write and assignfile, has anybody done
this before??? Create a bitmap in delphi using the bmp structure instead of
the tbitmap class??

Does anybody know what am I doing wrong??

Thank you.
                                                           Luis Avila.

 

Re:problemns with tbitmap savetofile method


How about just creating and freeing the bitmap once, instead of creating and
freeing it for each bitmap you want to process?
-Howard

Re:problemns with tbitmap savetofile method


thank you, but ive already done that and I got the same error .

Howard Moon escribi en mensaje <8s73kv$9...@bornews.borland.com>...

Quote
>How about just creating and freeing the bitmap once, instead of creating
and
>freeing it for each bitmap you want to process?
>-Howard

Re:problemns with tbitmap savetofile method


In <39e70eb8_1@dnews>, Luis Avila carefully scribed:

Quote

>  My bitmap:= Tbitmap.Create;
>  I fill the bitmap object using the canvas property

> I save the bitmap using MyBitmap.SaveToFile;
> MyBitmap.ReleaseHandle;
> MyBitmap.free;

Luis,

As I understand it, ReleaseHandle simply disconnects the underlying Windows bitmap from your TBitmap object, but doesn't destroy it - the assumption is that some other object is taking ownership.  So when you destroy your TBitmap in the following line, the underlying Windows bitmap is left{*word*154} in space.

Try removing the ReleaseHandle line and see what happens.

Roger Morton
roger.mor...@bigfoot.com

Other Threads