Bitmap::FromFile を使用してファイルからビットマップをロードしていますが、その後ディスクから削除したいと思っています。
問題は、ロードされたイメージがアンロードされるまで、Bitmap::FromFile が変更/削除からファイルを完全にロックすることです。
これは、ビットマップをバイナリ ファイルに保存しているためです。したがって、次の順序で実行したいと考えてい
ます。 1. バイナリ ファイルから画像を抽出します
。
2. 画像をロードし
ます。画像リソースを保護するため、プログラム ディレクトリに保存したくありません)
Bitmap::FromFile は、私の試みのようにファイルからロードされたイメージを複製する場合でも、ファイルが削除されないようにロックします:
Bitmap* tempbmp = Bitmap::FromFile(fileanddir.c_str(),false);
Rect temprect( 0, 0, tempbmp->GetWidth(), tempbmp->GetHeight() );
// make the image to be used as a clone to the temporary
// bitmap to avoid file locking
image_to_be_used = tempbmp->Clone(temprect, PixelFormatDontCare);
// delete temporary loaded bitmap since it shouldn't be needed
delete tempbmp;
// delete the file itself, too bad the file is locked
int theresult = remove(tocharptr(fileanddir));
// returns -1, also: manually deleting at this point gives the error
// that the file is being used by another person/program
ファイル自体がロックされないように、ビットマップをロードしたり、メモリにコピーしたりする方法はありますか?
(だから私はそれをロードした後にそれを削除することができます)