Page 6 of 18 FirstFirst ... 345678916 ... LastLast
Results 201 to 240 of 710

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

  1. #201
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

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

    Hi.

    GDIpImage.Render may have problem.

    I want use GDIpImage.Render to draw a jpg's right-bottom corner in a picturebox, but I found there has some Offset.
    I didn't know why.

    Please see the attachment.

    Thanks!
    Attached Files Attached Files

  2. #202

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Quote Originally Posted by mjohnlq View Post
    ...but I found there has some Offset.
    I didn't know why.
    Double check the parameter values you are passing. You are trying to render a 400 pixel wide image 30x larger than actual size.
    Code:
    passing DestWidth & DestHeight as: k.Height * 30, k.Width * 30
    If you want to render the bottom right corner, I would suggest setting the SrcX, SrcY, SrcWidth & SrcHeight parameters vs rendering the entire image to some large negative offset.

    Bottom line. I don't see anything incorrect with the .Render function at this time. Appears the parameter values are the error.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #203
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

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

    Hi.

    Thanks for your suggestion.

    I want use GDIpImage to enlarge and shrink a picture as photoshop do.

    But the problem is still exist.

    The method2 is what I did as your suggestion.

    Please see the attachment.
    Attached Files Attached Files

  4. #204

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Quote Originally Posted by mjohnlq View Post
    ... but I found there has some Offset.
    I didn't know why.
    Ignore previous replies, I now see what you are talking about.
    I had to change the picturebox's backcolor to dark so the offset was obvious.

    I'm looking into it and it isn't an issue with the control; but may be some GDI+ anomaly. Hopefully will know more later.

    Follow-up. Increasing the zoom factor also increases the unwanted offset. Obviously a factor of 1 has no offset, where a factor of 50 has quite a big offset. This is definitely GDI+ related, not control related. Still looking...

    Update. Figured out I think. The offset you see appears to be directly proportional to the zoom factor. If you are zooming 30x then you'll see an offset of 15 pixels. Haven't played with zoom values < 1 (i.e., .5). This 'bug' also seems to apply only if the X and/or Y coords are less than zero; no offsets seen with X,Y => 0

    The following adjusts the X,Y coords by half the zoom & appears to render well. However, flaky in my opinion & not 100&#37; sure it works in all cases. I'll do a bit more research and see if I can find some sort of GDI+ setting that will prevent these offsets.
    Code:
        Const zoom As Single = 30
        Dim X As Long, Y As Long
        Dim m_Effects As New GDIpEffects
        Dim k As GDIpImage
        Set k = LoadPictureGDIplus(App.Path & "\contact.jpg")
        Picture1.Cls
        X = Picture1.ScaleWidth - k.Width * zoom
        Y = Picture1.ScaleHeight - k.Height * zoom
        If X < 0& And zoom > 1 Then X = X + zoom / 2
        If Y < 0& And zoom > 1 Then Y = Y + zoom / 2
        k.Render Picture1.hDC, X, Y, k.Width * zoom, k.Height * zoom, , , , , , m_Effects.AttributesHandle, , 0, RenderInterpolation.lvicNearestNeighbor
    Final Update: Ok, I've found what I believe is the answer. There is another GDI+ setting that can be used & appears to solve the problem. No need to adjust X,Y coords based on zoom factor.
    1. Add this API declaration to your GDIpImage class, at very top of class after the Option Explicit line
    Code:
    Private Declare Function GdipSetPixelOffsetMode Lib "gdiplus" (ByVal graphics As Long, ByVal PixOffsetMode As Long) As Long
    2. In the GDIpImage.Render method, add call to that API as described below. Note you'll find two places in that routine with identical lines of code. Add the new call to both sections of the code.
    Code:
    ...
            Else
                Call GdipSetInterpolationMode(hGraphics, Interpolation + 2&)
            End If
    ' insert new call here:
            Call GdipSetPixelOffsetMode(hGraphics, SmoothingModeAntiAlias)
    This will be added to the latest modifications when I post them this weekend. Need to test a few things first.
    Last edited by LaVolpe; Aug 18th, 2011 at 02:10 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #205
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

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

    Hi
    Thank your very very much.

    I has another question.

    I found photoshop's cursor can be very large if set the pen's width....

    I want change the cursor's size too. But widows's cursor size is fixed to 32 x 32, it' is very bad. I don't know how photoshop can change cursor's size.

    I found some other post of you that can use CreateIconFromResourceEx to create a cursor, but it can't change cursor's size too.

    Now, I found GDIpImage can save a .ico to .cur, I want set my cursor use the ico, the ico's size is 16 x 16, and i want change it to a 32 x32 cursor.

    below is what i do, but has problem.

    Please see the attachment.

    //////////////////////////////////////////////

    Private Sub SetCursor_Click()
    Dim k As New GDIpImage
    Set k = LoadPictureGDIplus(VB.LoadPicture(App.Path & "\1.ico")) ' (VB.LoadResPicture(101, vbResIcon)).

    Dim m As New StdPicture

    'I want change the ico's size from 16 x 16 and then set the cursor's hot spot , how can I do?

    ' k.Width = 32 'I Can't change it
    ' k.Height = 32 'I Can't change it

    SavePictureGDIplus k, m, lvicSaveAs_HCURSOR
    Me.MousePointer = MousePointerConstants.vbCustom
    Set Me.MouseIcon = m
    End Sub

    //////////////////////////////////////////////////////

    could you help see what's is wrong with me?
    Attached Files Attached Files

  6. #206

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    To set a cursor's hotspot, pass a SAVESTRUCT in the last optional parameter of SavePictureGDIplus

    Using sample code from your test5 zip
    Code:
        Dim SS As SAVESTRUCT
        SS.CursorHotSpotX = newHorizontalHotSpotValue
        SS.CursorHotSpotY = newVerticalHotSpotValue
        SS.Width = 32: SS.Height = 32
        SavePictureGDIplus k, m, lvicSaveAs_HCURSOR, SS
    Edited: Note that because this is being resized, will most likely cause alphablending during resizing. stdPicture object's cannot accept alphablended images and any resized cursor pixels not fully opaque or fully transparent will be turned to fully transparent. This will have the effect of losing some detail in the cursor. To overcome this problem, recommend also setting the SS.AlphaTolerancePct value to 25 which produces good quality complex-to-simple transparency reduction. stdPicture icons/cursors only support simple transparency. The SavePictureGDIp.rtf document included with the project attempts to explain that. The SS.AlphaTolerancePct member was designed for such cases: stdPicture icons/cursors, GIFs, & metafiles

    Another option instead of using the SS.AlphaTolerancePct member is to use the SS.RSS.Quality member and set it to lvicNearestNeighbor. But I think the quality of stretching will be less professional than using the SS.AlphaTolerancePct member
    Last edited by LaVolpe; Aug 18th, 2011 at 12:27 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #207
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

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

    Hi, LaVolpe

    Thanks very much.
    But I still have questions:

    1. If I needn't stretch the icon,
    can GDIpImage let me not stretch the 16 * 16 icon , only add the icon size to 32 * 32? because i need show a small cursor as photoshop do.
    if stretch the icon, the cursor is twice the size, this is not what i want.

    2. If I need stretch the icon,
    set SS.Width = 128: SS.Height = 128, the width has no effect.
    the width and the height is always 32.
    So how Can I show a very big cursor like photoshop?

    3. If the Icon is stretch,
    SS.CursorHotSpotX = 0
    SS.CursorHotSpotY = 0
    is not right, it has some offset.
    in test5, when the mouse move to the title, the cursor still didn't restore.

    Thanks!

  8. #208

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    mjohnlq, regarding the offsets when zooming... I found a final solution I believe. See post #204 where I included the patch.

    Note: That issue had nothing to do with negative X,Y offsets. What was really the issue, as proven by some of my testing, was using nearest-neighbor interpolation along with stretching/zooming. What GDI+ was doing was pre-sizing the output image size based on bicubic/bilinear interpolation. That means the overall image is expanded by the 1/2 the zoom factor in all directions which is typical for that interpolation model. But when GDI+ rendered the image, it clipped the 'blurred' portion which made it look as though image was rendered offset by a few pixels. It was actually clipped. By providing the new GDI+ setting, the issue no longer exists. Just FYI

    And regarding the cursor not staying custom when you move to the titlebar.... The custom cursor only applies to the client area of your form, not the titlebar, menubar, or borders. If you want cursor to apply to entire form, use Screen.MouseIcon instead of Me.MouseIcon
    Last edited by LaVolpe; Aug 18th, 2011 at 02:45 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #209

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    mjohnlq, regarding cursors sizes....

    VB is to blame here.

    The icon you provided in your zip contains just one 16x16 icon. However, when you load an icon/cursor into a MouseIcon property, it seems to always come out visually as 32x32 regardless of what its original size is.

    But that is just an illusion. VB is doing something behind the scenes. The stdPicture object (Me.MouseIcon) is really 16x16 !!!! Don't believe it, then try this:

    Debug.Print ScaleX(Me.MouseIcon.Width, vbHimetric, vbPixels)

    Also note that VB and cursors/icons behave slightly different when app is compiled. You may want to test a 16x16 & 32x32 MouseIcon image from a compiled test app.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #210
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

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

    Thanks Very much!

  11. #211

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Updated version posted today.

    Updates are to address issues discovered by mjohnlq. Refer to posts 195-204 for more details.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  12. #212
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

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

    hi.

    Other software can read cursors in attachment, but GDIpImage can't.
    You can use prjTheBasics to test it.

    Thanks!
    Attached Files Attached Files

  13. #213

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Quote Originally Posted by mjohnlq View Post
    Other software can read cursors in attachment, but GDIpImage can't.
    Actually it can read them, but are aborting because they are not formatted correctly.

    Those cursors have the height set at zero within the icon directory entry. Not sure if you are well versed on icon file structure. Anyway, zero equates to 256 for icons/cursors & those cursors are 32x32 except one which is 16x16. I have included patches for mal-formatted image data in other image formats; so I'll include a patch for these types of icons/cursors too

    I'll tweak the project to handle these situations when possible. Since all icons/cursors are really bitmaps with masks, that bitmap information also has dimensions. I can bounce the bitmap dimensions up against the icon structure dimensions and internally modify the icon structure as needed. Bottom line, with a properly written icon, the icon structure should be correct, but the bitmap data should always override the icon structure info.

    Thanx for the sample icons. I don't expect this tweak to be implemented before the weekend & hope that's not an issue for you.
    Last edited by LaVolpe; Aug 21st, 2011 at 11:00 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  14. #214
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

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

    Yes, the format of the cursor files is invalid !
    I think it is needn't modify the codes for these invalid format cursor file.

    Thanks verh much!

  15. #215

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Quote Originally Posted by mjohnlq View Post
    Yes, the format of the cursor files is invalid !
    I think it is needn't modify the codes for these invalid format cursor file.
    I'll modify the code because Windows has no issues displaying them and I'd like to at least be able to do what Windows does. The modification is relatively simple
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  16. #216
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

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

    Hi.

    I have another two cursor file, their format is valid.
    But AlphaImgCtl maybe show incorrect.

    in attachment.
    1. "See in other soft.png" is when the two cursors show in other software.
    2. test6 is test show the cursor files use AlphaImgCtl .

    you can see, AlphaImgCtl can't show complete.

    Thanks very much!
    Attached Files Attached Files

  17. #217

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Quote Originally Posted by mjohnlq View Post
    Hi.

    I have another two cursor file, their format is valid.
    But AlphaImgCtl maybe show incorrect.
    Ok, that's a logic bug. I'll look into it -- gotta be something wrong with my mask processing section

    Though... When looking at the icon/image in Windows Explorer or on my desktop, it is displayed like the AlphaImgCtl. If I were to load the cursor into a VB Image control, it is displayed like in your png snapshot. Interesting

    Update: I will need to handle black&white cursors/icons a bit differently. I can now render the exact same image as shown in your png snapshot & VB's image control. However, in reality, 1 bit cursors/icons that use an XOR mask (as does your cursor), what you get depends on what the cursor is currently rendered over. See attached. For my control, the assumption for drawing is that cursor will be over a white background.
    Name:  BWcursor.PNG
