diff --git a/renderdoc/api/replay/data_types.h b/renderdoc/api/replay/data_types.h index c1f9d8dd3..8e7a9bbc0 100644 --- a/renderdoc/api/replay/data_types.h +++ b/renderdoc/api/replay/data_types.h @@ -1180,3 +1180,21 @@ pixel. }; DECLARE_REFLECTION_STRUCT(PixelModification); + +DOCUMENT("Contains the bytes and metadata describing a thumbnail."); +struct Thumbnail +{ + DOCUMENT("The :class:`FileType` of the data in the thumbnail."); + FileType type; + + DOCUMENT("The ``bytes`` byte array containing the raw data."); + bytebuf bytes; + + DOCUMENT("The width of the thumbnail image."); + uint32_t width; + + DOCUMENT("The height of the thumbnail image."); + uint32_t height; +}; + +DECLARE_REFLECTION_STRUCT(Thumbnail); diff --git a/renderdoc/api/replay/renderdoc_replay.h b/renderdoc/api/replay/renderdoc_replay.h index 3a1ca5f25..67d667b99 100644 --- a/renderdoc/api/replay/renderdoc_replay.h +++ b/renderdoc/api/replay/renderdoc_replay.h @@ -1515,9 +1515,9 @@ The data is copied internally so it can be destroyed after calling this function :param int maxsize: The largest width or height allowed. If the thumbnail is larger, it's resized. :return: The raw contents of the thumbnail, converted to the desired type at the desired max resolution. -:rtype: ``bytes``. +:rtype: Thumbnail. )"); - virtual bytebuf GetThumbnail(FileType type, uint32_t maxsize) = 0; + virtual Thumbnail GetThumbnail(FileType type, uint32_t maxsize) = 0; protected: ICaptureFile() = default; diff --git a/renderdoc/api/replay/replay_enums.h b/renderdoc/api/replay/replay_enums.h index 26640ebd3..44c3e3f57 100644 --- a/renderdoc/api/replay/replay_enums.h +++ b/renderdoc/api/replay/replay_enums.h @@ -947,6 +947,10 @@ DOCUMENT(R"(The format of an image file .. data:: EXR An EXR file + +.. data:: RAW + + Raw data, just the bytes of the image tightly packed with no metadata or compression/encoding )"); enum class FileType : uint32_t { @@ -958,6 +962,7 @@ enum class FileType : uint32_t TGA, HDR, EXR, + Raw, Count, }; diff --git a/renderdoc/core/target_control.cpp b/renderdoc/core/target_control.cpp index 673801af7..26927a17f 100644 --- a/renderdoc/core/target_control.cpp +++ b/renderdoc/core/target_control.cpp @@ -153,7 +153,7 @@ void RenderDoc::TargetControlClientThread(Network::Socket *client) ICaptureFile *file = RENDERDOC_OpenCaptureFile(); if(file->OpenFile(captures.back().path.c_str(), "rdc") == ReplayStatus::Succeeded) { - buf = file->GetThumbnail(FileType::JPG, 0); + buf = file->GetThumbnail(FileType::JPG, 0).bytes; } file->Shutdown(); diff --git a/renderdoc/replay/capture_file.cpp b/renderdoc/replay/capture_file.cpp index 76860ac28..5cf7ea984 100644 --- a/renderdoc/replay/capture_file.cpp +++ b/renderdoc/replay/capture_file.cpp @@ -161,7 +161,7 @@ public: m_StructuredData.buffers.push_back(new bytebuf(*buf)); } - bytebuf GetThumbnail(FileType type, uint32_t maxsize); + Thumbnail GetThumbnail(FileType type, uint32_t maxsize); // ICaptureAccess @@ -481,12 +481,13 @@ ReplayStatus CaptureFile::Convert(const char *filename, const char *filetype, fl return ReplayStatus::Succeeded; } -bytebuf CaptureFile::GetThumbnail(FileType type, uint32_t maxsize) +Thumbnail CaptureFile::GetThumbnail(FileType type, uint32_t maxsize) { - bytebuf buf; + Thumbnail ret; + ret.type = type; if(m_RDC == NULL) - return buf; + return ret; const RDCThumb &thumb = m_RDC->GetThumbnail(); @@ -495,7 +496,9 @@ bytebuf CaptureFile::GetThumbnail(FileType type, uint32_t maxsize) uint32_t thumbwidth = thumb.width, thumbheight = thumb.height; if(jpgbuf == NULL) - return buf; + return ret; + + bytebuf buf; // if the desired output is jpg and either there's no max size or it's already satisfied, // return the data directly @@ -546,6 +549,11 @@ bytebuf CaptureFile::GetThumbnail(FileType type, uint32_t maxsize) switch(type) { + case FileType::Raw: + { + encodedBytes.assign(thumbpixels, thumbpixels + (thumbwidth * thumbheight * 3)); + break; + } case FileType::JPG: { int len = thumbwidth * thumbheight * 3; @@ -579,7 +587,7 @@ bytebuf CaptureFile::GetThumbnail(FileType type, uint32_t maxsize) { RDCERR("Unsupported file type %d in thumbnail fetch", type); free(thumbpixels); - return buf; + return ret; } } @@ -588,7 +596,11 @@ bytebuf CaptureFile::GetThumbnail(FileType type, uint32_t maxsize) free(thumbpixels); } - return buf; + ret.bytes.swap(buf); + ret.width = thumbwidth; + ret.height = thumbheight; + + return ret; } int CaptureFile::FindSectionByName(const char *name) diff --git a/renderdoccmd/renderdoccmd.cpp b/renderdoccmd/renderdoccmd.cpp index d8c922b84..736a335ac 100644 --- a/renderdoccmd/renderdoccmd.cpp +++ b/renderdoccmd/renderdoccmd.cpp @@ -296,7 +296,7 @@ struct ThumbCommand : public Command ReplayStatus st = file->OpenFile(filename.c_str(), "rdc"); if(st == ReplayStatus::Succeeded) { - buf = file->GetThumbnail(type, maxsize); + buf = file->GetThumbnail(type, maxsize).bytes; } else {