From c9d99d1525e2e9374ed0fa10837e82e76c3b9216 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 Jan 2023 20:46:46 +0300 Subject: Telegram: sticker conversion from WEBP to PNG --- protocols/Telegram/src/avatars.cpp | 11 ++++++++++- protocols/Telegram/src/stdafx.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'protocols/Telegram/src') diff --git a/protocols/Telegram/src/avatars.cpp b/protocols/Telegram/src/avatars.cpp index 5c309c17be..225dcee0e2 100644 --- a/protocols/Telegram/src/avatars.cpp +++ b/protocols/Telegram/src/avatars.cpp @@ -87,8 +87,17 @@ void CTelegramProto::ProcessFile(TD::updateFile *pObj) for (auto &it : m_arFiles) { if (it->m_uniqueId == pFile->remote_->unique_id_.c_str()) { - MoveFileW(wszExistingFile, it->m_destPath); if (it->m_type == it->AVATAR) { + if (it->m_destPath.Right(5).MakeLower() == L".webp") { + if (auto *pImage = FreeImage_LoadU(FIF_WEBP, wszExistingFile)) { + it->m_destPath.Truncate(it->m_destPath.GetLength() - 5); + it->m_destPath += L".png"; + FreeImage_SaveU(FIF_PNG, pImage, it->m_destPath); + FreeImage_Unload(pImage); + } + } + else MoveFileW(wszExistingFile, it->m_destPath); + SMADD_CONT cont = {1, m_szModuleName, it->m_destPath}; CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont)); } diff --git a/protocols/Telegram/src/stdafx.h b/protocols/Telegram/src/stdafx.h index 1ded1b61dd..47564f1ee3 100644 --- a/protocols/Telegram/src/stdafx.h +++ b/protocols/Telegram/src/stdafx.h @@ -25,6 +25,8 @@ #include #include +#include "../../libs/freeimage/src/FreeImage.h" + #include "td/telegram/Client.h" #include "td/telegram/td_api.h" #include "td/telegram/td_api.hpp" -- cgit v1.2.3