[Libreoffice-commits] core.git: vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 15 14:26:15 UTC 2021
vcl/source/filter/GraphicFormatDetector.cxx | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
New commits:
commit 48d655fe12bc2c4c42d6c88b8a43fade1614ee2a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Feb 15 16:25:56 2021 +0900
Commit: Tomaž Vajngerl <quikee at 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 <quikee at 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";
More information about the Libreoffice-commits
mailing list