In the following part of my UWP application, I have a performance bottle-neck of creating a lot of large TIFF files. Is there any way to make it run faster without too many conversions and data copies? Due to platform restrictions, I am not allowed to use fopen
(access denied).
std::ostringstream output_TIFF_stream;
TIFF* ofo = TIFFStreamOpen("MemTIFF", &output_TIFF_stream);
...
TIFFWriteRawStrip(ofo, 0, currentFrame->image, bufferSize);
TIFFClose(ofo);
auto str = output_TIFF_stream.str();
auto size = str.length();
unsigned char* chars = (unsigned char*)str.c_str();
auto byteArray = ref new Array<unsigned char>(chars, size);
DataWriter^ dataWriter = ref new DataWriter();
dataWriter->WriteBytes(byteArray);
IBuffer^ buffer = dataWriter->DetachBuffer();
create_task(_destinationFolder->CreateFileAsync(fileName))
.then([](StorageFile^ file) {
return file->OpenTransactedWriteAsync();
})
.then([buffer](StorageStreamTransaction^ transaction) {
create_task(transaction->Stream->WriteAsync(buffer)).wait();
return transaction;
})
.then([](StorageStreamTransaction^ transaction) {
return create_task(transaction->CommitAsync());
})
.wait();
I have tried broadFileSystemAccess
but it has same problem. fopen
still doesn't work.
I haven't found any way to speed up I/O operations in UWP. If you are writing an I/O speed critical application. I recommend using WPF or if you friendly with WRL, then the new Windows APP SDK.