diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-02-15 16:25:56 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-02-15 15:25:32 +0100 |
commit | 48d655fe12bc2c4c42d6c88b8a43fade1614ee2a (patch) | |
tree | 51dfc50bf789fe7a8c9ac148b0ce9208085586a1 | |
parent | 4927883c820d23da797978c270ce684103734399 (diff) |
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 <quikee@gmail.com>
-rw-r--r-- | vcl/source/filter/GraphicFormatDetector.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
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"; |