MCPcopy Create free account
hub / github.com/HO-COOH/FastCopy / getIconFromWin32Menu

Method getIconFromWin32Menu

FastCopy/FileContextMenu.cpp:27–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25};
26
27winrt::Microsoft::UI::Xaml::Media::ImageSource FileContextMenu::getIconFromWin32Menu(HBITMAP menuItemInfoBitmap)
28{
29 static GdiplusInitializer s_gdiPlusInitializer;
30 if (!menuItemInfoBitmap)
31 return nullptr;
32
33 auto pbitmap = Gdiplus::Bitmap::FromHBITMAP(menuItemInfoBitmap, NULL);
34 INT const height = pbitmap->GetHeight();
35 INT const width = pbitmap->GetWidth();
36
37 Gdiplus::Color c{Gdiplus::Color::MakeARGB(255, 0, 0, 0)};
38
39 Gdiplus::Rect bmBounds{0, 0, (INT)width, (INT)height};
40 Gdiplus::BitmapData data{};
41 pbitmap->LockBits(&bmBounds, Gdiplus::ImageLockModeRead, PixelFormat32bppRGB, &data);
42
43 Gdiplus::Bitmap tmp{width, height, data.Stride, PixelFormat32bppARGB, (BYTE*)data.Scan0};
44 Gdiplus::Bitmap clone{width, height, PixelFormat32bppARGB};
45
46 Gdiplus::Graphics* gr = Gdiplus::Graphics::FromImage(&clone);
47 gr->DrawImage(&tmp, bmBounds);
48
49 HBITMAP hbitmap{};
50 clone.GetHBITMAP(c, &hbitmap);
51 return HBitmapToWriteableBitmap(hbitmap);
52}
53
54winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItem FileContextMenu::makeMenuFlyout(MENUITEMINFO const& menuItemInfo)
55{

Callers

nothing calls this directly

Calls 1

HBitmapToWriteableBitmapFunction · 0.85

Tested by

no test coverage detected