Reputation: 1623
I'm using C++ Builder XE7. Whenever a form resizes I need to rebuild a D2D bitmap, which I create with CreateBitmap(). As this will quickly eat up all video memory, I want to destroy the previous bitmap before creating a new one. Oddly enough I cannot find any information how to destroy this _di_ID2D1Bitmap. I tried the Release() method but that just gives me an AV in line 291 of systobj.h.
What is the proper way to destroy a _di_ID2D1Bitmap?
Thanks.
Upvotes: 0
Views: 600
Reputation: 951
_di_ID2D1Bitmap
is a DelphiInterface
. An interface reference in Delphi is a pointer to pointer to an IMT. So, a variable of _di_ID2D1Bitmap
type is a pointer.
You don't have to free it manually, because there is an automatic reference counting - ie - when there are no references left, it will be freed automatically. You may check the IInterface._AddRef
and IInterface._Release
methods.
In short, if you have a pointer P
holding just one reference to your ID2D1Bitmap
(ie _di_ID2D1Bitmap
), when you pass it to the CreateBitmap()
it will acquire a ref to the new bitmap while the old one will became with 0 references and will be freed.
Here are some useful reads:
Upvotes: 2