| 25 | }; |
| 26 | |
| 27 | winrt::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 | |
| 54 | winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutItem FileContextMenu::makeMenuFlyout(MENUITEMINFO const& menuItemInfo) |
| 55 | { |
nothing calls this directly
no test coverage detected