diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-02-11 20:07:20 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-02-11 20:07:20 +0300 |
commit | 825ae994c240dd20c6be15351ed57f9feda656fb (patch) | |
tree | 51375591e8f7c5f88d723ec94d6d78ff6b2bd897 /src/Storage | |
parent | aa5c62260d29c150c17c7400ad8b567d51dc2bac (diff) |
Suppot JPEG thumbnail images
Diffstat (limited to 'src/Storage')
-rw-r--r-- | src/Storage/FileInfoParser.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Storage/FileInfoParser.cpp b/src/Storage/FileInfoParser.cpp index f7ddf326..28deb67d 100644 --- a/src/Storage/FileInfoParser.cpp +++ b/src/Storage/FileInfoParser.cpp @@ -974,24 +974,31 @@ bool FileInfoParser::FindThumbnails(const char *_ecv_array bufp, FilePosition bu constexpr const char * PngThumbnailBegin = "; thumbnail begin "; constexpr const char * QoiThumbnailBegin = "; thumbnail_QOI begin "; + constexpr const char * JpegThumbnailBegin = "; thumbnail_JPG begin "; const char *_ecv_array pos = bufp; while (true) { const char *_ecv_array qoiPos = strstr(pos, QoiThumbnailBegin); const char *_ecv_array pngPos = strstr(pos, PngThumbnailBegin); + const char *_ecv_array jpegPos = strstr(pos, JpegThumbnailBegin); GCodeFileInfo::ThumbnailInfo::Format fmt(GCodeFileInfo::ThumbnailInfo::Format::qoi); - if (qoiPos != nullptr && (pngPos == nullptr || qoiPos < pngPos)) + if (qoiPos != nullptr && (pngPos == nullptr || qoiPos < pngPos) && (jpegPos == nullptr || qoiPos < jpegPos)) { // found a QOI thumbnail pos = qoiPos + strlen(QoiThumbnailBegin); - fmt = GCodeFileInfo::ThumbnailInfo::Format::qoi; } - else if (pngPos != nullptr) + else if (pngPos != nullptr && (jpegPos == nullptr || pngPos < jpegPos)) { // found a PNG thumbnail pos = pngPos + strlen(PngThumbnailBegin); fmt = GCodeFileInfo::ThumbnailInfo::Format::png; } + else if (jpegPos != nullptr) + { + // found a JPEG thumbnail + pos = jpegPos + strlen(JpegThumbnailBegin); + fmt = GCodeFileInfo::ThumbnailInfo::Format::jpeg; + } else { return false; // no more thumbnails in this buffer, but we have room to save more thumbnail details |