vcl/win/dtrans/FmtFilter.cxx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
New commits: commit c874834280fccd39ee61a6d44babc5c7eb8ec773 Author: Mike Kaganski <[email protected]> AuthorDate: Sun Nov 9 12:53:01 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Sun Nov 9 10:22:01 2025 +0100 Simplify WinBITMAPToOOBMP a bit Use CreateCompatibleDC to avoid using actual desktop DC. Use ScopedHDC for reliable resource management. Change-Id: Ia6662cf50355e4259e1d985d1deec8a828f9c8ef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193649 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/vcl/win/dtrans/FmtFilter.cxx b/vcl/win/dtrans/FmtFilter.cxx index 47aff85c6cf4..d62389235994 100644 --- a/vcl/win/dtrans/FmtFilter.cxx +++ b/vcl/win/dtrans/FmtFilter.cxx @@ -29,6 +29,7 @@ #include <shlguid.h> #include <objidl.h> #include <shellapi.h> +#include <win/scoped_gdi.hxx> #include <string> #include <sstream> @@ -397,8 +398,6 @@ css::uno::Sequence<sal_Int8> CF_HDROPToFileList(HGLOBAL hGlobal) Sequence< sal_Int8 > WinBITMAPToOOBMP( HBITMAP aHBMP ) { - Sequence< sal_Int8 > ooBmpStream; - if (BITMAP bm{}; GetObjectW(aHBMP, sizeof(bm), &bm)) { size_t nDataBytes = ((bm.bmWidth * bm.bmBitsPixel + 31) / 32) * 4 * bm.bmHeight; @@ -414,15 +413,14 @@ Sequence< sal_Int8 > WinBITMAPToOOBMP( HBITMAP aHBMP ) pBmp->bmiHeader.biBitCount = bm.bmBitsPixel; pBmp->bmiHeader.biCompression = BI_RGB; - HDC hdc = GetDC(nullptr); - if (GetDIBits(hdc, aHBMP, 0, bm.bmHeight, pBmp + 1, pBmp, DIB_RGB_COLORS)) + ScopedHDC hdc(CreateCompatibleDC(nullptr)); + if (GetDIBits(hdc.get(), aHBMP, 0, bm.bmHeight, pBmp + 1, pBmp, DIB_RGB_COLORS)) { - ooBmpStream = WinDIBToOOBMP( aBitmapStream ); + return WinDIBToOOBMP(aBitmapStream); } - ReleaseDC(nullptr, hdc); } - return ooBmpStream; + return {}; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
