当前位置: 移动技术网 > IT编程>开发语言>.net > DSAPI 3张图片实现花开动画

DSAPI 3张图片实现花开动画

2019年04月11日  | 移动技术网IT编程  | 我要评论

溏心风暴3迅雷下载,国乒为什么换刘国梁,新概念英语学习机

效果图

素材

代码

 dim b0, b1, b3 as bitmap
    private b as bitmap = nothing
    private sub loading_load(sender as object, e as eventargs) handles mybase.load
        b0 = my.resources.p0.clone
        b1 = my.resources.p1.clone
        b3 = my.resources.p3.clone
        me.show()
    end sub

    private sub play()
        for i as single = 0.1 to 1.5 step 0.02
            if me.disposing then exit sub
            makebg(i)
            threading.thread.sleep(10)
            application.doevents()
        next
        makebg(1.5)
        threading.thread.sleep(2000)
        for i as single = 255 to 0 step -1
            if me.disposing then exit sub
            dsapi.控件.form窗体.透明窗体样式显示图像(me, b, i)
            application.doevents()
        next
    end sub
    private sub makebg(db as single)
        try
            if b isnot nothing then b.dispose()
            b = nothing
            if db < 1.5 then
                b = b0.clone
                using g as graphics = graphics.fromimage(b)
                    g.clip = new region(new rectangle(0, 0, 625, 656))
                    dim _b1 as bitmap = new bitmap(625, 656)
                    using g2 as graphics = graphics.fromimage(_b1)
                        g2.clip = new region(new rectanglef(0, 0, 625, 656))
                        dim w, h as integer
                        dim _b as bitmap = makeimg(db)
                        w = (625 - _b.width) / 2
                        h = (656 - _b.height) / 2
                        g2.drawimage(_b, new rectangle(w, h, _b.width, _b.height), new rectangle(0, 0, _b.width, _b.height), graphicsunit.pixel)
                        _b.dispose()
                    end using
                    dim _b3 as bitmap = b1.clone
                    dsapi.图形图像.应用透明度遮罩(_b3, _b1)
                    _b1.dispose()
                    g.drawimage(_b3, new rectangle(0, 0, 625, 656), new rectangle(0, 0, 625, 656), graphicsunit.pixel)
                end using
            else
                b = b1.clone
            end if
            dsapi.控件.form窗体.透明窗体样式显示图像(me, b, 255)
        catch
        end try
    end sub

    private sub loading_shown(sender as object, e as eventargs) handles me.shown
        for i as single = 0 to 255
            dsapi.控件.form窗体.透明窗体样式显示图像(me, b0, i)
            application.doevents()
            if me.opacity = 0 then me.opacity = 1
        next
        play()
        me.close()
    end sub

    private function makeimg(db as single) as bitmap
        try
            dim w, h as integer
            w = 410 * db
            h = 431 * db
            dim bb as new bitmap(w, h)
            using g as graphics = graphics.fromimage(bb)
                g.clip = new region(new rectangle(0, 0, w, h))
                g.drawimage(b3, new rectangle(0, 0, w, h), new rectangle(0, 0, 410, 431), graphicsunit.pixel)
            end using
            return bb
        catch
            return nothing
        end try
    end function

  原理:

1 缩放黑影大小,并绘制到和花图一样的图片上

2 使用黑影图作为花图的透明度遮罩,有黑影的地方不透明,其他地方透明

3 将花图绘制到灰白的花上

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网