我应该在锁定后解锁 TBitmap canvas 吗?

Should I unlock TBitmap canvas after locking it?

我想在本地TBitmap和return上画画。因为我在主线程之外,所以在使用它之前必须锁定canvas。 (How threadsafe is TBitmap)

我是否必须解锁 canvas,或者 TBitmap 析构函数会为我解锁?在位图上绘制后解锁此函数中的 canvas 是否安全,并在我想读取位图时再次锁定它,或者如果我这样做可以清除 canvas 吗?

std::shared_ptr<TBitmap> f() {
    std::shared_ptr<TBitmap> bmp(new TBitmap);
    bmp->Canvas->Lock();
    // draw on bitmap
    return bmp;
}

正如雷米评论的那样:

The bitmap destructor will NOT unlock the canvas for you. If you explicitly lock it, you must explicitly unlock it. And yes, once you unlock the canvas, the main UI thread is free to clear the bitmap resources.