diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-02 15:55:48 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-02 15:55:48 +0000 |
commit | ab53b72bf7067feb9dede0fd76b5a3cbc13863b9 (patch) | |
tree | 677a18bc997d1cf118379b288a7c2dd2c160d9b1 /plugins/HistoryStats/src/canvas.cpp | |
parent | 1c229f90bfc6c8032bd2d20e297e97f321eb4db7 (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/src/canvas.cpp')
-rw-r--r-- | plugins/HistoryStats/src/canvas.cpp | 56 |
1 files changed, 7 insertions, 49 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;
}
|