Using VB to achieve semi-transparent superposition of two images

Source: Internet
Author: User

the Code is simple. It does not explain how VB achieves the semi-transparent superposition of two images.

Option explicit </P> <p> private declare function createcompatibledc lib "GDI32" (byval HDC as long) as long <br/> private declare function deletedc lib "GDI32" (byval HDC as long) As long <br/> private declare function SelectObject lib "GDI32" (byval HDC as long, byval hobject as long) As long <br/> private declare function deleteobject lib "GDI32" (byval hobject as long) as long <br/> private declare function alphablend lib "msimg32" (byval hdestdc as long, byval X as long, byval y as long, byval nwidth as long, byval nheight as long, byval hsrcdc as long, byval xsrc as long, byval ysrc as long, byval widthsrc as long, byval heightsrc as long, byval blendfunct as long) as Boolean </P> <p> private sub form_load () <br/> dim w as long, H as long <br/> dim pic1 as stdpicture, pic2 as stdpicture <br/> dim hmemdc1 as long, hmemdc2 as long <br/> dim holdbmp1 as long, holdbmp2 as long </P> <p> set pic1 = loadpicture ("C:/pic1.jpg") <br/> hmemdc1 = createcompatibledc (Me. HDC) <br/> holdbmp1 = SelectObject (hmemdc1, pic1.handle) </P> <p> set pic2 = loadpicture ("C:/pic2.jpg ") <br/> W = me. scalex (pic2.width, vbhimetric, vbpixels) <br/> H = me. scaley (pic2.height, vbhimetric, vbpixels) <br/> hmemdc2 = createcompatibledc (Me. HDC) <br/> holdbmp2 = SelectObject (hmemdc2, pic2.handle) <br/> alphablend hmemdc1, 0, 0, W, H, hmemdc2, 0, 0, W, H, 100 * & h10000 </P> <p> deleteobject SelectObject (hmemdc2, holdbmp2) <br/> deletedc hmemdc2 <br/> set pic2 = nothing </P> <p> SelectObject hmemdc1, holdbmp1 <br/> deletedc hmemdc1 <br/> set me. picture = pic1 <br/> set pic1 = nothing <br/> end sub <br/>

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.