我想在本地 TBitmap
上绘制并返回它。因为我在主线程之外,所以在使用之前必须锁定 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.
关于c++ - 锁定后我应该解锁 TBitmap Canvas 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53040477/