Views: 1685
Size:  3.3 KB
    In above image, the top 4 boxes is the same cursor, in VB's Image Control, drawn over colored squares. The bottom image is modified code to handle B&W cursors/icon processing differently, more correct. Modified code not yet posted.

    Final update. Had to handle the AND & XOR masks manually to guarantee I could draw the icons exactly correct. I'll include the patch in the next update, expected end of August.
    Last edited by LaVolpe; Aug 23rd, 2011 at 06:31 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  18. #218
    New Member
    Join Date
    Nov 2010
    Posts
    2

    Lightbulb Green Screen / ChromaKey

    Hello Keith,

    I have a feature request:

    Would it be possible to add an option for Green Screen removal? Where a photo is taken against a green or blue screen and you can convert the background to transparent?

    Lots of controls have the ability to replace a color or make it transparent, but to do true ChromaKey you would need to be able to supply a color and then be able to convert that color in addition to a range of lighter and darker colors to transparent.

    Sound like something that is possible?

    Also, any thoughts on watermark options? The ability to set a font, color, style, position, transparency and rotation would be really nice addition as well.

    Regards,

  19. #219

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Regarding green screen ability -- already there but will make the color 100&#37; transparent throughout. The two properties you'll need to set are: TransaprentColor and TransparentColorMode
    For example using vbGreen
    AlphaImgCtl1.TransparentColor = vbGreen
    AlphaImgCtl1.TransparentColorMode = lvicUseTransparentColor

    Not sure if the above is what you truly meant.

    Regarding watermarks. They can be done a few ways & I don't intend to build a specific function for that. In fact, the control is already setup for such things

    1. To use an image as a watermark, some sample code exists in the AICGlobals.MergePictureGDIplus function

    2. A text watermark isn't specifically addressed but not that difficult either if one is comfortable with GDI+. Creating text with a rotated font and whatever attributes you want with GDI+ is simple. The string can be rendered in the control's PostPaint event. Or, if the control is hosting a 24/32bpp image, you can grab an hGraphics object from it's handle (AlphaImgCtl1.Picture.Handle) via the GdipGetImageGraphicsContext API and draw the GDI+ string directly to the image itself. There are other options that come to mind also.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  20. #220
    New Member
    Join Date
    Nov 2010
    Posts
    2

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

    Well not exactly what I was talking about.

    In photography, you can shoot a subject or a product in front of a green-screen then use software to remove the background and make it transparent.

    Typically the green-screen is a bright neon green and unlikely the subject will have this color of green.

    However, due to shadows and lighting, the green may be a little lighter or a little darker in certain spots. Thus the software allows you to select the base color of green then has a choke value, typically between 0 and 255 that allows you to remove the base green plus shades of the green both lighter and darker.

    I have attached an example photo with the green screen and one that has been removed using software to remove the green screen.

    The original is of a model taken in front of a green screen in .jpg format, with the green background removed with a choke value of 55 and saved in .png format with all green removed.

    As you can see there are some color variations in the green background, this is due to lighting and shadows in the studio.

    I also resized the .png file so it would fit the file limits of this forum.
    Attached Images Attached Images   

  21. #221

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    VB_Rocks. though the control isn't directly set up to do what you are suggesting, it can be done outside of the control. Using your JPG source as an example, try this...

    1. New form, add AlphaImgCtl and assign your JPG to that control
    2. Add a command button to the form & this code
    Code:
    Private Declare Function GdipCreateImageAttributes Lib "gdiplus.dll" (ByRef imgAttr As Long) As Long
    Private Declare Function GdipSetImageAttributesColorKeys Lib "gdiplus.dll" (ByVal mImageattr As Long, ByVal mType As Long, ByVal mEnableFlag As Long, ByVal mColorLow As Long, ByVal mColorHigh As Long) As Long
    Private Declare Function GdipDisposeImageAttributes Lib "gdiplus.dll" (ByVal imgAttr As Long) As Long
    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
    
    Private Sub Command1_Click()
        
        Dim hAttributes As Long, hGraphics As Long, tImg As New GDIpImage
        Dim lBaseColor As Long, lLow As Long, lHigh As Long, lChannel As Long
        Dim SS As SAVESTRUCT
        
        AlphaImgCtl1.BackColor = vbWhite
        AlphaImgCtl1.BackStyleOpaque = True
    
        ' set up structure for a blank 32bpp image same size as original
        SS.ColorDepth = lvicConvert_TrueColor32bpp_ARGB
        SS.Width = AlphaImgCtl1.Picture.Width
        SS.Height = AlphaImgCtl1.Picture.Height
        If SavePictureGDIplus(Nothing, tImg, , SS) = False Then Exit Sub ' create blank image
        ' now get a handle to its DC (hGraphics)
        If GdipGetImageGraphicsContext(tImg, hGraphics) = 0& Then
        
            ' assign base color; we'll use top left corner for simple example & ensure in GDI+ color format
            lBaseColor = ConvertRGBtoARGB(GetPixelGDIplus(AlphaImgCtl1.Picture, 0, 0))
            
            ' create an attributes handle
            If GdipCreateImageAttributes(hAttributes) = 0& Then
                ' adjust the range to 1/8th above & below base color. 1/8th is +/- 32
                ' assign darker color to lLow & lighter color to lHigh
                lLow = &HFF000000: lHigh = lLow
                
                lChannel = (lBaseColor And &HFF&)
                If lChannel > 31 Then lLow = lLow Or (lChannel - 32)
                If lChannel < 224 Then lHigh = lHigh Or (lChannel + 32) Else lHigh = lHigh Or &HFF&
                
                lChannel = (lBaseColor And &HFF00&) \ &H100&
                If lChannel > 31 Then lLow = lLow Or (lChannel - 32) * &H100&
                If lChannel < 224 Then lHigh = lHigh Or (lChannel + 32) * &H100& Else lHigh = lHigh Or &HFF00&
                
                lChannel = (lBaseColor And &HFF0000) \ &H10000
                If lChannel > 31 Then lLow = lLow Or (lChannel - 32) * &H10000
                If lChannel < 224 Then lHigh = lHigh Or (lChannel + 32) * &H10000 Else lHigh = lHigh Or &HFF0000
                
                ' create the attributes
                If GdipSetImageAttributesColorKeys(hAttributes, 1&, 1&, lLow, lHigh) = 0& Then
                
                    ' draw source image to new image while applying attributes
                    AlphaImgCtl1.Picture.Render 0&, , , , , , , , , , hAttributes, hGraphics
                    Set AlphaImgCtl1.Picture = tImg
                End If
                
                GdipDisposeImageAttributes hAttributes ' clean up
            End If
                    
            GdipDeleteGraphics hGraphics ' clean up
            
        End If
        
    End Sub
    Note that the removal of green isn't 100&#37; perfect but I suspect that is more of an issue of using a JPG as a source. JPGs lossy color compression wouldn't be ideal whereas a PNG source would be ideal IMO.
    Last edited by LaVolpe; Aug 22nd, 2011 at 01:08 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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

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

    Quote Originally Posted by LaVolpe View Post
    VB_Rocks. though the control isn't directly set up to do what you are suggesting, it can be done outside of the control. Using your JPG source as an example, try this...

    Note that the removal of green isn't 100% perfect but I suspect that is more of an issue of using a JPG as a source. JPGs lossy color compression wouldn't be ideal whereas a PNG source would be ideal IMO.
    Look like the Green part has range e.g.RGB(118,165,110),G(Green) is always bigger than R & B. Can we do pixel by pixel replacement with White (255,255,255) if G is bigger than R and B?

  23. #223

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Quote Originally Posted by Jonney View Post
    Look like the Green part has range e.g.RGB(118,165,110),G(Green) is always bigger than R & B. Can we do pixel by pixel replacement with White (255,255,255) if G is bigger than R and B?
    I don't think pixel by pixel tweaking is preferred due to lack of speed.
    My intention was simply to show a way this can be done even though the control doesn't support it directly. I doubt a JPG would really be used as a source. Saving a JPG over an over again at less than 100&#37; quality will degrade the image to a point where no threshhold will be satisfactory. My opinion of course - JPGs bad choice where original color data is important.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  24. #224
    New Member
    Join Date
    Aug 2011
    Posts
    1

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

    The Alpha Imagen Control is perfect, but i think that have a litte problem, when we assign the control to download an image from the Internet, if the image is too large or the internet connection is very slow, freezes the program control until the image downloads completely.

    I think this is a problem, as for example in a project where it is assigned to control download multiple images from the Internet in a form, this would not be shown until control download all ...

    Regards...

  25. #225

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    DarkOnMatrix. Good point. I'll experiment a bit and update this posting when I know more.
    There are callback options available when using APIs to grab internet data. The VB6 usercontrol can do this for us easily but is not unicode compliant & too bad; would've been very easy to provide async data.

    Update #1. Very doable to allow async vs sync downloads. The issue is assignment of a GDIpImage object if async is used. The LoadPictureGDIplus function returns a GDIpImage class object containing the picture. But if async is used, the function will return immediately without any image assigned. So, how are you going to know that the image finished downloading? How are you going to be able to abort the download if you wanted to? I'm looking at those scenarios now. An immediate option is to create a new AsyncDownload class that has events. You would pass this class as the SourceImageData parameter of LoadPictureGDIplus. That class would have events that told you whether or not the image downloaded, progress, option to abort, and a few other properties. When finished downloading, then you'd be able to assign a GDIpImage class to the picture. Still thinking this over.... Nah, I think I have a clever way to get around those problems, maybe.

    Update #2. Pretty dang close to a solution.

    Update #3. Aug 29. Successfully created a multi-threaded asynchronous solution that works in a test executable. Need to test it a bit more & if still successful, will incorporate it into the control.

    Side note & logic bugs.
    1. InternetCheckConnection used to test net connection & will always fail if going thru proxy. Not reliable
    2. INTERNET_OPEN_TYPE_DIRECT flag used in InternetOpen call & will cause failure if going thru proxy. Don't use that flag
    3. Only 3 protocols supported: http, ftp, gopher (though I think gopher no longer supported in Vista or Win8). Will add code to support file:\\
    Last edited by LaVolpe; Aug 29th, 2011 at 10:33 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  26. #226
    Junior Member
    Join Date
    Aug 2011
    Posts
    28

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

    Quote Originally Posted by LaVolpe View Post
    Ok, that's a logic bug. I'll look into it -- gotta be something wrong with my mask processing section

    Though... When looking at the icon/image in Windows Explorer or on my desktop, it is displayed like the AlphaImgCtl. If I were to load the cursor into a VB Image control, it is displayed like in your png snapshot. Interesting

    Update: I will need to handle black&white cursors/icons a bit differently. I can now render the exact same image as shown in your png snapshot & VB's image control. However, in reality, 1 bit cursors/icons that use an XOR mask (as does your cursor), what you get depends on what the cursor is currently rendered over. See attached. For my control, the assumption for drawing is that cursor will be over a white background.
    Name:  BWcursor.PNG
