79609928

Date: 2025-05-07 06:57:09
Score: 0.5
Natty:
Report link

I refer to other answers and comments why your code did not compile.

What I want to mention is that you do not need the std::vector if you have only one bitmap.

Create the bitmap directly on the stack

Gdiplus::Bitmap bitmap(L"images.png");
nWidth  = bitmap.GetWidth();
nHeight = bitmap.GetHeight();
graphics.DrawImage(&bitmap, 950, 200, nWidth, nHeight);

Create the bitmap on the heap

auto bitmap = std::make_unique<Gdiplus::Bitmap>(L"images.png");
nWidth  = bitmap->GetWidth();
nHeight = bitmap->GetHeight();
graphics.DrawImage(bitmap.get(), 950, 200, nWidth, nHeight);

bitmap is an object (and not a pointer) of type std::unique_ptr<Gdiplus::Bitmap>. During destruction, the Gdiplus::Bitmap object it points to will also be destroyed. There is no need to put the unique_ptr into a container.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: michael3.14