[vb6]Alpha Image Control v2 - Final Update (15 Jan 2012) - Page 5-VBForums
Page 5 of 12 FirstFirst ... 2345678 ... LastLast
Results 161 to 200 of 479

Thread: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)

  1. #161
    Member
    Join Date
    Aug 2006
    Posts
    53

    Exclamation Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [14 Apr 2011]

    Mr. lavolpe...

    how to integrated ListView n LavolepeImageList???
    Lavolpe ImageList
    http://www.Planet-Source-Code.com/vb...69621&lngWId=1

    please help me....

  2. #162

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [14 Apr 2011]

    Quote Originally Posted by afdoal View Post
    Mr. lavolpe...

    how to integrated ListView n LavolepeImageList???
    Lavolpe ImageList
    http://www.Planet-Source-Code.com/vb...69621&lngWId=1

    please help me....
    You cannot. That was mentioned in the comments/feedback section of that link. That control was designed for users of custom drawn controls (i.e., buttons, grid controls, image controls, etc) where the image is not assigned to a property, but drawn manually on the control. Hope that answers your question. I've stopped supporting all code on PSC when I left PSC. I won't be making any changes to that project nor re-creating it.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #163

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [1 June 2011]

    Updated 1 Jun 2011

    - Added support for creating animated GIFs
    - Added support for creating multi-image icons/cursors
    - Added support for creating PNG-embedded icons/cursors (Vista and above can read these)

    See the comments/examples in AICGlobals.SavePictureGDIplus class and also the SavePictureGDIp.rtf file
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #164
    Lively Member
    Join Date
    May 2011
    Posts
    86

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [2 June 2011]

    Thanks Lavolpe for the bug explanation,

    I'm sorry I missed it in the forums I'll look more into it.

    regards

  5. #165
    New Member
    Join Date
    May 2011
    Posts
    15

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [2 June 2011]

    Hi Folks,

    I recently recieved a requiriment that should be addressed with rotated transparent text in different angles even with different font sizes and colors.

    Does anyone has ideas on how to accomplish that?

    I saw this code http://www.vbaccelerator.com/codelib...o/sidelogo.htm
    but unfortunatly it seems that could not handle transparencies and font colors.

    Thanks in advance

    B.

  6. #166

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [2 June 2011]

    Quote Originally Posted by Bigweld View Post
    ...I recently recieved a requiriment that should be addressed with rotated transparent text in different angles even with different font sizes and colors.
    Does anyone has ideas on how to accomplish that? ...
    Please do not post questions here not directly related to my project. Your question should be posted in the graphics or vb portion of the forums. Thank you.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #167
    New Member
    Join Date
    May 2011
    Posts
    15

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [2 June 2011]

    Hi All,

    Sorry. You are right. Is there any way to remove it from the current thread?
    Thanks

    B.

  8. #168

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [2 June 2011]

    Don't worry about it. It'll serve as a reminder for others. I think I read somewhere that the 'privilege' of deleting your posts was tied to some magic number of overall posts one has made as a forum member. Anyway, here's the "how to" if you are enabled to.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #169
    New Member
    Join Date
    May 2011
    Posts
    15

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [2 June 2011]

    Hi Lavolpe

    I'm trying to present images using AlphaImgCtl controls dynamically generated.
    The last dynamically created image should be presented at the top in the zOrder but I could not get it.
    Regardless the ZOrder I set, the firt presented image remains at the top and the rest are presented behind it.

    There is the code that I made:

    a) This is the part that dynamically creates the set of images to be used. This set is not visible to the user while the program runs.

    Code:
    Sub LoadDeck()
    
    Dim f           As Byte
    Dim Lavolpe(51) As AlphaImgCtl
    
    For f = 0 To 51
       Set Lavolpe(f) = Controls.Add("LaVolpeAlphaImg.AlphaImgCtl", "Lavolpe" & CStr(f))
       Lavolpe(f).Picture = LoadPictureGDIplus(CARD_BASE_PATH & CStr(f) & PNG_EXTENSION)
    Next
    
    End Sub
    b) This is the part that uses the previous generated controls and then sets the image according the desired index when necessary.

    Code:
    Sub ShowCard(OffsetMultiplier As Byte)
       
       Static z  As Byte
       Dim a     As AlphaImgCtl
       
       Set a = Controls.Add("LaVolpeAlphaImg.AlphaImgCtl", "c" & CStr(z), Me)
    
       With a
          .Top = CARD_INITIAL_POSY - (POSY_CARD_OFFSET * OffsetMultiplier)
          .Left = 527
          .Width = 180
          .Height = 270
          Set .Picture = Lavolpe(m.CardID).Picture
          .ZOrder z
          .Enabled = True
          .Visible = True
       End With
       z = z + 1
     
     End Sub
    Would you like to take a look to it, please?
    Not sure if there is an issue of the AlphaImgCtl or mine

    Thanks in advance

    B.

    PS: Its seems like the 'delete post' option is not avalible. I see just the 'edit post' option while trying to remove my previous post. Sorry.

  10. #170

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [2 June 2011]

    You have to understand the ZOrder method. Your z variable is useless. The only two values allowed for the ZOrder method are: vbSendToBack or vbBringToFront.

    Edited: Has nothing to do with the Alpha Image Control. The ZOrder method is one that all VB controls have, including usercontrols created with VB. The control itself does not process that, VB does for the control.
    Last edited by LaVolpe; Jun 4th, 2011 at 09:57 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  11. #171
    New Member
    Join Date
    May 2011
    Posts
    15

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [2 June 2011]

    Thank you, for pointing me the error.
    B.

  12. #172

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [12 June 2011]

    FYI: Small enhancement added today... The Interpolation property.
    By default the image quality is always highest possible. It will render with high-quality bicubic interpolation whenever the image is rotated or scaled to a different size than the original. There may be cases when a lower quality rendering is desired. Basically lower quality means faster renders, while higher qualities mean slower renders. Now you have that option to render at any of the other 5 quality settings offered.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  13. #173

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [12 June 2011]

    A question came up recently how one can use rotation to animate a "knob" manually. Here's one idea.

    1. Add an AlphaImgCtl to your form
    2. Assign that control a nice picture of a knob or something circular
    3. If the picture is not circular
    -- change the control's .AutoSize property to lvicMultiAngle & control will resize itself
    -- change the control's .AutoSize property to lvicNoAutoSize & adjust size as needed
    -- set the control's .Rotation property to several settings at 45 degree intervals to ensure image is not cropped at those angles
    -- if image is cropped at a certain angle, enlarge your control size a bit & repeat previous 2 steps
    4. Paste this code in your form
    Code:
    Private m_StartAngle As Single
    
    Private Sub AlphaImgCtl1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            With AlphaImgCtl1
                ' want zero degrees due North, so passing an offset of -90
                m_StartAngle = CalculateAngle(X - .ScaleWidth \ 2, Y - .ScaleHeight \ 2, -90)
            End With
        End If
    End Sub
    
    Private Sub AlphaImgCtl1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            ' want zero degrees due North, so passing an offset of -90
            X = CalculateAngle(X - AlphaImgCtl1.ScaleWidth \ 2, Y - AlphaImgCtl1.ScaleHeight \ 2, -90)
            Y = (X - m_StartAngle)
            If Y Then
                AlphaImgCtl1.Rotation = AlphaImgCtl1.Rotation + Y
                m_StartAngle = X
                ' perform whatever action the knob would do: change sound volume, rotate some other image, etc
            End If
        End If
    End Sub
    
    Private Function CalculateAngle(ByVal X As Single, ByVal Y As Single, _
                        Optional AngleOffset As Single, Optional AngleStep As Single = 1!) As Single
        
        ' returns a Degree vs Radian usable for properties that require angles in degrees vs. radians
        
        ' X & Y must be offset from a reference point
        '   -- the reference point is usually the center of whatever you want rotated
        '   -- So X may be: X - CenterPoint
        '       and Y may be: Y - CenterPoint
        ' AngleOffset is used to change what 0 degrees is relative to
        '   -- by default, 0 degrees is due West
        '   -- if you want due North to be 0 degrees, then pass AngleOffset as -90
        '   -- Why -90? If 0 is really due West then due North is 90 (clockwise rotation), 
        '       so to make due North zero, we need to subtract 90 
        ' AngleStep is used to restrict returned degrees to a fixed step value
        '   -- If you want the degrees to be returned in increments of 10, then pass 10
        '   -- If AngleStep is 10, then degrees < 10 will be returned as zero, < 20 returned as 10, etc
        
        Dim Radian As Single
        Dim xDiff As Single
        Dim yDiff As Single
        Dim Angle As Single
        
        Const PI As Single = 3.14159265358979
        
        xDiff = -X
        yDiff = -Y
        
        If Abs(xDiff) < 0.00000001 Then xDiff = 0!
        If Abs(yDiff) < 0.00000001 Then yDiff = 0!
        
        If xDiff <> 0! Then
            Radian = Atn(yDiff / xDiff)
            If xDiff < 0 Then Radian = Radian + PI
        Else
            If yDiff < 0 Then
                Radian = 3! * PI / 2! '90
            Else
                Radian = PI / 2! '270
            End If
        End If
        
        If Radian < 0! Then Radian = Radian + PI * 2!
        Angle = Radian * (180! / PI) + AngleOffset
        If Angle < 0! Then Angle = Angle + 360!
        
        ' restrict rotation to n degree increments
        If AngleStep Then
            CalculateAngle = Int((Angle \ AngleStep) * AngleStep)
        Else
            CalculateAngle = Angle
        End If
    
    End Function
    5. Now run your form, hold mouse down on the control and start rotating it.

    Edited: Using above code, you will notice that sensitivity to changes is greater while mouse is closer to center of control and less sensitive the further away the mouse is from that center.

    Edited yet again. For those that use the above logic, the assumption is that the image is rendered center of control. If image is rendered top left, adjust the center point in MouseDown & MouseMove

    If you get an error saying .ScaleWidth & .ScaleHeight are not supported, you are using a previous version of the control.
    Last edited by LaVolpe; Jun 29th, 2011 at 08:01 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  14. #174
    Hyperactive Member
    Join Date
    Jan 2010
    Posts
    363

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [12 June 2011]

    Quote Originally Posted by LaVolpe View Post
    A question came up recently how one can use rotation to animate a "knob" manually. Here's one idea.

    1. Add an AlphaImgCtl to your form
    2. Assign that control a nice picture of a knob or something circular
    3. If the picture is not circular
    -- change the control's .AutoSize property to lvicMultiAngle & control will resize itself
    -- change the control's .AutoSize property to lvicNoAutoSize & adjust size as needed
    -- set the control's .Rotation property to several settings at 45 degree intervals to ensure image is not cropped at those angles
    -- if image is cropped at a certain angle, enlarge your control size a bit & repeat previous 2 steps
    4. Paste this code in your form
    5. Now run your form, hold mouse down on the control and start rotating it.

    Edited: Using above code, you will notice that sensitivity to changes is greater while mouse is closer to center of control and less sensitive the further away the mouse is from that center.
    Good algorithm (CalculateAngle) for rotation using 'knob' manually. But we can resize AIC & rotate pic at the same time with a bit of modification of CalculateAngle (using xDiff and center position of AIC to determine the zoom changes).
    One annoying thing is GDI+ doesn't draw Anti-aliasing for two edges of a rotated pictures.
    Last edited by Jonney; Jun 29th, 2011 at 01:03 AM. Reason: resize AIC & rotate pic at the same time

  15. #175

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [12 June 2011]

    Another nice routine.

    version 1.1 of GDI+ library has some niffty effects but not available to v1.0 of GDI+. One such effect is a blur. v1.1 has a true gaussian blur routine. If you want a blur routine for v1.0, the following may be useful. It is not a true blur but produces good results.

    You'll need these 2 GDI+ API delcarations
    Code:
    Private Declare Function GdipGetImageGraphicsContext Lib "gdiplus.dll" (ByVal pImage As Long, ByRef graphics As Long) As Long
    Private Declare Function GdipDeleteGraphics Lib "gdiplus.dll" (ByVal mGraphics As Long) As Long
    1. On a new form, add 2 AlphaImgCtl controls and 1 command button
    2. Add an image to AlphaImgCtl1
    3. Make the AlphaImgCtl2 same size as AlphaImgCtl1
    4. Copy & paste following code. Run project & click on the button. Play with different blur depths
    Code:
    Private Sub Command1_Click()
    ' modified from this source: http://www.autohotkey.net/~tic/Gdip.ahk
    
        Dim tImg As GDIpImage
        Dim SS As SAVESTRUCT, hGraphics As Long
        
        ' create a new blank image same size as source image & place in 2nd image control
        SS.ColorDepth = lvicConvert_TrueColor32bpp_pARGB
        SS.Width = AlphaImgCtl1.Picture.Width
        SS.Height = AlphaImgCtl1.Picture.Height
        Set tImg = New GDIpImage
        SavePictureGDIplus Nothing, tImg, , SS
        Set AlphaImgCtl2.Picture = tImg
        
        ' create new temp blank image a fraction size of source image
        ' change the percentage to smaller values for greater effect & higher for lesser effect
        SS.Width = AlphaImgCtl1.Picture.Width * 0.33
        SS.Height = AlphaImgCtl1.Picture.Height * 0.33
        If SS.Width = 0 Or SS.Height = 0 Then
                MsgBox "Blur depth is too great"
                Exit Sub
        End If
        Set tImg = New GDIpImage
        SavePictureGDIplus Nothing, tImg, , SS
        
        ' render the source image onto temp image at fraction of size
        GdipGetImageGraphicsContext tImg.Handle, hGraphics ' function only works for 24bpp & above
        AlphaImgCtl1.Picture.Render 0&, , , SS.Width, SS.Height, , , , , , , hGraphics, , lvicHighQualityBicubic
        GdipDeleteGraphics hGraphics
        
        ' render temp image to full size and update 2nd control
        GdipGetImageGraphicsContext AlphaImgCtl2.Picture.Handle, hGraphics
        tImg.Render 0&, , , AlphaImgCtl1.Picture.Width, AlphaImgCtl1.Picture.Height, , , , , , , hGraphics, , lvicHighQualityBicubic
        GdipDeleteGraphics hGraphics
        AlphaImgCtl2.Refresh
        Set tImg = Nothing
    
    End Sub
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  16. #176

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [12 July 2011]

    FYI. Updated version posted today.

    - Fixed couple minor errors in ICO & GIF creation routines
    - Added ability to load image from Base64 encoded string
    - Added AlphaMask & RenderSkewed functions to GDIpImage class (see class comments)
    - Updated couple sample projects using newly added functions (see Change History on post #1)
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  17. #177
    New Member
    Join Date
    Jul 2011
    Posts
    3

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    WOW lavolpe
    Good day
    Very good and interesting your project, excuse my question, is there any way to remove the rest of the form and only leave the control and also encourage you, thank you for your answer

  18. #178

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    astronald, welcome to the forums.

    The zip file containing the control. Unzip it to a folder and open the .vbp file. Compile it. It will become a stand-alone OCX that you can add to your toolbox whenever you want. Should I update the control and you re-download, be sure to compile future revisions with binary compatibility. There is a link in post #1 I point people to, to better understand binary compatibility if this is a new topic to you.

    The zip file containing the sample projects are there just for educational purposes. They have no bearing on the actual control.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  19. #179
    New Member
    Join Date
    Jul 2011
    Posts
    3

    Thumbs up Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]



    Thanks Lavolpe, I liked the clock project would be done without you see the gray background of the form, thanks again for your help.


  20. #180
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    I have a memory leak in my project which is loading and unloading alpha image controls in a control array. It seems as though every time I add another object to the array it will add two gdi objects however when I unload an object either one or no gdi objects will go away. Iíve attached a simple project which shows the problem.
    Attached Files Attached Files

  21. #181

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Quote Originally Posted by cheesebrother View Post
    I have a memory leak in my project which is loading and unloading alpha image controls in a control array...
    Edited: For others reading this post. If you read my "Memory Leak FAQ", linked in my signature below, you'll know what we are talking about, regarding GDI counts.

    I can't reproduce the problem. Well, I can sort of

    1. My baseline GDI count is 513 let's say. That's the count before running the project
    2. I run the project (ensuring no other VB MDI child widows open). Count = 525
    3. I add 5 new controls & count rises to 534
    4. I then remove those 5 controls & count drops to 529

    It does appear 1 leak per object. But it isn't & here's why:
    5. Close form normally. Count now reads: 513

    When VB loads DLLs/OCXs. It doesn't exactly clean up memory right away when the instance of it is removed. I can't tell you the intricacies of how VB's garbage collection works because I don't know. However, the fact that the GDI count did not change from starting the project to ending the project, indicates no leaks. Agreed?
    Last edited by LaVolpe; Jul 29th, 2011 at 10:45 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  22. #182
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Thanks. I can see what you're saying. Great control.

  23. #183

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Quote Originally Posted by cheesebrother View Post
    Thanks. I can see what you're saying. Great control.
    You're welcome & thanks for the compliment.

    FYI: Using your sample code, you can reduce memory usage. Add this before making your control visible
    Code:
    Set object(object.UBound).Picture = object(object.LBound).Picture
    When you dynamically load a control that already contains a picture, that picture's data & GDI+ objects are replicated not shared. You can verify this by printing out the object(object.UBound).Picture.Handle property. Using the above tweak, all is shared. However, in post #3 back on page #1, read the gotchas about sharing multi-image formats
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  24. #184
    New Member
    Join Date
    Jul 2011
    Posts
    1

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Hello
    I've been using LaVolpeAlphaImg.

    To become a better control
    I hope the following features are added.

    1. picturebox, grid control with the features that happens when you come to a top layer
    2. Png in the form to apply full-screen window (like the splash window)

    Pay as you think, if this feature has to pay.
    Have a nice day.

  25. #185
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    There is one other thing that i've been trying to do. Is there a way to have vb compile the alpha image control pictures without putting them in a resource file? I tried running my program on another computer and got an error that said "Component 'LaVolpeAlphaImg3.ocx' or one of its dependancies not correctly registered: A file is missing or invalid."

  26. #186

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Quote Originally Posted by shaneshock@nate.com View Post
    To become a better control
    I hope the following features are added.

    1. picturebox, grid control with the features that happens when you come to a top layer
    2. Png in the form to apply full-screen window (like the splash window)
    #1. Have no idea what you are suggesting. Are you asking for a picturebox control version of the Alpha Image Control? If so, won't happen. This control cannot be made to be a container of other controls, especially windowed controls.

    #2. Not sure what you meant there either. If you want the control & image to size to the form, simply change the control's dimensions in the form's resize event. Also set the Aspect & AlignCenter properties for the stretching/alignment of the contained image, as desired.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  27. #187

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Quote Originally Posted by cheesebrother View Post
    There is one other thing that i've been trying to do. Is there a way to have vb compile the alpha image control pictures without putting them in a resource file? I tried running my program on another computer and got an error that said "Component 'LaVolpeAlphaImg3.ocx' or one of its dependancies not correctly registered: A file is missing or invalid."
    The pictures assigned to a control during design time are stored in the hosting form's .frx file & compiled within your app when app is compiled. That isn't the reason for your error. You can't just copy the ocx to another pc and expect it to work, the ocx needs to be registered on that other pc. Suggest creating a proper install setup.exe for your application
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  28. #188
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Okay, I'll need to learn how to do that. Sorry to bother you.

  29. #189
    New Member
    Join Date
    Jul 2011
    Posts
    3

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Thanks Lavolpe, I liked the clock project.
    would be without you see the gray background of the form, thanks again for your help.

  30. #190

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Quote Originally Posted by astronald View Post
    Thanks Lavolpe, I liked the clock project.
    would be without you see the gray background of the form, thanks again for your help.
    If you are asking how to make something like a clock widget that would show up on the desktop and without a form's background showing thru, that is a project all in itself. I'll give you these hints. But for assistance you should post your questions in the graphics or VB6 portion of the forums, not here in the codebank or in this thread. This is all the help I'll provide since your question isn't related to how my project works.

    1. Use SetLayeredWindowAttributes & UpdateLayeredWindow APIs to draw your clock on a transparent form. The form should be made an owned window to the desktop if clock is to appear on the desktop

    2. This usercontrol cannot be used as is because of how UpdateLayeredWindow works. But you can still draw the clock parts to the form every second (if second hand is displayed) or every minute if no second hand used. The usercontrol's PaintImageAsDrawnToHDC function would be helpful here or accessing the Picture property's .Render function directly.

    Search the forums for examples of the 2 APIs I mentioned. Good luck.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  31. #191
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Hi. I use the control, but found some problem.
    please see the attachment.

    I read the contact.jpg use GDIpImage.
    But I get the different color value in point (x,y) = (0,64) form photoshop or paint.

    use GDIpImage, I get
    'Red:255;Green:255;Blue:251;Alpha:255
    when use photoshop or paint or other soft ,I get
    'Red:255;Green:255;Blue:255;Alpha:255

    Plese help me see what's wrong?

    Thanks!

  32. #192

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Quote Originally Posted by mjohnlq View Post
    Hi. I use the control, but found some problem.
    please see the attachment.
    Forgot the attachment. If you include the jpg, also tell me whether the control is showing the image actual size or not. Also show the code you are using the extract the color
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  33. #193
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [13 July 2011]

    Hi, LaVolpe,
    I found the problem.
    It's my mistake, (x, y) should be (y, x).
    now, the value is the same with other software.
    Thanks!
    Attached Files Attached Files

  34. #194

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [14 August 2011]

    Updated control. See 1st post
    - Can now create animated PNG
    - Prevented control from trying to process 64bit binaries for images
    - GDIpImage.AnimationLoops property returns animated PNG loop count
    - New control method Animate2 is class-based version of older Animate method
    - Added ability to do a screen capture to 24bpp bitmap

    Edited: To test animated PNGs without using my control, use FireFox to open the animated PNG file
    Last edited by LaVolpe; Aug 14th, 2011 at 09:57 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  35. #195
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [14 August 2011]

    Hi.
    When AlphaImgCtl1.WantPrePostEvents = True, then AlphaImgCtl can't resize correct.

    //////////////////////////////////////////////////////////////
    Option Explicit

    Private Sub Form_Load()
    AlphaImgCtl1.WantPrePostEvents = True
    End Sub

    Private Sub Form_Resize()
    AlphaImgCtl1.Move Me.ScaleLeft, Me.ScaleTop, Me.ScaleWidth, Me.ScaleHeight
    End Sub
    ///////////////////////////////////////////////////////////////

    Above code can't run correct, if AlphaImgCtl1.WantPrePostEvents = false then it is correct.


    Please see the attachment!

    Thanks!
    Attached Files Attached Files

  36. #196

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [14 August 2011]

    Quote Originally Posted by mjohnlq View Post
    Hi.
    When AlphaImgCtl1.WantPrePostEvents = True, then AlphaImgCtl can't resize correct.
    Thanx for the bug report. An undiscovered bug that's persisted through last several versions.

    I think I know what is happening and will look into it. In the mean time, setting WantPrePostEvents in the property sheet instead of form_load will have expected results

    Update: Figured out the problem... logic error. I never coded for scenario where WantPrePostEvents without an image assigned to the control - not enough foresight there. Requires tweaks in 2 routines & will upload patch by Aug 17th after a bit more testing
    Last edited by LaVolpe; Aug 15th, 2011 at 11:16 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  37. #197
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [14 August 2011]

    Hi
    SaveControlAsDrawnToGDIpImage

    e.g
    ///////////////////////////////
    Set AlphaImgCtl2.Picture = AlphaImgCtl1.SaveControlAsDrawnToGDIpImage(True)
    //////////////////////////////

    Above Code is invalid.

    And SaveImageAsDrawnToGDIpImage may have the same problem.

    Thanks!

  38. #198

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [14 August 2011]

    Quote Originally Posted by mjohnlq View Post
    Set AlphaImgCtl2.Picture = AlphaImgCtl1.SaveControlAsDrawnToGDIpImage(True)

    Above Code is invalid.
    Can you be more specific? What's invalid about it? If the following resolves the issue, please let me know also

    If AlphaImgCtl2 isn't showing the complete image, try this:
    Code:
    AlphaImgCtl2.AutoSize = lvicSingleAngle
    Set AlphaImgCtl2.Picture = AlphaImgCtl1.SaveControlAsDrawnToGDIpImage(True)
    Also note that AlphaImgCtl1 must be visible

    Edited: If there is no image assigned to the usercontrol, there is a check for that to abort the routine. I can see where this may not be desirable. I'll include that modification also. Simply remove the following line from the usercontrol's SaveControlAsDrawnToGDIpImage function:
    If m_Image.Handle = 0& Then Exit Function

    The same scenario for SaveImageAsDrawnToGDIpImage does not apply. That function relates to the loaded image only, not any background graphics. Therefore if no image loaded, SaveImageAsDrawnToGDIpImage will abort
    Last edited by LaVolpe; Aug 16th, 2011 at 11:03 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  39. #199
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [14 August 2011]

    Hi.
    Please see the attachment, the copy button has no effect.

    Thanks!
    Attached Files Attached Files

  40. #200

    Thread Starter
    VBaholic & Loving It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    GetWindowRect()
    Posts
    12,143

    Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [14 August 2011]

    Quote Originally Posted by mjohnlq View Post
    Please see the attachment, the copy button has no effect.
    Now I understand. Thanx for the example. Need to think this over a bit.

    AlphaImgCtl1 is user-drawn in that example. The PrePaint event draws the image itself then tells the control to not draw its copy. So, that does explain why no graphics were returned to AlphaImgCtl2 since AlphaImgCtl1 was told not to draw the image

    I'll be considering this. The following scenarios are possible along with what I consider commonsense responses

    I. If WantPrePostEvents is True then graphics may or may not be user-drawn

    a. If the control is told to abort painting by passing the PrePaint event's Cancel parameter as True
    -- SaveControlAsDrawnToGDIpImage has no choice but to return the graphics as drawn by the user since the control will not be drawing the image. This will include any background fill/graphics since the user dictates everything

    b. If the control is NOT told to abort painting then
    -- SaveControlAsDrawnToGDIpImage should function as intended

    II. If WantPrePostEvents is False then no user-drawn graphics to worry about
    -- SaveControlAsDrawnToGDIpImage should function as intended

    III. The SaveImageAsDrawnToGDIpImage function is not affected. It uses the control's image and any image properties (i.e., rotation, grayscaling, etc)
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VBA Control Arrays} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Page 5 of 12 FirstFirst ... 2345678 ... LastLast

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.