PNG to BMP with white background Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 427
Joined: Fri Dec 09, 2016 7:28 am
Contact:

PNG to BMP with white background

Post by cutecode »

Why do I get black background instead of white background

Code: Select all

	wxString x1 = L"c:\\tmp\\1.png";
	wxString x2 = L"c:\\tmp\\2.bmp";
	
	wxImage im;
	im.LoadFile(x1, wxBITMAP_TYPE_PNG);
	
	im.Replace(im.GetMaskRed(), im.GetMaskGreen(), im.GetMaskBlue(), 255, 255, 255);

	im.SaveFile(x2, wxBITMAP_TYPE_BMP);
Thank you
Attachments
1.png
1.png (862 Bytes) Viewed 399 times
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: PNG to BMP with white background

Post by doublemax »

That png has an alpha channel, try calling wxImage::ConvertAlphaToMask() first.
Use the source, Luke!
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 427
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: PNG to BMP with white background

Post by cutecode »

Thank you!!!
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
Post Reply