Recent

Author Topic: BGRABitmap - copy rectangle  (Read 244 times)

mosquito

  • New Member
  • *
  • Posts: 26
BGRABitmap - copy rectangle
« on: February 23, 2021, 09:48:49 am »
I have a TBGRABitmap in memory, how can I extract a rectangle from this bitmap and copy it to another temporary bitmap?

winni

  • Hero Member
  • *****
  • Posts: 2187
Re: BGRABitmap - copy rectangle
« Reply #1 on: February 23, 2021, 10:41:20 am »
Hi!

Easy:

Code: Pascal  [Select][+][-]
  1. NewBGRAbitmap := TBGRAbitmap.create;
  2. NewBGRAbitmap := OldBGRAbitmap.GetPart (Rect(10,10,100,100));

Done.

Winni

mosquito

  • New Member
  • *
  • Posts: 26
Re: BGRABitmap - copy rectangle
« Reply #2 on: February 23, 2021, 12:03:51 pm »
Thanks, this is just what I was looking for. :D

Roland57

  • Full Member
  • ***
  • Posts: 121
Re: BGRABitmap - copy rectangle
« Reply #3 on: February 23, 2021, 02:40:24 pm »
Hello!

@Winni

The first line isn't required. It would create a memory leak.

Regards.

Roland

winni

  • Hero Member
  • *****
  • Posts: 2187
Re: BGRABitmap - copy rectangle
« Reply #4 on: February 24, 2021, 05:49:49 pm »
Hi Roland.

That depends on the version of BGRAbitmap your using.

Old versions behaved this way: If you did not do a create before the Getpart you got a nice crash.

Nice that it was at long last changed.

Winni

circular

  • Hero Member
  • *****
  • Posts: 3666
    • Personal webpage
Re: BGRABitmap - copy rectangle
« Reply #5 on: February 24, 2021, 06:49:05 pm »
Hmmm nope it has always been a memory leak.

Assigning to the variable replaces the previous pointer.

Maybe you’re thinking of BGRAReplace?
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018