Results 1 to 16 of 16

Thread: Would having a picture load only when needed reduce the compiled.exe size?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Would having a picture load only when needed reduce the compiled.exe size?

    Hi there folks. I am working on a prog that is a little sluggish on a flash drive. The .exe is a big file size . It has quite a few pictures. Would it be less sluggish if I changed it so, the pictures only load when needed?

    If that is the case, I have quite a few forms with a picture loaded as the form picture property, is there a way to cancel or remove the picture?

    Thank you so much!!!

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    Are you using a picture box or image control and how many pictures are you using in your application?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    I am using a picturebox in many, and some forms have 7, some have an array of 31.
    There are lots lol.

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    Well, in that case then yes, loading the pictures into the program would make a difference.

    This is how to remove the picture from either a picture box or image box.

    Code:
    'Clear the image from a picturebox
    Picture1.Picture = LoadPicture("")
    'Clear everything from a picturebox
    Picture1.Cls
    'Clear image from a imagebox
    Image1.Picture = Nothing
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5
    Hyperactive Member
    Join Date
    Mar 2014
    Posts
    321

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    save compressed images into database that way u got 1 datafile containing lots images

  6. #6
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    Just load your pictures at form_load into a stpPicture array, that way your program will load the pictures faster from memory than from file. It will only slow down the loading of program a little. You could add a DoEvents in the loading loop and me.show before the loading loop so program would be visible and responsive even tho it's loading pictures.

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    If you want to reduce the exe file size then you need to not have the pictures included in the exe. In other words the picture boxes would be empty in the designer and loaded at run time. If you are talking a lot of pictures then this would reduce the exe size a lot. Loading the pictures from file may cause some drag int he program depending on how many you are loading at once, how large they are and what format they are in.

    And of course loading from a flash drive will be slower than loading from a HD how much slower depends on the USB interface in use.

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    OH these are BRILLIANT ideas. I feel like a coder from the 70s trying to build in as little space as possible lol.

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

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    Have you looked at compressing the images?

    BMPs of any size at all are usually quite wasteful and could be replaced by compressed JPG, GIF, or PNG images.

    JPG photos can often be compressed at a lower quality and save space with little visible reduction in appearance.

    PNGs have been trivially loadable at run time in VB6 for a long time now (since WIA 2.0 in Vista) and it only takes a little bit of GDI+ code to load them without WIA if you still need to run on ancient unsupported Windows versions. GIF can be better for low-color images (256 or less colors) but PNG supports higher color depths. A graphics tool with PNGOUT support can produce better PNG compression.

    These work better for images with less variation in them than photos normally have.

    Even before compression you can look at color depth and size. Scaling a huge image down to the size you need ahead of time often makes more sense than doing it at runtime. Dropping the color depth often doesn't hurt image quality and can save a lot of space, though once again photos don't always stand up well to this.

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    Quote Originally Posted by dilettante View Post
    Have you looked at compressing the images?

    BMPs of any size at all are usually quite wasteful and could be replaced by compressed JPG, GIF, or PNG images.

    JPG photos can often be compressed at a lower quality and save space with little visible reduction in appearance.

    PNGs have been trivially loadable at run time in VB6 for a long time now (since WIA 2.0 in Vista) and it only takes a little bit of GDI+ code to load them without WIA if you still need to run on ancient unsupported Windows versions. GIF can be better for low-color images (256 or less colors) but PNG supports higher color depths. A graphics tool with PNGOUT support can produce better PNG compression.

    These work better for images with less variation in them than photos normally have.

    Even before compression you can look at color depth and size. Scaling a huge image down to the size you need ahead of time often makes more sense than doing it at runtime. Dropping the color depth often doesn't hurt image quality and can save a lot of space, though once again photos don't always stand up well to this.
    I use the program on one of those interactive whiteboards, so any "imperfection" in an image because of jpg would be 10x as big. Honestly, I don't think the students would care, or see it tbh, but I am too nitpicky there I guess lol. I like the idea of png because it is smaller file size, and great quality. If there is one thing elementary students like, is colorful programs. Is there a way for VB to allow me to choose png files in addition to bmp , jpg, an gif when I go to select image?


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

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    There is no PNG support at all in VB6.

    However as long as you are setting images at runtime you can either use WIA 2.0 which can load a PNG file or resource and create a StdPicture quite easily.

    Code:
        'Requires Windows XP SP 1 or later, and a reference to:
        '
        '   Microsoft Windows Image Acquisition Library v2.0
        '
        With New WIA.Vector
            .BinaryData = LoadResData(101, "CUSTOM")
            Set Image1.Picture = .Picture
        End With
    'Or:
        With New WIA.ImageFile
            .LoadFile "Misc101.png"
            Set Image1.Picture = .FileData.Picture
        End With
    With more code you can do the same thing by making GDI+ API calls yourself.

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    Quote Originally Posted by dilettante View Post
    There is no PNG support at all in VB6.

    However as long as you are setting images at runtime you can either use WIA 2.0 which can load a PNG file or resource and create a StdPicture quite easily.

    Code:
        'Requires Windows XP SP 1 or later, and a reference to:
        '
        '   Microsoft Windows Image Acquisition Library v2.0
        '
        With New WIA.Vector
            .BinaryData = LoadResData(101, "CUSTOM")
            Set Image1.Picture = .Picture
        End With
    'Or:
        With New WIA.ImageFile
            .LoadFile "Misc101.png"
            Set Image1.Picture = .FileData.Picture
        End With
    With more code you can do the same thing by making GDI+ API calls yourself.

    Oh you guys are great. Already shaved about 20mb off the .exe size. I wonder how much I can further save!!!

  13. #13

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    Quote Originally Posted by Justin M View Post
    I wonder how much I can further save!!!
    Turn On the "Compile to P-Code" option in project properties.

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    What would be the difference between that option and native? Are there any compatibility differences?

  15. #15

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    Quote Originally Posted by Justin M View Post
    What would be the difference between that option and native? Are there any compatibility differences?
    I'm using this option for 10 years for all my solutions, difference is in faster compilation, much smaller size (PRO) program execution is slower but i never notest the difference (CON)

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

    Re: Would having a picture load only when needed reduce the compiled.exe size?

    Execution can even be faster!

    However this only occurs in limited situations such as small programs that load, do a simple thing, and then exit. The most common case would be server side CGI programs that are run thousands of time. The speed gain all comes from a smaller EXE loading faster and tending to already be in the disk cache most of the time.

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