I encapsulated a method, passed in the corresponding image, it will turn the image into a translucent effect and display it on the program interface.
Void cmegajoycontainer: converttoalpha (cwindowgc & GC, cfbsbitmap * imgtobrighten) const
{
Cfbsbitmap * iemptybitmap = new (eleave) cfbsbitmap ();
Cleanupstack: pushl (iemptybitmap );
User: leaveiferror (iemptybitmap-> Create (imgtobrighten-> sizeinpixels (), ceikonenv: static ()-> defaultdisplaymode ()));
Cfbsbitmapdevice * IgD = cfbsbitmapdevice: newl (iemptybitmap );
Cleanupstack: pushl (IGD );
Cfbsbitgc * IGC;
User: leaveiferror (IGD-> createcontext (IGC ));
IGC-> setpenstyle (cgraphicscontext: enullpen );
IGC-> setbrushcolor (krgbwhite );
IGC-> setbrushstyle (cgraphicscontext: esolidbrush );
IGC-> drawrect (trect (tpoint (0, 0), iemptybitmap-> sizeinpixels ()));
IGC-> setbrushstyle (cgraphicscontext: enullbrush );
Delete IGC;
Cleanupstack: popanddestroy (IGD );
Cfbsbitmap * iemptybitmapmask = new (eleave) cfbsbitmap ();
Cleanupstack: pushl (iemptybitmapmask );
User: leaveiferror (iemptybitmapmask-> Create (imgtobrighten-> sizeinpixels (), egray256 ));
IgD = cfbsbitmapdevice: newl (iemptybitmapmask );
Cleanupstack: pushl (IGD );
User: leaveiferror (IGD-> createcontext (IGC ));
IGC-> setpenstyle (cgraphicscontext: enullpen );
IGC-> setbrushcolor (krgbgray );
IGC-> setbrushstyle (cgraphicscontext: esolidbrush );
IGC-> drawrect (trect (tpoint (0, 0), iemptybitmap-> sizeinpixels ()));
IGC-> setbrushstyle (cgraphicscontext: enullbrush );
Delete IGC;
Cleanupstack: popanddestroy (IGD );
GC. bitbltmasked (tpoint (0, 0), iemptybitmap, trect (tpoint (0, 0), iemptybitmapmask-> sizeinpixels (), iemptybitmapmask, efalse );
Cleanupstack: popanddestroy (iemptybitmapmask );
Cleanupstack: popanddestroy (iemptybitmap );
}
Note that you must add the file to the. MMP file.
Library bitgdi. Lib
Library ws32.lib
Library fbscli. Lib
The effect is as follows:
The original image is
The converted image is