Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have png in Gdiplus::image. I can render image using below code.
Gdiplus::Graphics graphics(dc);
graphics.DrawImage(m_pBitmap, 0, 0);
Now how to draw png with a transparent color so all pixels of a certain color (for example: RGB(255,255,255)) show transparently and you can see the background where the transparent pixels are using Gdiplus.
Can I get any sample code?
Gdiplus::Bitmap bm(L"transparent.png", TRUE);
if(bm.GetLastStatus() == Gdiplus::Status::Ok)
Gdiplus::Graphics gr(hdc);
Gdiplus::ImageAttributes attr;
attr.SetColorKey(Gdiplus::Color(255, 255, 255), Gdiplus::Color(255, 255, 255),
Gdiplus::ColorAdjustTypeBitmap);
gr.DrawImage(
Gdiplus::Rect(0, 0, bm.GetWidth(), bm.GetHeight()),
0, 0, bm.GetWidth(), bm.GetHeight(),
Gdiplus::UnitPixel,
&attr);
MessageBox(0, L"error", 0, 0);
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.