Views: 1685
Size:  3.3 KB
    In above image, the top 4 boxes is the same cursor, in VB's Image Control, drawn over colored squares. The bottom image is modified code to handle B&W cursors/icon processing differently, more correct. Modified code not yet posted.

    Final update. Had to handle the AND & XOR masks manually to guarantee I could draw the icons exactly correct. I'll include the patch in the next update, expected end of August.

    Hi. LaVolpe.

    The cursor's effect Looks very good!

    Thanks very mush!

  27. #227

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Control updated today & binary compatibility still maintained.

    Fixed icon issues noted in posts 212-216 above
    Added async download capability per request. See post 224 above
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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

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

    Hi, I want to let you know about a bug I found while using the control. The control will clip its picture when you set the rotation to -89.1. I can reproduce this every time by putting a 20*400 bitmap into it and setting the correct rotation.

  29. #229

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Quote Originally Posted by cheesebrother View Post
    Hi, I want to let you know about a bug I found while using the control. The control will clip its picture when you set the rotation to -89.1. I can reproduce this every time by putting a 20*400 bitmap into it and setting the correct rotation.
    Bug reports always welcomed. Can you provide more details on the control's properties? Besides the Rotation property being -89.1, what is the Aspect and AutoSize properties set to? When I pasted a simple 20x400 image into the control, no clipping appeared. Here are the properties I used
    Rotation: -89.1
    AutoSize: lvicMultiAngle
    Aspect: lvicActualSize

    Edited: I think I see what you are talking about, by changing the AutoSize property to lvicSingleAngle
    Here is a temporary solution. Haven't tested it yet and need to ensure it doesn't affect other functions relying on this one:
    - modCommon.GetScaledCanvasSize
    - Replace these 2 lines
    Code:
        a = (Int(Angle) Mod 360!) + (Angle - Int(Angle))
        If a < 0# Then a = a + 360#
    - With these few lines
    Code:
        If Angle < 0! Then
            a = 360! + (Angle Mod 360)
        Else
            a = Angle Mod 360
        End If
    Also note that original code wouldl break if passing a value outside of +/- 720 degree angles. I'll have to reduce angles internally to max range of +/- 359.9999 to handle all scenarios. In doing so, internally all negative values will also be converted to positive values with addition of 360 degrees. Like I said, the above 'patch' is temporary but may fix both issues.

    Also the modCommon.GetScaledImageSizes function will need a similar patch
    Last edited by LaVolpe; Sep 6th, 2011 at 03:32 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  30. #230
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

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

    Yes, I got the problem when the control's AutoSize property was set to IvicSingleAngle and the Aspect was set to IvicActualSize. Thanks for the little fix, I tried it and it works well.

  31. #231

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Quote Originally Posted by cheesebrother View Post
    Yes, I got the problem when the control's AutoSize property was set to IvicSingleAngle and the Aspect was set to IvicActualSize. Thanks for the little fix, I tried it and it works well.
    Cool. I'll include the patch later this week. Trick was to do calculations based off of angles rounded up/down as needed vs. actual angle when rotating in fraction of degrees

    BTW. While testing, I discovered another minor bug. If image is mirrored both vertically and horizontally, drawing it at angles other than 90 degree increments may fail (believe this to be a GDI+ bug). I do have a fix for that now also & will include it with the patch for the bug you discovered.
    Last edited by LaVolpe; Sep 7th, 2011 at 09:51 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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

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

    Quote Originally Posted by LaVolpe View Post
    Control updated today & binary compatibility still maintained.

    Fixed icon issues noted in posts 212-216 above
    Added async download capability per request. See post 224 above
    When async downloading, I can't do other things... But I don't worry much because of most of people won't use much of this function.

  33. #233

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Quote Originally Posted by Jonney View Post
    When async downloading, I can't do other things... But I don't worry much because of most of people won't use much of this function.
    When downloading asynchronously, you will be able to do other things.

    When wanting to download a URL asynchronously ensure you pass the last parameter of LoadPictureGDIplus as False. Otherwise, synchronous downloads will be performed (default behavior).

    If you are passing that last parameter as False, then maybe async downloads are not supported. Test the global AsyncDownloadsEnabled property and see if it returns true or false. The control will fall back to sync downloads if that property returns false

    Edited: Simple example. You'll see the caption changing while download is occurring. If async download is not enabled, msgbox displays & project unloads

    1. Add AlphaImgCtl to form & a timer
    2. Copy & paste this code. The image downloaded is one from post #220 above.
    Code:
    Option Explicit
    
    Private Sub AlphaImgCtl1_AsyncDownloadDone(Success As Boolean, ErrorCode As Long)
        Timer1.Enabled = False
        If Success Then
            Me.Caption = "Done. Success"
        Else
            Me.Caption = "Error: " & ErrorCode
        End If
    End Sub
    
    Private Sub Form_Load()
        Me.Show
        DoEvents
        If AsyncDownloadsEnabled = False Then
            MsgBox "Async downloads not enabled", vbInformation
            Unload Me
            Exit Sub
        End If
    
        Dim sURL As String: sURL = "http://www.vbforums.com/attachment.php?attachmentid=85501&stc=1&d=1313972675"
    
        Timer1.Interval = 100
        Timer1.Enabled = True
        AlphaImgCtl1.AutoSize = lvicSingleAngle
        Set AlphaImgCtl1.Picture = LoadPictureGDIplus(sURL, , False)
    
    End Sub
    
    Private Sub Timer1_Timer()
        Me.Caption = Timer
    End Sub
    Note: When a modal window is displayed (i.e., a message box), and your project is not compiled, it affects raised events from the control. So, no AlphaImgCtl1_AsyncDownloadDone event is triggered. When ocx is compiled, image will still be displayed while modal window is active, but event not received. When ocx is not compiled, image data is not even processed...

    If within your code & you have doubt whether the image was loaded or not during the display of a modal window, you can query the GDIpImage class' AsyncDownloadStatus property after that modal window is closed. Example:
    Code:
        If AlphaImgCtl1.Picture.AsyncDownloadStatus = lvicAsync_Ok Then
            ' image assigned
        ElseIf AlphaImgCtl1.Picture.AsyncDownloadStatus = lvicAsync_Invalid Then
            ' failure - reason would have been passed to the AsyncDownloadDone event
        else 
            ' any other value indicates download is not complete. lvicAsync_WaitingOnReply may indicate destination not responding
        End If
    The above will only work when the control is compiled. And here is why it doesn't work when control is not compiled
    Step 1: cAsyncClient initiates downloads and is owned by a GDIpImage class
    Step 2: When download done, raises event to owner GDIpImage class & passes collected image data
    Step 3: GDIpImage class processes image data as needed
    Step 4: If GDIpImage class is owned by AlphaImgCtl, then it raises its AsyncDownloadDone event to that control
    Step 5: AlphaImgCtl raises its AsyncDownloadDone event to its host (your form) when it gets the GDIpImage event

    When modal window is displayed while events are being raised...
    a. When control is uncompiled, step 2 is broke due to VB blocking events and Steps 3-5 never get executed
    b. When control is compiled but project is not, Step 5 is broke due to VB blocking events
    c. When project is compiled, no steps are broke, no workarounds needed

    I can see where this could be an issue when designing one's app & insisting on using the uncompiled control. So, I'll include a patch that will know to re-execute Step 2. That patch will be executed with a query to the AsyncDownloadStatus property, similar method as sample code above shows.
    Last edited by LaVolpe; Sep 7th, 2011 at 06:00 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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

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

    Quote Originally Posted by LaVolpe View Post
    When downloading asynchronously, you will be able to do other things.

    When wanting to download a URL asynchronously ensure you pass the last parameter of LoadPictureGDIplus as False. Otherwise, synchronous downloads will be performed (default behavior).

    If you are passing that last parameter as False, then maybe async downloads are not supported. Test the global AsyncDownloadsEnabled property and see if it returns true or false. The control will fall back to sync downloads if that property returns false
    Thanks. I missed the last parameter of LoadPictureGDIplus.
    How about Moving Public Property AsyncDownloadsEnabled to AlphaImgCtl? It looks weird because of this is only Public Property in AICGlobles.

  35. #235

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Quote Originally Posted by Jonney View Post
    How about Moving Public Property AsyncDownloadsEnabled to AlphaImgCtl? It looks weird because of this is only Public Property in AICGlobles.
    The async downloads can be done with a GDIpImage class also, not just the Alpha Image Control, i.e., ....
    Code:
    Private WithEvents myImage As GDIpImage
    
    Private Sub Command1_Click()
        Dim sURL As String: sURL = "http://www.vbforums.com/attachment.php?attachmentid=85501&stc=1&d=1313972675"
        Set myImage = LoadPictureGDIplus(sURL, , False)
    End Sub
    
    Private Sub myImage_AsyncDownloadDone(Success As Boolean, ErrorCode As Long)
        If Success Then
            Me.Caption = "Done. Success"
        Else
            Me.Caption = "Error: " & ErrorCode
        End If
    End Sub
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  36. #236

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Control updated today.

    - Fixes a rotation calculation error. See posts 228-231 above for more info
    - Added IDE patch when using uncompiled control & async download events blocked by a modal window you have displayed from your project. See post 233 for more info
    - Added 2 new global asynchronous download support functions:
    :: AsyncGetDownloadStates returns count of all downloads in progress, waiting on reply, and/or queued
    :: AsyncAbortDownloads aborts all active and/or queued downloads
    - Added AsyncDownloadURL property to the GDIpImage class. This property available until the class' AsyncDownloadDone event is triggered and exits.

    The LoadPictureGDIp.rtf file has a section that discusses async downloads. Suggest reading that too
    Last edited by LaVolpe; Sep 9th, 2011 at 09:55 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  37. #237

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Found minor logic bug this morning.

    Where: modCommon module, CreateSourcelessHandle function
    Observation: Converting EMF/WMF to bitmap can result in a single black edge on the right and/or bottom side of the image when there shouldn't be one
    Cause: Rendering from single variable-type dimensions to long variable-type dimensions creates rounding error that could result in unwanted black edge(s).
    Solution: Use same variable type dimensions. Will upload patch by weekend
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  38. #238

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Control updated today.

    - Fixes rounding error noted in previous post #237
    - Added new grayscale property enumeration item: Black and White

    About the Black and White grayscale option. It uses luminance to determine pixel color. This method would render a pure black and blue image as all black due the low luminance of both black and blue. This new option uses GDI+ color matrix to generate the colors and no consideration is given to other colors in the image. It is a simple formula, controlled by GDI+, that looks like:
    Color = IIF( (redWeight * red + greenWeight * green + blueWeight * blue) >= 127.5, vbWhite, vbBlack)

    Note: The above algorithm/formula is common in many graphics programs, including MS Paint, affects any image consisting mostly of Blue, Green and/or Red. Various methods exist to negate this problem, including diffusion and methods similar to the one described below. Any single method for conversion to black and white probably won't be acceptable for every situation; also applies to converting/reducing image colors to 4, 16 or 256 colors

    However, if saving the same blue & black image via the SavePictureGDIplus function and passing the SaveStruct.ColorDepth as black and white, luminance is not the decision factor by itself. The function used processes each pixel and the pixel's luminance, in relation to all other pixels in the image, determines pixel color (in this case, blue would become white & black remains black).

    So, bottom line, you have two black and white options to choose from. One is immediate via the GrayScale property and is somewhat limited, and the other is available only when saving images using the SaveStruct.ColorDepth member. Both methods can return radically different results as one is based on fixed RGB ratio to white; while the other fixed RGB ratio between darkest & lightest colors in image. Both are completely different algorithms

    Additionally, you always have the option of providing your own custom functions by accessing the pixels from the image's GDI+ handle

    Within the modCommon module, you'll find the function: CreateGDIpAttributeHandle
    In that function is a constant named BWLuminanceRatio which can be modified to adjust the ratio/cutoff between what will be black and what will be white. Recommend setting somewhere between .4 & .5 (smaller value more white & larger value more black). The min/max values are between 0 & 1 inclusively. Can also achieve ratio modifications thru code by adding/removing lightness from the image: LightnessPct property

    Example of differences. When image is not mostly a prime color, results are similar; otherwise, can be quite different
    Name:  bwgray.PNG
Views: 1658
Size:  145.5 KB
    Last edited by LaVolpe; Sep 19th, 2011 at 06:54 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  39. #239

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Minor patch uploaded today.

    While playing with inverting black & white images that used the LightnessPct or BlendPct properties, wasn't getting the expected results. Found logic bug in the color matrix calculations when inverting colors. Fixed now, I believe
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  40. #240
    Addicted Member
    Join Date
    Jun 2009
    Location
    C:\Windows\SysWOW64\
    Posts
    227

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

    After your last update, the TransparencyPct property is not working at all. No matter what I type, it behaves as if it was 100.

Page 6 of 18 FirstFirst ... 345678916 ... 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
  •  



Click Here to Expand Forum to Full Width