Results 1 to 40 of 59

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

Threaded View

  1. #8

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

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

    Probably final enhancement made. Will support any bug-reports for quite awhile.

    Project in post #1 updated to include support for non-placeable WMFs. These are rare, but VB does not support them natively. Minor code tweaks added for improved sanity checks but nothing major.

    Define non-placeable? Size-less WMF. It has no dimensions, thus no proportions. These types of WMFs are always machine/device-dependent. In other words, they are designed for a specific aspect ratio. Without knowing that ratio, applications must make their own decisions. Most apps will react by defining its dimensions to the size of the screen or some other arbitrary values. This class uses a 256x256 max size scaled proportionally to the current monitor size. In other words, rectangular and not exceeding 256x256. The aspect-ratio decision is a guess and that decision determines whether the image looks or feels right. Is it better to guess square vs rectangle? Rhetorical question. A better & far more difficult solution would be to analyze the WMF internally and determine the extent of each drawing command; thereby having a better guesstimate of its true aspect-ratio. A lot of effort for what is basically a dead technology.

    Tip: If you want to create sample non-placeable WMFs, simply save to a new file, the old file, starting from byte #23. Placeable WMFs have a 22-byte header placed in front of the WMF. Remove this header & it's now non-placeable

    Edited: And a note about using PNG,TIFF, etc and design-view. Recommend the following

    1. As mentioned earlier, support for these image types, and any other non-VB supported image type, are not available during design-time, only run-time

    2. Since you know the size of the image beforehand, size the target control appropriately and that control is simply a placeholder during design-time. Load the image via the resource file during Form_Load. If you don't know the image size, right clicking on it's file and selecting properties should give that information in one of the property page tabs.

    3. I would not recommend creating 32bit bitmaps from PNG/TIF (as is done in the sample project) just so you can see the image during design-view. 32bit bitmaps can be fairly large, storage-wise. Makes a bit more sense to abide by previous paragraph.

    4. Also mentioned in post #1, if you are wanting to access individual sub-images from any multi-image format, place those in a resource file and load them from there. It's one way to guarantee the sub-images are available after your project is compiled to an exe. Sub-image formats can include TIF, GIF, Icons. Would not recommend loading GIFs in design-view if you want to animate them after project is compiled. You'll have to load GIFs from the resource file (or disk) to animate. No point in storing the GIF twice, once in the image control & once in the resource file.

    5. Since TIF support is tied to the version of GDI+ installed on the system, would recommend converting your TIF images using whatever is at your disposal to a new TIF file, storing the pages with LZW compression scheme. That scheme is supported among all versions of GDI+. If the TIF can be loaded using v1.0 of GDI+, you should be good to go. Vista and XP require manifests to use GDI+ v1.1 and lower than XP can only use v1.0. Windows 7 and above always uses v1.1 without a need to manifest, though a manifest can request v1.0 prior to Windows 8. If your project will only run on Win7 or better, then this recommendation can be considered overkill.
    Last edited by LaVolpe; Nov 11th, 2015 at 05:15 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
  •  



Click Here to Expand Forum to Full Width