Results 1 to 40 of 59

Thread: [vb6] Class to make Image Controls Support PNG, TIF, GIF Animation

Threaded View

  1. #11
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: [vb6] Class to make Image Controls Support PNG, TIF, GIF Animation

    Code:
               Set m_objPicture = StdPictureEx.LoadPicture(sFileName)
               If Not m_objPicture Is Nothing Then
                  LoadImage = True
                  Dim Bmp As BITMAP
                  GetObject Picture.Handle, Len(Bmp), Bmp
                  m_lImageWidth = Bmp.bmWidth
                  m_lImageHeight = Bmp.bmHeight
               End If
    Code:
    Public Sub AlphaRenderTo(ByVal hDC As Long, Optional ByVal X As Long, Optional ByVal Y As Long, _
                                                               Optional ByVal dx As Long, Optional ByVal dy As Long, _
                                                               Optional ByVal xSrc As Long, Optional ByVal ySrc As Long, _
                                                               Optional ByVal wSrc As Long, Optional ByVal hSrc As Long, _
                                                               Optional ByVal GlobalAlpha As Double = 1)
      If wSrc = 0 Then wSrc = m_lImageWidth
      If hSrc = 0 Then hSrc = m_lImageHeight
     
      If m_objPicture.Handle Then OldBM = SelectObject(mhDC, m_objPicture.Handle)
      GdiAlphaBlend hDC, X, Y, dx, dy, mhDC, xSrc, ySrc, wSrc, hSrc, 2 ^ 24 + &HFF0000 * GlobalAlpha
      If OldBM Then SelectObject mhDC, OldBM
    End Sub
    
    Private Sub Class_Initialize()
       mhDC = CreateCompatibleDC(0)
    End Sub
    OK, I am testing the StdPictureEx.LoadPicture function, I expect it is smart as AlphaImage. But there's limits due to different design?

    Using StdPictureEx.cls loading File path:
    1. I don't see the exposed Public Property of Image Size/Image Type...
    2. I load WMF/EMF/Color Management Jpg/ico, I see nothing.
    3. If the file is gif with single frame, StdPictureEx.LoadPicture(sFileName) doesn't return the first frame. I guess I have to use SubImage for my case (above code)?

    Edited: For 3, I use BitBlt, I see the single frame gif:
    Code:
    BitBlt hDC, X, Y, dx, dy, mhDC, xSrc, ySrc, vbSrcCopy
    'GdiAlphaBlend hDC, X, Y, dx, dy, mhDC, xSrc, ySrc, wSrc, hSrc, 2 ^ 24 + &HFF0000 * GlobalAlpha
    But lose Alpha features if use BitBlt.
    Last edited by Jonney; Dec 7th, 2015 at 08:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width