Results 1 to 17 of 17

Thread: VB6 QUESTION: icon to bitmap

  1. #1

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,250

    VB6 QUESTION: icon to bitmap

    Just asking for some help to point in me in the correct direction.

    I want to extract icons from DLLS or EXEs, I think I can already do that using privateExtractIcons or ExtractIcons APIs.

    I believe I just need to use the handle from the above APIs to place the resulting image into a bitmap. The aim then being to load that bitmap into a collection using the scripting.Dictionary object so I can extract that image as I require.

    Background is that retaining any transparency is important and note I'm not writing it into a stdPicture object but instead writing it to the screen using GDI+. I have all that covered but the conversion from icon handle to bitmap I am deficient.

    As long as I can load the bitmap into the dictionary I should be good...

    I haven't written any code yet but I am not being lazy - I just want the benefit of your knowledge to prevent me going down the wrong path (I am doing some research but limited time available here).

    Can anyone give me a pointer as to a good method to convert a handle to an icon to a bitmap using GDI+ or similar retaining any alpha blending, I'd really appreciate the leg up.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: VB6 QUESTION: icon to bitmap

    Don't icons have the possibility of several actual images of different sizes in them? Which size do you want, the largest, all of them?
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,250

    Re: VB6 QUESTION: icon to bitmap

    I am using privateExtractIcons to successfully get the largest at the moment (256x256) but it could equally be any of the icon sizes contained within an binary.

    I am able to extract any of those at the moment using my code and can successfully write them to a stdPicturebox, I just feel quite unsure as to which API/method to use extract using the returned handle to convert to a bitmap so that I can feed it into a scripting.dictionary collection. Not done this before.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 QUESTION: icon to bitmap

    Use GetIconInfo() but there are numerous caveats.

    First, every loaded Icon eats two bitmaps: color and mask even for PNG-format Icons. Second, calling GetIconInfo() creates two more bitmaps, copies of the Icon's two resources.

    And we have already established that GDI handles are a limited resource. That's why you keep crashing.

    This is why ImageList controls exist: to get around having too many bitmaps.

    So if this is the same weird project... use a proper ListView control and an ImageList and stop trying to use various flexgrid controls to display images. And preferably in virtual ListView mode.

  5. #5
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,708

    Re: VB6 QUESTION: icon to bitmap

    How does using an ImageList get around GDI limits?

    The ImageList is just managing a list of bitmaps. ImageList_Add does the same CreateCompatibleDC->CreateDIBSection->etc.

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 QUESTION: icon to bitmap

    An Imagelist creates two bitmaps, one for color and one for mask. These bitmaps are very wide, horizontally tiling all of the images it stores.

    We also have the PictureClip control for doing this explicitly in VB6. You can also create an invisible UserControl of your own for the same thing.

  7. #7

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,250

    Re: VB6 QUESTION: icon to bitmap

    Dil, sorry, crashing? I'm not having any crashing. Flexgrids? You are confusing my post with another entirely.

    I think you may have lost track.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  8. #8

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,250

    Re: VB6 QUESTION: icon to bitmap

    My question is simply asked so that I can extract an icon and then convert it using that handle to a bitmap so that I can load it into a dictionary object.

    I have a method to extract the icon, I just was hoping for some advice on converting to a bitmap.

    It is unrelated to any other question currently on this forum.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 QUESTION: icon to bitmap

    Well then you have your answer, there are two bitmaps involved. Just watch out for leaking GDI objects.

  10. #10

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,250

    Re: VB6 QUESTION: icon to bitmap

    Well, hopefully that will help, I will have to do some digging but thankyou anyway. Glad you are back on track again.

    I am fairly certain my GDI+ usage also has leaking objects but not certainly not causing crashing in this case.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  11. #11
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    Re: VB6 QUESTION: icon to bitmap

    yereverluvinuncleber wrote in Posting #1

    I want to extract icons from DLLS or EXEs, I think I can already do that using privateExtractIcons or ExtractIcons APIs.
    "Windows\System32\Shell32.dll" is a resouces library file of Windows; if you happen to be using Win 10 Home Edition, to test what we are talking about are the same thing, would you please show what have you got of the Ref 2437 icon (counting from Ref 0001 of the "Individual Icons", as distinguished from the "Group Icons", in the Shell32.dll)? If you are using Professional Edition, then how is the last icon image you got?

  12. #12
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    Re: VB6 QUESTION: icon to bitmap

    Dilettante wrote in Posting #4

    First, every loaded Icon eats two bitmaps: color and mask even for PNG-format Icons
    Just to clarify, a PNG item doesn't have a mask. Starting from the file-stated .dwImageOffset, it is a PNG file in its entirety, including the PNG file signature, and the PNG image bytes are compressed. In another word, if you dump those bytes to a file with a file extension ".png", the saved file will be a valid PNG file.

    Edited:
    Remark: All masks of an ICO file are invariably of 1-BPP.
    Last edited by Brenker; Jul 5th, 2022 at 12:22 AM.

  13. #13
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 QUESTION: icon to bitmap

    As far as I can tell we weren't talking about PNG files but Icons.

    And yes, even if you have loaded an icon from an ICO with a PNG-format image (Vista icons) there is a mask bitmap as well as an unpremultiplied ARGB bitmap returned by GetIconInfo().

  14. #14
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    Re: VB6 QUESTION: icon to bitmap

    I am not talking of PNG files, I am talking about the ICOs (including PNG items) in EXE/DLL as a library. In such EXE/DLL files there is not a mask for any PNG item.

    Because I don't use the APIs that yereverluvinuncleber uses: I was not aware that a mask is created even for a PNG item - a misunderstanding here.

    I remember LaVolpe has a posting on the subject - listing ICOs in EXE/DLL as a library (he seemed to be using Shell32.dll). The said posting is the proper approach using LoadResource etc (I am sure if one wants it one can find it).

    It is possible to list the ICOs (incl PNG items) on Group basis or on Individua basis. The said LaVolpe's posting is on Individual basis only.

    Below is a screenshot of on Group basis (but the same screen allows user to choose Individual basis as well). The images on the left side is a PictureBox showing the "representative" images of the groups (updated when user selects a panel, the PictureBox is therefore not a big one). The ICOs belonging to the selected Group are listed on the right side - the image below the listing is updated when the user selects an item. The 1st item happens to be PNG, hence the 256x256 ICO is shown. In this case, no mask is involved.
    Attached Images Attached Images  
    Last edited by Brenker; Jul 5th, 2022 at 02:18 AM.

  15. #15
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,708

    Re: VB6 QUESTION: icon to bitmap

    Which post of LaVolpe's are you talking about, this project of his shows the full group when you click on an icon.

  16. #16
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    Re: VB6 QUESTION: icon to bitmap

    @fafalone:

    Thank you for letting me know of this one, a perfect one. This is the 1st time I see it.

    The one I referred must be an earlier one, because to my impression there were many more posting entries there, and one of them was mine. I recall I raised the point of "Group" icons, and LaVolpe asked "what". Then I didn't see him pursue further in that thread. Because of my other engagement prior to 2021, I basically left vbForums for 2 or 3 years.

    Anyway, it is good to know there is such a good posting of LaVolpe's. I miss LaVolope; there had been a thread with a total of about 40 postings, only between LaVolpe and myself: https://www.vbforums.com/showthread....cale-JPEG-TIFF It was such a good time then.
    Last edited by Brenker; Jul 5th, 2022 at 03:34 AM.

  17. #17

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,250

    Re: VB6 QUESTION: icon to bitmap

    Quote Originally Posted by Brenker View Post
    If you are using Professional Edition, then how is the last icon image you got?
    Sorry, using Win7 Pro.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

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