| 379 | } |
| 380 | |
| 381 | void PixelBuffer::ExportToFile( const std::wstring& FilePath ) |
| 382 | { |
| 383 | // Create the buffer. We will release it after all is done. |
| 384 | ReadbackBuffer TempBuffer; |
| 385 | TempBuffer.Create(L"Temporary Readback Buffer", m_Width * m_Height, (uint32_t)BytesPerPixel(m_Format)); |
| 386 | |
| 387 | CommandContext::ReadbackTexture2D(TempBuffer, *this); |
| 388 | |
| 389 | // Retrieve a CPU-visible pointer to the buffer memory. Map the whole range for reading. |
| 390 | void* Memory = TempBuffer.Map(); |
| 391 | |
| 392 | // Open the file and write the header followed by the texel data. |
| 393 | std::ofstream OutFile(FilePath, std::ios::out | std::ios::binary); |
| 394 | OutFile.write((const char*)&m_Format, 4); |
| 395 | OutFile.write((const char*)&m_Width, 4); // Pitch |
| 396 | OutFile.write((const char*)&m_Width, 4); |
| 397 | OutFile.write((const char*)&m_Height, 4); |
| 398 | OutFile.write((const char*)Memory, TempBuffer.GetBufferSize()); |
| 399 | OutFile.close(); |
| 400 | |
| 401 | // No values were written to the buffer, so use a null range when unmapping. |
| 402 | TempBuffer.Unmap(); |
| 403 | } |
nothing calls this directly
no test coverage detected