diff --git a/Docs/src/ui.but b/Docs/src/ui.but index da618de2..44dc631d 100644 --- a/Docs/src/ui.but +++ b/Docs/src/ui.but @@ -75,7 +75,7 @@ If HWND is a window, Gotos jump_if_window, otherwise, Gotos jump_if_not_window ( \c [/EXERESOURCE] [/STRINGID] [/RESIZETOFIT[WIDTH|HEIGHT]] ctrl imagetype lrflags image -Loads and sets a image on a static control. \cw{ctrl} is the handle of the control. \cw{imagetype} must 0 for bitmaps and 1 for icons (and the control style must match the image type). \cw{lrflags} must be 0x10 to load from a file or 0 to load from a resource. \cw{image} specifies the file path or resource name. Use \cw{/EXERESOURCE} to load a resource from the installer .EXE. Use \cw{/STRINGID} if \cw{image} is a string, otherwise it is interpreted as a number. Use \cw{/RESIZETOFIT[WIDTH|HEIGHT]} to resize the image to the dimensions of the control. +Loads and sets a image on a static control. \cw{ctrl} is the handle of the control. \cw{imagetype} must 0 for bitmaps and 1 for icons (and the control style must match the image type). \cw{lrflags} should be 0x10 to load from a file or 0 to load from a resource. \cw{image} specifies the file path or resource name. Use \cw{/EXERESOURCE} to load a resource from the installer .EXE. Use \cw{/STRINGID} if \cw{image} is a string, otherwise it is interpreted as a number. Use \cw{/RESIZETOFIT[WIDTH|HEIGHT]} to resize the image to the dimensions of the control. \c LoadAndSetImage /EXERESOURCE $hIconStatic 1 0 103 \c LoadAndSetImage /STRINGID /RESIZETOFITWIDTH $hBmpStatic 0 0x10 "$PluginsDir\myimg.bmp" diff --git a/Source/BinInterop.cpp b/Source/BinInterop.cpp index 474e0b24..d53b27be 100644 --- a/Source/BinInterop.cpp +++ b/Source/BinInterop.cpp @@ -461,7 +461,8 @@ DWORD GetDIBHeaderInfo(const void*pData, size_t DataSize, GENERICIMAGEINFO&Info) } if (size >= 16) // OS22XBITMAPHEADER/BITMAPINFOHEADER/BITMAPV*HEADER { - Info.Width = LE2HE32(p32[1]), Info.Height = (INT32) LE2HE32(p32[2]); + Info.Width = LE2HE32(p32[1]), Info.RawHeight = (INT32) LE2HE32(p32[2]); + Info.Height = abs(Info.RawHeight); Info.Planes = LE2HE16(p16[6+0]), Info.BPP = LE2HE16(p16[6+1]); return size; } @@ -475,7 +476,7 @@ DWORD IsBMPFile(const void*pData, size_t DataSize, GENERICIMAGEINFO*pInfo) if (DataSize >= 14+12 && p8[0] == 'B' && p8[1] == 'M') { DWORD *p32 = (DWORD*) (&p8[2]), fsize = LE2HE32(p32[0]), bitsoffs = LE2HE32(p32[2]); - if ((!fsize || fsize > 14+12) && (!bitsoffs || bitsoffs > 14+12)) + if ((!fsize || fsize > 14+12) && (!bitsoffs || bitsoffs >= 14+12)) { GENERICIMAGEINFO info; return GetDIBHeaderInfo(p8 + 14, DataSize - 14, pInfo ? *pInfo : info); diff --git a/Source/BinInterop.h b/Source/BinInterop.h index 657a4d02..5b8c20ab 100644 --- a/Source/BinInterop.h +++ b/Source/BinInterop.h @@ -29,6 +29,7 @@ bool GetDLLVersion(const TCHAR *filepath, DWORD &high, DWORD &low); typedef struct { UINT32 Width, Height; + INT32 RawHeight; WORD BPP, Planes; } GENERICIMAGEINFO; diff --git a/Source/ResourceEditor.cpp b/Source/ResourceEditor.cpp index ff5771d6..1fd45cb0 100644 --- a/Source/ResourceEditor.cpp +++ b/Source/ResourceEditor.cpp @@ -770,6 +770,8 @@ bool CResourceEditor::AddExtraIconFromFile(const WINWCHAR* Type, WINWCHAR* Name, GENERICIMAGEINFO info; if (/*!IsPNGFile(pImg, imgSize, &info) &&*/ !GetDIBHeaderInfo(pImg, imgSize, info)) // Are PNG cursor images allowed? goto fail; + //if (info.RawHeight != info.Height && isDib) + // goto fail; // Are TopDown DIBs allowed? Probably not but we play it safe. typedef struct { WORD x, y; } CURSORIMGHDR; //msdn.microsoft.com/en-us/library/windows/desktop/ms648017(v=vs.85).aspx pCursor = new BYTE[imgSize + 4]; diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 3433cff5..5c8298d2 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -1342,7 +1342,7 @@ static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l hTreeItems=(HTREEITEM*)GlobalAlloc(GPTR,sizeof(HTREEITEM)*num_sections); - hBMcheck1=LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1)); + hBMcheck1=LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); // LR_CREATEDIBSECTION required to load TopDown bitmaps last_selected_tree_item=-1; oldTreeWndProc=(WNDPROC)SetWindowLongPtr(hwndTree1,GWLP_WNDPROC,(LONG_PTR)newTreeWndProc);