summaryrefslogtreecommitdiff
path: root/plugins/HistoryStats
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-02 15:55:48 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-02 15:55:48 +0000
commitab53b72bf7067feb9dede0fd76b5a3cbc13863b9 (patch)
tree677a18bc997d1cf118379b288a7c2dd2c160d9b1 /plugins/HistoryStats
parent1c229f90bfc6c8032bd2d20e297e97f321eb4db7 (diff)
- old PNG conversion code (png2dib, dib2png) removed;
- m_png.h also removed; - all calls of LoadImage replaced with CallService(MS_IMG_LOAD); - four invalid CloseHandle() calls removed; - massive code cleaning for Popup, HistoryStats & SplashScreen plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@13974 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/HistoryStats')
-rw-r--r--plugins/HistoryStats/src/canvas.cpp56
-rw-r--r--plugins/HistoryStats/src/canvas.h3
-rw-r--r--plugins/HistoryStats/src/dlgoption_subglobal.cpp8
-rw-r--r--plugins/HistoryStats/src/mu_common.cpp26
-rw-r--r--plugins/HistoryStats/src/mu_common.h10
-rw-r--r--plugins/HistoryStats/src/settings.cpp2
-rw-r--r--plugins/HistoryStats/src/statistic.cpp5
-rw-r--r--plugins/HistoryStats/src/stdafx.h2
8 files changed, 12 insertions, 100 deletions
diff --git a/plugins/HistoryStats/src/canvas.cpp b/plugins/HistoryStats/src/canvas.cpp
index 5eb395f2b2..881fbc254f 100644
--- a/plugins/HistoryStats/src/canvas.cpp
+++ b/plugins/HistoryStats/src/canvas.cpp
@@ -137,53 +137,11 @@ bool Canvas::getDigest(Digest& digest)
bool Canvas::writePNG(const TCHAR* szFileName)
{
- // read data from DIB
- BYTE* pData = new BYTE[m_nLineLength * m_nHeight];
-
- if (GetDIBits(m_hDC, m_hBmp, 0, m_nHeight, pData, reinterpret_cast<BITMAPINFO*>(m_pBMIH), DIB_RGB_COLORS) != m_nHeight) {
- delete[] pData;
- return false;
- }
-
- // apply transparency, if any
- updateTrans(pData);
-
- // calculate resulting image size
- long png_len = 0;
-
- if (!mu::png::dibToPng(m_pBMIH, pData, 0, &png_len) || png_len == 0) {
- delete[] pData;
- return false;
- }
-
- // get the resulting image data
- BYTE* pRawPNG = new BYTE[png_len];
-
- png_len = 0;
-
- if (!mu::png::dibToPng(m_pBMIH, pData, pRawPNG, &png_len)) {
- delete[] pData;
- delete[] pRawPNG;
-
- return false;
- }
-
- // write image data to file
- FILE* fp = _tfopen(szFileName, _T("wb"));
-
- if (!fp) {
- delete[] pData;
- delete[] pRawPNG;
-
- return false;
- }
-
- fwrite(pRawPNG, 1, png_len, fp);
- fclose(fp);
-
- // free buffers
- delete[] pRawPNG;
- delete[] pData;
-
- return true;
+ IMGSRVC_INFO img = { 0 };
+ img.cbSize = sizeof(img);
+ img.dwMask = IMGI_HBITMAP;
+ img.hbm = m_hBmp;
+ img.fif = FIF_PNG;
+ img.tszName = (TCHAR*)szFileName;
+ return CallService(MS_IMG_SAVE, (WPARAM)&img, IMGL_TCHAR) == 0;
}
diff --git a/plugins/HistoryStats/src/canvas.h b/plugins/HistoryStats/src/canvas.h
index 81a69caed4..a5b7f06519 100644
--- a/plugins/HistoryStats/src/canvas.h
+++ b/plugins/HistoryStats/src/canvas.h
@@ -20,9 +20,6 @@ public:
bool operator <(const Digest& other) const { return (memcmp(m_Digest, other.m_Digest, 20) < 0); }
};
-public:
- static bool hasPNG() { return mu::png::_available(); }
-
private:
int m_nChannels;
int m_nWidth;
diff --git a/plugins/HistoryStats/src/dlgoption_subglobal.cpp b/plugins/HistoryStats/src/dlgoption_subglobal.cpp
index c2b0054cf5..9df4998661 100644
--- a/plugins/HistoryStats/src/dlgoption_subglobal.cpp
+++ b/plugins/HistoryStats/src/dlgoption_subglobal.cpp
@@ -286,14 +286,6 @@ void DlgOption::SubGlobal::loadSettings()
m_Options.checkItem(*i, localS.m_HideContactMenuProtos.find(protoName) != localS.m_HideContactMenuProtos.end());
}
-
- // check for availability of 'libpng'
- if (!Canvas::hasPNG()) {
- if (m_Options.isItemChecked(m_hGraphicsModePNG))
- m_Options.setRadioChecked(m_hGraphicsMode, Settings::gmHTML);
-
- m_Options.enableItem(m_hGraphicsModePNG, false);
- }
}
void DlgOption::SubGlobal::saveSettings()
diff --git a/plugins/HistoryStats/src/mu_common.cpp b/plugins/HistoryStats/src/mu_common.cpp
index 17c84e7eee..74cd534b0f 100644
--- a/plugins/HistoryStats/src/mu_common.cpp
+++ b/plugins/HistoryStats/src/mu_common.cpp
@@ -207,32 +207,6 @@ namespace mu
}
/*
- * png
- */
-
- namespace png
- {
- bool _available()
- {
- return
- true &&
- ServiceExists(MS_DIB2PNG);
- }
-
- bool dibToPng(const BITMAPINFOHEADER* pBMIH, const BYTE* pDIData, BYTE* pImageData, long* pImageLen)
- {
- DIB2PNG info;
-
- info.pbmi = const_cast<BITMAPINFO*>(reinterpret_cast<const BITMAPINFO*>(pBMIH));
- info.pDiData = const_cast<BYTE*>(pDIData);
- info.pResult = pImageData;
- info.pResultLen = pImageLen;
-
- return bool_(CallService(MS_DIB2PNG, 0, reinterpret_cast<LPARAM>(&info)));
- }
- }
-
- /*
* proto
*/
diff --git a/plugins/HistoryStats/src/mu_common.h b/plugins/HistoryStats/src/mu_common.h
index 8ad005a5f4..349c68c218 100644
--- a/plugins/HistoryStats/src/mu_common.h
+++ b/plugins/HistoryStats/src/mu_common.h
@@ -72,16 +72,6 @@ namespace mu
}
/*
- * png
- */
-
- namespace png
- {
- bool _available();
- bool dibToPng(const BITMAPINFOHEADER* pBMIH, const BYTE* pDIData, BYTE* pImageData, long* pImageLen);
- }
-
- /*
* proto
*/
diff --git a/plugins/HistoryStats/src/settings.cpp b/plugins/HistoryStats/src/settings.cpp
index 722e298a4f..a9c2b6ec06 100644
--- a/plugins/HistoryStats/src/settings.cpp
+++ b/plugins/HistoryStats/src/settings.cpp
@@ -524,7 +524,7 @@ ext::string Settings::getOutputPrefix(DWORD timeStarted) const
bool Settings::isPNGOutputActiveAndAvailable() const
{
- return (m_GraphicsMode == gmPNG && Canvas::hasPNG());
+ return (m_GraphicsMode == gmPNG);
}
DWORD Settings::getIgnoreBefore() const
diff --git a/plugins/HistoryStats/src/statistic.cpp b/plugins/HistoryStats/src/statistic.cpp
index e609101d3d..f2a5fceaf3 100644
--- a/plugins/HistoryStats/src/statistic.cpp
+++ b/plugins/HistoryStats/src/statistic.cpp
@@ -1303,7 +1303,6 @@ bool Statistic::createStatistics()
/*
* Cleanup.
*/
- CloseHandle(hThread);
CloseHandle(m_hCancelEvent);
m_hCancelEvent = NULL;
m_hWndProgress = NULL;
@@ -1372,9 +1371,11 @@ bool Statistic::createStatisticsSteps()
void __cdecl Statistic::threadProc(void *lpParameter)
{
Statistic* pStats = reinterpret_cast<Statistic*>(lpParameter);
-
SetEvent(pStats->m_hThreadPushEvent);
+ // perform action
+ pStats->createStatistics();
+
// check for errors
if (!pStats->m_ErrorText.empty() && !mu::system::terminated())
MessageBox(0, pStats->m_ErrorText.c_str(), TranslateT("HistoryStats - Error"), MB_ICONERROR | MB_OK);
diff --git a/plugins/HistoryStats/src/stdafx.h b/plugins/HistoryStats/src/stdafx.h
index 6e49afefe2..76b7afa97b 100644
--- a/plugins/HistoryStats/src/stdafx.h
+++ b/plugins/HistoryStats/src/stdafx.h
@@ -56,7 +56,6 @@
#include <m_message.h> // not used
#include <m_netlib.h> // not used
#include <m_options.h>
-#include <m_png.h>
#include <m_popup.h> // not used
#include <m_protocols.h>
#include <m_protomod.h> // not used
@@ -67,6 +66,7 @@
#include <m_url.h> // not used
#include <m_userinfo.h> // not used
#include <m_utils.h>
+#include <m_imgsrvc.h>
#include <m_addcontact.h> // not used, depends on m_protosvc.h
#include <m_icq.h> // depends on m_protosvc.h