[Game Template 8] Win32 Transparent Map

Source: Internet
Author: User

>_<: The same with previous introduction. In the InitInstance fanction make a littlechange:

>_<:yes just add another picture "dra.bmp" and give the handle to DRA. And then call function Mypaint (...)

1Hdc=GetDC (hWnd);2Mdc=CreateCompatibleDC (HDC);3 4Bg= (HBITMAP) LoadImage (NULL,"bg.bmp", Image_bitmap, -, the, lr_loadfromfile);5Dra= (HBITMAP) LoadImage (NULL,"dra.bmp", Image_bitmap, -,124, lr_loadfromfile);6 //name, type, size, loading mode;7 8 Mypaint (HDC);9ReleaseDC (HWND,HDC);

>_<:as following here is the mypaint (...) function:

>_<:in This function :

    • firstly ,  move the picture "bg.bmp" to Compatibledc MDC by its handle BG.
    • then  copy MDC to HDC. Until now there was no change.
    • and then  move dra to mdc,latter using twice BitBlt.

Here we can see: the seventh line, only USE&NBSP;MDC ' S lower  part do an operation Srcand; The eighth line,use another part of the MDC does an operation srcpaint.  for why through the steps can achieve  transparency? it involves some knowledge of image science, here would not introduce.)

>_<! However, One thing must be reminded : The picture of dra.bmp must use following style form:

&NBSP; Yes,the part so you don ' t want to show must use the black background and this part would be done the operation late than Another part. and Another part  includes so you want to show must is black, you don ' t want t O Show must be white!

>_<:mypaint (...)

1 voidMypaint (hdc hdc)2 {3 SelectObject (MDC,BG);4BITBLT (HDC,0,0,1366,768Mdc0,0, srccopy);//in window position, size, original cut bit5 6 SelectObject (Mdc,dra);7BITBLT (HDC, $, the, -, +Mdc0, +, Srcand);8BITBLT (HDC, $, the, -, +Mdc0,0, srcpaint);9}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.