From b3ded48d866f59df3c9e8634eabe6e62596ad2d5 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sun, 21 Dec 2014 08:17:45 +0000 Subject: Popup: changed warning level to w4 git-svn-id: http://svn.miranda-ng.org/main/trunk@11550 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Popup/src/popup_gdiplus.cpp | 135 +++++++++++++++++------------------- 1 file changed, 63 insertions(+), 72 deletions(-) (limited to 'plugins/Popup/src/popup_gdiplus.cpp') diff --git a/plugins/Popup/src/popup_gdiplus.cpp b/plugins/Popup/src/popup_gdiplus.cpp index c85f756c75..bf81780e79 100644 --- a/plugins/Popup/src/popup_gdiplus.cpp +++ b/plugins/Popup/src/popup_gdiplus.cpp @@ -1,10 +1,10 @@ /* Popup Plus plugin for Miranda IM -Copyright � 2002 Luca Santarelli, - � 2004-2007 Victor Pavlychko - � 2010 MPK - � 2010 Merlin_de +Copyright © 2002 Luca Santarelli, +© 2004-2007 Victor Pavlychko +© 2010 MPK +© 2010 Merlin_de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -43,7 +43,7 @@ void LoadGDIPlus() if (g_gdiplusToken == 0) Gdiplus::GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL); } - __except ( EXCEPTION_EXECUTE_HANDLER ) { + __except (EXCEPTION_EXECUTE_HANDLER) { gbGdiPlusLoaded = false; } } @@ -55,11 +55,11 @@ void UnloadGDIPlus() if (g_gdiplusToken && gbGdiPlusLoaded) Gdiplus::GdiplusShutdown(g_gdiplusToken); } - __except ( EXCEPTION_EXECUTE_HANDLER ) { + __except (EXCEPTION_EXECUTE_HANDLER) { // do nothing - } + } gbGdiPlusLoaded = true; - g_gdiplusToken = 0; + g_gdiplusToken = 0; } using namespace Gdiplus; @@ -71,37 +71,37 @@ using namespace Gdiplus; HBITMAP SkinEngine_CreateDIB32(int cx, int cy) { - if ( cx < 0 || cy < 0 ) { - return NULL; - } - - BITMAPINFO RGB32BitsBITMAPINFO; - memset(&RGB32BitsBITMAPINFO, 0, sizeof(BITMAPINFO)); - RGB32BitsBITMAPINFO.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); - RGB32BitsBITMAPINFO.bmiHeader.biWidth=cx;// bm.bmWidth; - RGB32BitsBITMAPINFO.bmiHeader.biHeight=cy;// bm.bmHeight; - RGB32BitsBITMAPINFO.bmiHeader.biPlanes=1; - RGB32BitsBITMAPINFO.bmiHeader.biBitCount=32; - // pointer used for direct Bitmap pixels access - - - UINT *ptPixels; - HBITMAP DirectBitmap = CreateDIBSection(NULL, &RGB32BitsBITMAPINFO, DIB_RGB_COLORS, (void **)&ptPixels, NULL, 0); - if ((DirectBitmap == NULL || ptPixels == NULL) && cx!= 0 && cy!=0) - { - ; - } - else + if (cx < 0 || cy < 0) { + return NULL; + } + + BITMAPINFO RGB32BitsBITMAPINFO; + memset(&RGB32BitsBITMAPINFO, 0, sizeof(BITMAPINFO)); + RGB32BitsBITMAPINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + RGB32BitsBITMAPINFO.bmiHeader.biWidth = cx;// bm.bmWidth; + RGB32BitsBITMAPINFO.bmiHeader.biHeight = cy;// bm.bmHeight; + RGB32BitsBITMAPINFO.bmiHeader.biPlanes = 1; + RGB32BitsBITMAPINFO.bmiHeader.biBitCount = 32; + // pointer used for direct Bitmap pixels access + + + UINT *ptPixels; + HBITMAP DirectBitmap = CreateDIBSection(NULL, &RGB32BitsBITMAPINFO, DIB_RGB_COLORS, (void **)&ptPixels, NULL, 0); + if ((DirectBitmap == NULL || ptPixels == NULL) && cx != 0 && cy != 0) + { + ; + } + else { - memset(ptPixels,0,cx*cy*4); + memset(ptPixels, 0, cx*cy * 4); } - return DirectBitmap; + return DirectBitmap; } BOOL GDIPlus_IsAnimatedGIF(TCHAR * szName) { - int nFrameCount=0; + int nFrameCount = 0; Image image(szName); UINT count = image.GetFrameDimensionsCount(); @@ -113,9 +113,9 @@ BOOL GDIPlus_IsAnimatedGIF(TCHAR * szName) // Get the number of frames in the first dimension. nFrameCount = image.GetFrameCount(&pDimensionIDs[0]); - delete []pDimensionIDs; + delete[]pDimensionIDs; - return (BOOL) (nFrameCount > 1) && image.GetWidth() && image.GetHeight(); + return (BOOL)(nFrameCount > 1) && image.GetWidth() && image.GetHeight(); } void GDIPlus_GetGIFSize(TCHAR * szName, int * width, int * height) @@ -128,9 +128,9 @@ void GDIPlus_GetGIFSize(TCHAR * szName, int * width, int * height) void GDIPlus_ExtractAnimatedGIF(TCHAR * szName, int width, int height, HBITMAP * pBitmap, int ** pframesDelay, int * pframesCount, SIZE * pSizeAvatar) { - int nFrameCount=0; + int nFrameCount = 0; Bitmap image(szName); - PropertyItem * pPropertyItem; + PropertyItem * pPropertyItem; UINT count = 0; @@ -148,60 +148,51 @@ void GDIPlus_ExtractAnimatedGIF(TCHAR * szName, int width, int height, HBITMAP * int nSize = image.GetPropertyItemSize(PropertyTagFrameDelay); // Allocate a buffer to receive the property item. - pPropertyItem = (PropertyItem*) mir_alloc(nSize); + pPropertyItem = (PropertyItem*)mir_alloc(nSize); image.GetPropertyItem(PropertyTagFrameDelay, nSize, pPropertyItem); - + int clipWidth; int clipHeight; - int imWidth=image.GetWidth(); - int imHeight=image.GetHeight(); - float xscale=(float)width/imWidth; - float yscale=(float)height/imHeight; - xscale=min(xscale,yscale); - clipWidth=(int)(xscale*imWidth+.5); - clipHeight=(int)(xscale*imHeight+.5); - - HBITMAP hBitmap=SkinEngine_CreateDIB32(clipWidth*nFrameCount, height); - HDC hdc=CreateCompatibleDC(NULL); - HBITMAP oldBmp=(HBITMAP)SelectObject(hdc,hBitmap); + int imWidth = image.GetWidth(); + int imHeight = image.GetHeight(); + float xscale = (float)width / imWidth; + float yscale = (float)height / imHeight; + xscale = min(xscale, yscale); + clipWidth = (int)(xscale*imWidth + .5); + clipHeight = (int)(xscale*imHeight + .5); + + HBITMAP hBitmap = SkinEngine_CreateDIB32(clipWidth*nFrameCount, height); + HDC hdc = CreateCompatibleDC(NULL); + HBITMAP oldBmp = (HBITMAP)SelectObject(hdc, hBitmap); Graphics graphics(hdc); ImageAttributes attr; - ColorMatrix ClrMatrix = - { - 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, ((float)255)/255, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 1.0f - }; - // attr.SetColorMatrix(&ClrMatrix, ColorMatrixFlagsDefault,ColorAdjustTypeBitmap); graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic); - int * delays=(int*)mir_alloc(nFrameCount*sizeof(int)); - memset(delays,0,nFrameCount*sizeof(int)); + int * delays = (int*)mir_alloc(nFrameCount*sizeof(int)); + memset(delays, 0, nFrameCount*sizeof(int)); - for (int i=1; ivalue)[i-1] * 10; - delays[i-1]=(int)lPause; + long lPause = ((long*)pPropertyItem->value)[i - 1] * 10; + delays[i - 1] = (int)lPause; } - SelectObject(hdc,oldBmp); + SelectObject(hdc, oldBmp); DeleteDC(hdc); mir_free(pPropertyItem); pPropertyItem = NULL; - delete []pDimensionIDs; + delete[]pDimensionIDs; if (pBitmap && pframesDelay && pframesCount && pSizeAvatar) { - *pBitmap=hBitmap; - *pframesDelay=delays; - *pframesCount=nFrameCount; - pSizeAvatar->cx=clipWidth; - pSizeAvatar->cy=clipHeight; + *pBitmap = hBitmap; + *pframesDelay = delays; + *pframesCount = nFrameCount; + pSizeAvatar->cx = clipWidth; + pSizeAvatar->cy = clipHeight; } GdiFlush(); } -- cgit v1.2.3