From ab53b72bf7067feb9dede0fd76b5a3cbc13863b9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 2 Jun 2015 15:55:48 +0000 Subject: - 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 --- plugins/HistoryStats/src/canvas.cpp | 56 +++--------------------- plugins/HistoryStats/src/canvas.h | 3 -- plugins/HistoryStats/src/dlgoption_subglobal.cpp | 8 ---- plugins/HistoryStats/src/mu_common.cpp | 26 ----------- plugins/HistoryStats/src/mu_common.h | 10 ----- plugins/HistoryStats/src/settings.cpp | 2 +- plugins/HistoryStats/src/statistic.cpp | 5 ++- plugins/HistoryStats/src/stdafx.h | 2 +- 8 files changed, 12 insertions(+), 100 deletions(-) (limited to 'plugins/HistoryStats') 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(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 @@ -206,32 +206,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(reinterpret_cast(pBMIH)); - info.pDiData = const_cast(pDIData); - info.pResult = pImageData; - info.pResultLen = pImageLen; - - return bool_(CallService(MS_DIB2PNG, 0, reinterpret_cast(&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 @@ -71,16 +71,6 @@ namespace mu void addPage(WPARAM addInfo, const TCHAR* pszGroup, const TCHAR* pszTitle, const TCHAR* pszTab, DLGPROC pfnDlgProc, const char* pszTemplate, HINSTANCE hInstance, DWORD flags = ODPF_BOLDGROUPS); } - /* - * 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(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 // not used #include // not used #include -#include #include // not used #include #include // not used @@ -67,6 +66,7 @@ #include // not used #include // not used #include +#include #include // not used, depends on m_protosvc.h #include // depends on m_protosvc.h -- cgit v1.2.3