diff options
-rw-r--r-- | plugins/SendScreenshotPlus/src/UMainForm.cpp | 22 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/Utils.cpp | 154 |
2 files changed, 90 insertions, 86 deletions
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp index 16c6dac8c4..909e5f7c5c 100644 --- a/plugins/SendScreenshotPlus/src/UMainForm.cpp +++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp @@ -662,7 +662,7 @@ void TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) { FIP->FI_Unload(m_Screenshot); m_Screenshot = NULL; } - m_hTargetWindow = m_hLastWin = NULL; + /* m_hTargetWindow = */m_hLastWin = NULL; Show(); }else{ // Saving Options and close @@ -678,21 +678,25 @@ void TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) { //--------------------------------------------------------------------------- // Standard konstruktor/destruktor TfrmMain::TfrmMain() { + /* m_opt_XXX */ + m_bOnExitSave = TRUE; + m_hWnd = NULL; m_hContact = NULL; - m_hTargetWindow = NULL; + m_bDeleteAfterSend=m_bFormAbout=m_bFormEdit=false; + m_hTargetWindow =m_hLastWin=NULL; m_hCursor = NULL; + m_FDestFolder =m_pszFile=m_pszFileDesc=NULL; m_Screenshot = NULL; - m_pszFile = m_pszFileDesc = m_FDestFolder = NULL; - m_bFormAbout = m_bFormEdit = m_bDeleteAfterSend = m_bSelectingWindow = false; + /* m_AlphaColor */ m_cSend = NULL; - m_bOnExitSave = TRUE; - LoadOptions(); + + m_MonitorCount = MonitorInfoEnum(m_Monitors, m_VirtualScreen); + m_Monitors = NULL; + /* m_opt_XXX */ LoadOptions(); m_bCapture = false; + /* m_hwndTab,m_hwndTabPage */ m_himlTab = NULL; - m_Monitors = NULL; - m_MonitorCount = MonitorInfoEnum(m_Monitors, m_VirtualScreen); - } TfrmMain::~TfrmMain() { diff --git a/plugins/SendScreenshotPlus/src/Utils.cpp b/plugins/SendScreenshotPlus/src/Utils.cpp index b56d953d79..ad2c00d4cf 100644 --- a/plugins/SendScreenshotPlus/src/Utils.cpp +++ b/plugins/SendScreenshotPlus/src/Utils.cpp @@ -157,81 +157,81 @@ FIBITMAP* CaptureScreen (HDC hDC,SIZE size,HWND hCapture){ }else{// bitblt screen DC to memory DC BitBlt(hMemDC,0,0,size.cx,size.cy,hScrDC,0,0,CAPTUREBLT|SRCCOPY); } - dib = FIP->FI_CreateDIBFromHBITMAP(hBitmap);
-
- //alpha channel from window is always wrong,
- //coz GDI do not draw all in alpha mode.
- //we have to create our own new alpha channel.
- bool bFixAlpha = true;
- bool bInvert = false;
-
- // Create monochrome (1 bit) B+W mask bitmap.
- HBITMAP hMask = CreateBitmap(size.cx,size.cy, 1, 1, NULL);
- HDC hMaskDC = CreateCompatibleDC(0);
- SelectBitmap(hMaskDC, hMask);
-
- //Create a SolidBrush object for non transparent area
- HBRUSH hBr = CreateSolidBrush(RGB(255,255,255));
-
- HRGN hrgn = NULL;
- int regionType;
- if(hCapture) {
- hrgn = CreateRectRgn(0,0,0,0);
- regionType = GetWindowRgn(hCapture, hrgn);
- if (regionType != ERROR) {
- // not layerd - fill the window region
- FillRgn(hMaskDC, hrgn, hBr);
- }
- else { //layerd window (WS_EX_LAYERED)
- BYTE bAlpha= 0;
- COLORREF crKey=0; //0x00bbggrr
- DWORD dwFlags=0;
- if(GetLayeredWindowAttributes(hCapture,&crKey,&bAlpha,&dwFlags)) {
- //per window transparency (like fading in a whole window).
- if((dwFlags & LWA_ALPHA) == LWA_ALPHA) {
- //Use bAlpha to determine the opacity of the layered window.
- bFixAlpha = false;
- }
- if((dwFlags & LWA_COLORKEY) == LWA_COLORKEY) {
- //Use crKey as the transparency color.
- SetBkColor(hMemDC, crKey);
- BitBlt(hMaskDC, 0, 0, size.cx, size.cy, hMemDC, 0, 0, SRCCOPY);
- bInvert = true;
- bFixAlpha = true;
- }
- }
- else {
- //per-pixel transparency (won't use the WM_PAINT )
- bFixAlpha = false;
- }
- }
- }
- else { //fill the desktop region
- hrgn = CreateRectRgn(0,0,size.cx,size.cy);
- FillRgn(hMaskDC, hrgn, hBr);
- }
-
- if(bFixAlpha) {
- FIBITMAP* dibMask = FIP->FI_CreateDIBFromHBITMAP(hMask);
- if(bInvert) FIP->FI_Invert(dibMask);
- FIBITMAP* dib8 = FIP->FI_ConvertTo8Bits(dibMask);
-
- //copy the dib8 alpha mask to dib32 main bitmap
- FIP->FI_SetChannel(dib,dib8,FICC_ALPHA);
- FIP->FI_Unload(dibMask);
- FIP->FI_Unload(dib8);
- }
-
- //clean up
- DeleteObject(hBr);
- if(hrgn) DeleteObject(hrgn);
- DeleteDC(hMaskDC);
- DeleteObject(hMask);
- SelectObject(hMemDC, hOld);
- DeleteDC(hMemDC);
- if(!hDC) ReleaseDC(NULL, hScrDC);
- DeleteObject(hBitmap);
-
+ dib = FIP->FI_CreateDIBFromHBITMAP(hBitmap); + + //alpha channel from window is always wrong, + //coz GDI do not draw all in alpha mode. + //we have to create our own new alpha channel. + bool bFixAlpha = true; + bool bInvert = false; + + // Create monochrome (1 bit) B+W mask bitmap. + HBITMAP hMask = CreateBitmap(size.cx,size.cy, 1, 1, NULL); + HDC hMaskDC = CreateCompatibleDC(0); + SelectBitmap(hMaskDC, hMask); + + //Create a SolidBrush object for non transparent area + HBRUSH hBr = CreateSolidBrush(RGB(255,255,255)); + + HRGN hrgn = NULL; + int regionType; + if(hCapture) { + hrgn = CreateRectRgn(0,0,0,0); + regionType = GetWindowRgn(hCapture, hrgn); + if (regionType != ERROR) { + // not layerd - fill the window region + FillRgn(hMaskDC, hrgn, hBr); + } + else { //layerd window (WS_EX_LAYERED) + BYTE bAlpha= 0; + COLORREF crKey=0; //0x00bbggrr + DWORD dwFlags=0; + if(GetLayeredWindowAttributes(hCapture,&crKey,&bAlpha,&dwFlags)) { + //per window transparency (like fading in a whole window). + if((dwFlags & LWA_ALPHA) == LWA_ALPHA) { + //Use bAlpha to determine the opacity of the layered window. + bFixAlpha = false; + } + if((dwFlags & LWA_COLORKEY) == LWA_COLORKEY) { + //Use crKey as the transparency color. + SetBkColor(hMemDC, crKey); + BitBlt(hMaskDC, 0, 0, size.cx, size.cy, hMemDC, 0, 0, SRCCOPY); + bInvert = true; + bFixAlpha = true; + } + } + else { + //per-pixel transparency (won't use the WM_PAINT ) + bFixAlpha = false; + } + } + } + else { //fill the desktop region + hrgn = CreateRectRgn(0,0,size.cx,size.cy); + FillRgn(hMaskDC, hrgn, hBr); + } + + if(bFixAlpha) { + FIBITMAP* dibMask = FIP->FI_CreateDIBFromHBITMAP(hMask); + if(bInvert) FIP->FI_Invert(dibMask); + FIBITMAP* dib8 = FIP->FI_ConvertTo8Bits(dibMask); + + //copy the dib8 alpha mask to dib32 main bitmap + FIP->FI_SetChannel(dib,dib8,FICC_ALPHA); + FIP->FI_Unload(dibMask); + FIP->FI_Unload(dib8); + } + + //clean up + DeleteObject(hBr); + if(hrgn) DeleteObject(hrgn); + DeleteDC(hMaskDC); + DeleteObject(hMask); + SelectObject(hMemDC, hOld); + DeleteDC(hMemDC); + if(!hDC) ReleaseDC(NULL, hScrDC); + DeleteObject(hBitmap); + #ifdef _DEBUG switch (FIP->FI_GetImageType(dib)){ case FIT_UNKNOWN: @@ -430,7 +430,7 @@ BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder) { BOOL bOk=FALSE; Gdiplus::GetImageEncodersSize(&uiNum,&uiSize); if(uiSize>0){ - Gdiplus::ImageCodecInfo* pImageCodecInfo=(Gdiplus::ImageCodecInfo *)new char[uiSize]; + Gdiplus::ImageCodecInfo* pImageCodecInfo=(Gdiplus::ImageCodecInfo*)mir_alloc(uiSize); if(pImageCodecInfo){ Gdiplus::GetImageEncoders(uiNum,uiSize,pImageCodecInfo); for( UINT i=0; i<uiNum; ++i){ @@ -439,8 +439,8 @@ BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder) { bOk=TRUE; } } + mir_free(pImageCodecInfo); } - delete pImageCodecInfo; } return bOk; } |