软件注册站
热情软件屋

 
小的图片需要在大的图片背后做水平和垂直移动
编号: QA004919    
建立日期: 2005年4月24日 最后修改日期: 2005年4月24日
所属类别: Visual Basic - 图形、图象
   
    操作系统:Windows2000 Pro
    编程工具:VB 6.0
    问题:我要实现的功能是,我有两幅背景为透明的GIF图片,一幅比较大的和一幅小的,以Image控件为容器。大的图片作为背景,小的图片和两个Line控件需要在大的图片背后做水平和垂直移动。但需要移动的控件在移动的过程中一直在闪烁。请问一下有什么方法解决?
    水平: 中级(付辉)
   
    周松的意见:
    源代码见附件demo.rar
    Dim IsVisible As Boolean
    
    Private Sub Form_Load()
    
     Image1.Picture = Me.Icon
     Image2.Picture = Me.Icon
    
    End Sub
    
    Private Sub Timer1_Timer()
     IsVisible = Not IsVisible
    
     Image2.Visible = IsVisible
     Line1.Visible = IsVisible
    
     If Image2.Left < 10 Then End
    
     If Not IsVisible Then
     Image2.Left = Image2.Left - 60
     Line1.X1 = Line1.X1 - 60
     Line1.X2 = Line1.X2 - 60
     End If
    
    End Sub
    
    

    
    VB本身动画很难避免闪烁,以为REDRAW实在太慢。
    考虑使用以下API,将最后一个参数设置为PATINVERT,可一定程度改善效果。
    BOOL BitBlt(
     HDC hdcDest, // handle to destination device context
     int nXDest, // x-coordinate of destination rectangle's upper-left
     // corner
     int nYDest, // y-coordinate of destination rectangle's upper-left
     // corner
     int nWidth, // width of destination rectangle
     int nHeight, // height of destination rectangle
     HDC hdcSrc, // handle to source device context
     int nXSrc, // x-coordinate of source rectangle's upper-left
     // corner
     int nYSrc, // y-coordinate of source rectangle's upper-left
     // corner
     DWORD dwRop // raster operation code
    );
    
    Lee Rambow的意见:
    但是要完全不闪烁,我用过的方法只有使用DIRECT,SURFACE之间的FLIP完全可以产生平滑的动画效果。
    参考IDirectDrawSurface3::Blt

    

此问题由周松等回答。

附加关键字:编程, 源程序, programming, source code, Visual Basic, VB, 图形、图象, picture, graph, image, draw

   
 
把这个问题推荐给朋友
   
 
   
您的意见类别
您的名字
您的电子邮件
您的建议(请尽可能详细)
 
 

版权所有 1997-2008 热情软件屋
如果您有任何建议和意见, 请给我发个电子邮件 askpro@china-askpro.com
Web Designed by ZebraStudio