diff --git a/Contrib/InstallOptions/InstallerOptions.cpp b/Contrib/InstallOptions/InstallerOptions.cpp index f29b855a..43078d8b 100644 --- a/Contrib/InstallOptions/InstallerOptions.cpp +++ b/Contrib/InstallOptions/InstallerOptions.cpp @@ -101,6 +101,7 @@ char *WINAPI STRDUP(const char *c) // LBS_MULTIPLESEL 0x00000008 // LISTBOX #define FLAG_READONLY 0x00000010 // TEXT/FILEREQUEST/DIRREQUEST // BS_LEFTTEXT 0x00000020 // CHECKBOX/RADIOBUTTON +#define TRANSPARENT_BMP 0x00000020 // BITMAP #define FLAG_PASSWORD 0x00000040 // TEXT/FILEREQUEST/DIRREQUEST #define FLAG_ONLYNUMBERS 0x00000080 // TEXT/FILEREQUEST/DIRREQUEST #define FLAG_MULTILINE 0x00000100 // TEXT/FILEREQUEST/DIRREQUEST @@ -476,6 +477,7 @@ int WINAPI ReadSettings(void) { { "HSCROLL", WS_HSCROLL }, { "VSCROLL", WS_VSCROLL }, { "DISABLED", WS_DISABLED }, + { "TRANSPARENT", TRANSPARENT_BMP }, { NULL, 0 } }; FieldType *pField = pFields + nIdx; @@ -1191,6 +1193,7 @@ int WINAPI createCfgDlg() { WPARAM nImageType = pField->nType == FIELD_BITMAP ? IMAGE_BITMAP : IMAGE_ICON; LPARAM nImage = 0; + if (pField->pszText) { pField->hImage = LoadImage( m_hInstance, @@ -1208,12 +1211,76 @@ int WINAPI createCfgDlg() } else nImage = (LPARAM)LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(103)); + + if ((pField->nFlags & TRANSPARENT_BMP) && nImageType == IMAGE_BITMAP) + { + // based on AdvSplash's SetTransparentRegion + BITMAP bm; + HBITMAP hBitmap = (HBITMAP) nImage; + + if (GetObject(hBitmap, sizeof(bm), &bm)) + { + HDC dc; + int x, y; + HRGN region, cutrgn; + BITMAPINFO bmi; + int size = bm.bmWidth * bm.bmHeight * sizeof(int); + int *bmp = (int *) MALLOC(size); + if (bmp) + { + bmi.bmiHeader.biBitCount = 32; + bmi.bmiHeader.biCompression = BI_RGB; + bmi.bmiHeader.biHeight = bm.bmHeight; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biWidth = bm.bmWidth; + bmi.bmiHeader.biClrUsed = 0; + bmi.bmiHeader.biClrImportant = 0; + + dc = CreateCompatibleDC(NULL); + SelectObject(dc, hBitmap); + + x = GetDIBits(dc, hBitmap, 0, bm.bmHeight, bmp, &bmi, DIB_RGB_COLORS); + + region = CreateRectRgn(0, 0, bm.bmWidth, bm.bmHeight); + + int keycolor = *bmp & 0xFFFFFF; + + // Search for transparent pixels + for (y = bm.bmHeight - 1; y >= 0; y--) { + for (x = 0; x < bm.bmWidth;) { + if ((*bmp & 0xFFFFFF) == keycolor) { + int j = x; + while ((x < bm.bmWidth) && ((*bmp & 0xFFFFFF) == keycolor)) { + bmp++, x++; + } + + // Cut transparent pixels from the original region + cutrgn = CreateRectRgn(j, y, x, y + 1); + CombineRgn(region, region, cutrgn, RGN_XOR); + DeleteObject(cutrgn); + } else { + bmp++, x++; + } + } + } + + // Set resulting region. + SetWindowRgn(hwCtrl, region, TRUE); + DeleteObject(region); + DeleteObject(dc); + FREE(bmp); + } + } + } + mySendMessage( hwCtrl, STM_SETIMAGE, nImageType, nImage ); + if (pField->nType == FIELD_BITMAP) { // Centre the image in the requested space. @@ -1226,6 +1293,7 @@ int WINAPI createCfgDlg() SetWindowPos(hwCtrl, NULL, bmp_rect.left, bmp_rect.top, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); } + break; } diff --git a/Contrib/InstallOptions/Readme.html b/Contrib/InstallOptions/Readme.html index 6ca35356..579c0c0b 100644 --- a/Contrib/InstallOptions/Readme.html +++ b/Contrib/InstallOptions/Readme.html @@ -492,6 +492,13 @@ resize the image to the size of the control. Also useful to support custom DPI settings. Without this, the image will be centered within the specified area. +TRANSPARENT +Used by "Bitmap" controls. Hides +every pixel with the same color as of the top left pixel. This +allows to see-through to controls behind it. This flag doesn't +work well with a combination of the RESIZETOFIT flag and bitmaps +with more than 256 colors. + GROUP Add this flag to the first control of a diff --git a/Plugins/InstallOptions.dll b/Plugins/InstallOptions.dll index f274579a..ee1e6cf4 100644 Binary files a/Plugins/InstallOptions.dll and b/Plugins/InstallOptions.dll differ