vcl/source/filter/GraphicFormatDetector.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
New commits: commit 48d655fe12bc2c4c42d6c88b8a43fade1614ee2a Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Feb 15 16:25:56 2021 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Feb 15 15:25:32 2021 +0100 vcl: Detect TGA graphic by inspecting the file footer Works only with TGA ver.2 files. Change-Id: I0378a1e03e238cd444175035768cccf491480191 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110898 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index 56f7a9f2d006..e5a1eb5f9a79 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -513,6 +513,24 @@ bool GraphicFormatDetector::checkSVG() bool GraphicFormatDetector::checkTGA() { + // Check TGA ver.2 footer bytes + if (mnStreamLength > 18) + { + char sFooterBytes[18]; + + mrStream.Seek(STREAM_SEEK_TO_END); + mrStream.SeekRel(-18); + mrStream.ReadBytes(sFooterBytes, 18); + + OString aFooterString(sFooterBytes); + if (aFooterString == "TRUEVISION-XFILE.") + { + msDetectedFormat = "TGA"; + return true; + } + } + + // Fallback to file extension check if (maExtension.startsWith("TGA")) { msDetectedFormat = "TGA"; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits