dcsimg
Results 1 to 3 of 3

Thread: [vb6] Resource Image Viewer/Extraction

  1. #1

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

    [vb6] Resource Image Viewer/Extraction

    A tool I developed to help with another project I'm working on. The tool worked well and decided to pretty it up and share it.

    This is similar to your typical resource-hacker, but limited in scope to only resource images: icons, cursors, bitmaps, animated icons/cursors. You can view those that are contained in a binary (dll, exe, ocx, etc) and also contained in VB resource files (.res). Additionally, you can open a disk icon/cursor file for review.

    There is an option to simulate DPI. This could be useful when you are viewing your own resource file and would like to see what your icons/cursors/bitmaps may look like if you declare your application DPI-aware.

    The tool allows you to extract the viewed images to file. For icons/cursors that contain multiple images, you can individually select which are to be extracted and change the order they will appear in within the extracted file.

    Also there is a filter option for image width, bit depth and whether icons/cursors include/exclude PNG-encoded images.

    Tip: At top of the form, there is a m_AllowSubclassing boolean. Set this to false if you plan on walking through any code; otherwise, leave it to true. The subclassing occurs on three things:

    1) The form itself to restrict minimal resizing
    2,3) The picturebox and scrollbar to trap mouse wheel scrolling messages

    Without the subclassing active, you can't use the mouse wheel for scrolling. The picturebox is coded for standard keyboard navigation.

    Name:  ss.jpg
Views: 871
Size:  33.0 KB
    Attached Files Attached Files
    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}

  2. #2

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

    Re: [vb6] Resource Image Viewer/Extraction

    Routine uses for this project can include

    1. Extracting a single image to file from a multi-image icon. The intent is that the icon would be added to a resource file or the picture property of a control. VB will always select the first icon in the file when adding them to picture properties. If the first icon isn't the one you want, now you have an easy method of extracting the desired one.

    2. Visualizing your multi-image icon resource items in other than 100% DPI without having to change your system DPI. Of course, this assumes you will declare your app as DPI-aware, otherwise, the system always selects the "best" 32x32 icon (or closest size) and scales it. When optional DPI-scaling is chosen, the grid should display the icon as the system would in the selected DPI. The code uses the same APIs that the system uses to determine best icon relative to the icon group's available subimages and system DPI. Note: Though the grid may be DPI-scaling, the group image viewer always displays actual size or scaled down to 256x256 as needed.

    3. If you used tools like Microsoft's Resource Compiler (rc.exe) to add 32bpp icons to your resource file, you can't use VB Resource Editor to view the resource file any longer. This tool can.

    Here's a little resource file 101

    In the status bar on the main form, the group name is displayed. When viewing the selected image group, the viewer window lists the subimage ID if applicable.

    Icons/Cursors are contained in groups. In your VB resource editor this is the name you assigned: 101, "MyLogo", etc. These groups are officially tagged as RT_GROUP_ICON & RT_GROUP_CURSOR respectively. Now each group has at least one icon/cursor, but can have several. These also have an ID, but VB doesn't expose that to you. These IDs are unsigned integers. Any icon, in any icon group, never has the same ID as any other icon in any group. Same applies to cursors. These IDs are displayed when you view the individual images of a group. These are officially tagged as RT_ICON & RT_CURSOR respectively.

    Animated Icons/Cursors. Very similar to icon/cursor groups. The key difference is that the group names are RT_ANIICON & RT_ANICURSOR respectively. Unlike icons/cursors, if they contain multiple images, those are not individually tagged. Some may have multiple sizes, say a 32x32 and 48x48 animated version. To pick which to load from a compiled resource, use LoadImage API passing the desired size.
    Note: though each has multiple frames, the individual frames are not considered subimages. The tool has basic code to animate the icon/cursor for sample purposes only when opened in the viewer.

    Tip: You can manually add these to your VB resource file.
    1. For each cursor/icon, add it as a custom resource
    2. Double click on it and change the "Type" from "CUSTOM" to #21 for animated cursor or #22 for animated icon.

    Bitmaps. These aren't groups and are officially tagged as RT_BITMAP. The individual resource only ever contains one image.
    Last edited by LaVolpe; Nov 18th, 2017 at 03:39 PM. Reason: included the "Resource 101" stuff
    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. #3

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

    The Filter Function

    A bit about the filter function for clarity.

    This does not apply when viewing bitmaps. It is disabled if there is only one image group. Otherwise...

    When filtering on groups that contain or don't contain PNG-encoded images, that is a stand-alone filter and not combined with the other filter options.

    The other filter options allow you to filter on groups that contain one or more image widths and/or one or more bit depths.

    When both widths and depths are used, consider it like this: List all groups where at least one of its subimages contain one of the selected widths AND those also are one of the selected depths.

    There is a checkbox on that filter window to make the filter exclusive. When used, it filters any groups where the filter criteria is not met.

    The filters are automatically cleared whenever the current view is changed (to bitmaps for example) or a new source file is loaded. They can also be cleared via the menu or the filter window.

    The filter function can be useful to quickly locate groups that have subimages you are interested in, say 16 pixels at 8 bits per pixel.
    Last edited by LaVolpe; Nov 18th, 2017 at 03: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}

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