c++buildervclc++builder-xe6

TWICImage giving access violation on assignment


I'm trying to use the TWICImage class in C++builder to save an in-memory bitmap to TIFF file. However, any attempt to use the Assign() method on TWICImage gives an access error.

For example:

TBitmap* bmp = new TBitmap();
TWICImage* wic = new TWICImage();
wic->Assign( bmp );

gives the access violation on the third line.


Solution

  • After a bit more digging, the following gives an error on the second and subsequent assignments:

    TBitmap* bmp = new TBitmap();
    for (int i=0; i<10; ++i) {
        std::unique_ptr<TWICImage> wic( new TWICImage() );
        wic->Assign( bmp );
    }
    

    However, if I make the TWICImage pointer static, it all works as expected. So it looks like there is something odd going on in the TWICImage destructor.