summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-01-18 20:46:46 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-01-18 20:46:46 +0300
commitc9d99d1525e2e9374ed0fa10837e82e76c3b9216 (patch)
tree128f0fe0315c73a4fca59279e867cf77e9ceb1c2
parent6b1d05a40f8e07ab37a9779944c334880a4aa67f (diff)
Telegram: sticker conversion from WEBP to PNG
-rw-r--r--libs/freeimage/src/FreeImage/Plugin.cpp2
-rw-r--r--protocols/Telegram/Telegram.vcxproj3
-rw-r--r--protocols/Telegram/Telegram.vcxproj.filters3
-rw-r--r--protocols/Telegram/src/avatars.cpp11
-rw-r--r--protocols/Telegram/src/stdafx.h2
5 files changed, 16 insertions, 5 deletions
diff --git a/libs/freeimage/src/FreeImage/Plugin.cpp b/libs/freeimage/src/FreeImage/Plugin.cpp
index 0e5452c929..ecedf6f927 100644
--- a/libs/freeimage/src/FreeImage/Plugin.cpp
+++ b/libs/freeimage/src/FreeImage/Plugin.cpp
@@ -231,6 +231,7 @@ FreeImage_Initialise(BOOL load_local_plugins_only) {
s_plugins->AddNode(InitJPEG);
s_plugins->AddNode(InitPNG);
s_plugins->AddNode(InitGIF);
+ s_plugins->AddNode(InitWEBP);
//s_plugins->AddNode(InitJNG);
//s_plugins->AddNode(InitKOALA);
//s_plugins->AddNode(InitIFF);
@@ -261,7 +262,6 @@ FreeImage_Initialise(BOOL load_local_plugins_only) {
//s_plugins->AddNode(InitPFM);
//s_plugins->AddNode(InitPICT);
//s_plugins->AddNode(InitRAW);
- //s_plugins->AddNode(InitWEBP);
//#if !(defined(_MSC_VER) && (_MSC_VER <= 1310))
//s_plugins->AddNode(InitJXR);
//#endif // unsupported by MS Visual Studio 2003 !!!
diff --git a/protocols/Telegram/Telegram.vcxproj b/protocols/Telegram/Telegram.vcxproj
index 6586c6698e..c28cc183f5 100644
--- a/protocols/Telegram/Telegram.vcxproj
+++ b/protocols/Telegram/Telegram.vcxproj
@@ -54,6 +54,9 @@
<ClInclude Include="src\version.h" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\..\libs\freeimage\freeimage.vcxproj">
+ <Project>{5d14cff3-0d17-4528-99ea-de9dca47cc2e}</Project>
+ </ProjectReference>
<ProjectReference Include="..\..\libs\sqlite3\sqlite3.vcxproj">
<Project>{0c02e395-e73f-47e3-8b95-b7924c0c7a6a}</Project>
</ProjectReference>
diff --git a/protocols/Telegram/Telegram.vcxproj.filters b/protocols/Telegram/Telegram.vcxproj.filters
index b4b601b02e..14ddb0e166 100644
--- a/protocols/Telegram/Telegram.vcxproj.filters
+++ b/protocols/Telegram/Telegram.vcxproj.filters
@@ -31,9 +31,6 @@
<ClCompile Include="src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\mt_proto.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\proto.h">
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 <m_popup.h>
#include <m_smileyadd.h>
+#include "../../libs/freeimage/src/FreeImage.h"
+
#include "td/telegram/Client.h"
#include "td/telegram/td_api.h"
#include "td/telegram/td_api.hpp"