【问题标题】:TWICImage giving access violation on assignmentTWICImage 在分配时给出访问冲突
【发布时间】:2023-04-05 14:38:01
【问题描述】:

我正在尝试使用 C++builder 中的 TWICImage 类将内存中的位图保存到 TIFF 文件。但是,任何尝试在 TWICImage 上使用 Assign() 方法都会导致访问错误。

例如:

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

在第三行给出访问冲突。

【问题讨论】:

  • 我无法重现该问题。你能提供更多细节吗?
  • 嗯。它在我尝试过的代码中崩溃,但不是在新项目中。我会看看项目选项。

标签: c++builder vcl c++builder-xe6


【解决方案1】:

经过一番挖掘,以下给出了第二个和后续分配的错误:

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

但是,如果我将 TWICImage 指针设为静态,则一切都会按预期工作。所以看起来 TWICImage 析构函数中发生了一些奇怪的事情。

【讨论】:

    猜你喜欢
    • 2018-03-11
    • 1970-01-01
    • 2017-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    相关资源
    最近更新 更多