Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-01

TRawImage.PerformEffect: how to properly use this?

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

Hi,

What is the correct way to use TRawImage.PerformEffect? Simply doing:
Image1.Picture.Bitmap.RawImage.PerformEffect(someeffect) will lead to memory loss, due to a getmem() call in PerformEffect.

Without looking at the context I tried freeing the memory allocated by getmem by using freemem inside the PerformEffect method. (You can see this "fix" in the attached patch in
http://bugs.freepascal.org/view.php?id=21068 )

Now Image1.Picture.Bitmap.RawImage.PerformEffect(someeffect) doesn't leak memory anymore, but after rebuilding Lazarus the IDE crashes (at least on Win7).
Undoing my "fix" and rebuilding Lazarus with -gh shows that Lazarus does not leak memory, even after numerous calls to TRawImage.PerformEffect (made by TImageList).

So either this simple
Image1.Picture.Bitmap.RawImage.PerformEffect(someeffect) is plain wrong usage, or TImageList does something special to avoid this memory leak? (I looked at the sources of TImageList but I'm obviously not clever enough to see the solution.)

Can someone shed some light on this?

Bart

Reply by email

Mattias Gaertner
to Bart
Show quoted text 26 lines
Hi, What is the correct way to use TRawImage.PerformEffect? Simply doing: Image1.Picture.Bitmap.RawImage.PerformEffect(someeffect) will lead to memory loss, due to a getmem() call in PerformEffect. Without looking at the context I tried freeing the memory allocated by getmem by using freemem inside the PerformEffect method. (You can see this "fix" in the attached patch in http://bugs.freepascal.org/view.php?id=21068 ) Now Image1.Picture.Bitmap.RawImage.PerformEffect(someeffect) doesn't leak memory anymore, but after rebuilding Lazarus the IDE crashes (at least on Win7). Undoing my "fix" and rebuilding Lazarus with -gh shows that Lazarus does not leak memory, even after numerous calls to TRawImage.PerformEffect (made by TImageList). So either this simple Image1.Picture.Bitmap.RawImage.PerformEffect(someeffect) is plain wrong usage, or TImageList does something special to avoid this memory leak? (I looked at the sources of TImageList but I'm obviously not clever enough to see the solution.) Can someone shed some light on this?

TCustomImageList frees the memory itself.
I added an option, so you can choose to free the memory.

Mattias

Reply by email

Paul Ishenin
to Bart: What is the correct way to use TRawImage.PerformEffect? Simply doing:…

20.01.12 1:52, Bart ?????:

Hi, What is the correct way to use TRawImage.PerformEffect?

This is internal method which is used by imagelist to perform highlight/shadow/disable effect on 32bpp images which are stored exactly in internal imagelist image format.

Since the method was written for internal imagelist usage the allocated memory may be deallocated by imagelist itself.

Best regards,
Paul Ishenin

Reply by email