Page 1 of 2 12 LastLast
Results 1 to 40 of 47

Thread: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

  1. #1

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

    Resolved [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    Chaps, hopefully an easy VB6 question to answer, I just want to know what you might typically do or what you might suggest as best practice in this case.

    I have some small images, jpegs, that are currently stored in the same folder as the binary. The images are used to display a visual state change. They are very small images that might fit on a button, for example.

    Currently the control is assigned an initial image at design time and the image might change to a new image or back again as the program determines. Rather than have two controls displaying a different image and hiding each as required, instead I load the new picture into the same control.
    This is just an example of what I might do, method not yet determined.

    If you were doing the same would you store the resource, in this case a JPG image:

    o in the application folder?
    o in a sub-folder marked as resources?
    o embed the image in a resource file and extract it when required?
    o embed the image in a resource file and extract all resources when the application first runs?

    It seems to me to be preferable in some way to have all the resources wrapped up in the binary, so the binary alone can be shipped by itself.

    I know I could be quite wrong - so I am asking what you would do in this sort of case. I am only talking about small images and limited amount of discrete resources and of course not libraries of PNGs.

    Any other suggestion would also be welcomed. I am on a learning path here just wanting to get a feel of what you chaps would do in a similar 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.

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    It depends how many images and where are you going to use them.

    If they are just like icons to be assigned to a button, I would put them in a couple of hidden PictureBoxes (possibly an array).
    Also an ImageList can be used.

    I prefer that over storing them on resources or in external files.
    But, as I said, it depends very much on many factors.

  3. #3
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    I store all image in a single file archive.
    That way I can update the images without recompiling the executable.

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    My vote is either the resources or an ImageList control, and extract them as needed (hopefully staying in memory when you do that). If in resources, they'll be fetched from disk when read. If in an ImageList control, they'll be pulled into memory whenever the form with the ImageList is loaded.
    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.

  5. #5

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Thankyou everyone. I think I will use an imageList to front-load the required images. I will play with the MSCOMCTL.OCX version, then I will adapt the program to use Krool's imageList. I think that sounds like a good enough approach for the moment. The thing about lacking experience is that you just don't know what you don't know.

    Sometimes it is good just to hear the things you know being said by others.

    Thanks as always.
    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.

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Look up the standard PictureClip control.

    It requires a little more development effort to create the composite source bitmap yourself, but it is far more efficient and flexible than imagelist controls.

  7. #7
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    I would create an external tool that would do stuff like that.
    if I want the pictures into the binary. I compile the exe and after that run the tool that will append the pictures onto the exe. of course I also include index/pos. and I do that in "reverse form" so reading backward, that way I use the end of file as starting point to add the index-data.
    so, it's easy from the main-exe to know what to do, just read the index-data and after that is just normal stream-loading.

  8. #8
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    99% of the time I store such project images inside in the EXE itself as a resource. My reasoning is that it makes it very easy to cart everything around.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by baka View Post
    I compile the exe and after that run the tool that will append the pictures onto the exe.
    Baka, that's almost exactly what putting them in the resources does, except that it's the compiler doing the appending rather than some custom written tool. Also, when putting them in resources, you can effectively preserve their original file names for fetching them from resources.
    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.

  10. #10
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    I always found the use of resources in VB6 quite cumbersome. (Anyway I used them at first)
    Why to do something in some way when there are other ways that are far easier and handy to achieve the same thing?

    That the resources are not loaded into memory until they are actually needed... does that matter in computers after year 2000?

    I never used any add-in for handling resources. Maybe that could have helped. But to have to edit and build *.rc *.res files... no thanks.

    Just to change one icon you need to go the rabbit hole and do all the process.
    I repeat: maybe some add-in could have helped, IDK.
    But I prefer to click, and find the file, press OK, and be done. And if I didn't like the new icon, then close the IDE without saving and open it again.

  11. #11
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    I work like that.
    I have external tools that "do stuff".
    encryption, sorting, creating data, any media files types and if "editing the pictures" or "changing format" I do that as well, and more.
    I usually don't append to exe, but I do create .dat files that is used by the executable.
    but if the .dat file is small, under 100MB, why not append to exe? its the same really, except you need to tell where is the start. could be added as the last 4bytes of the file.

    the program can work in "2 modes"
    mode 1: IDE-mode, that will read the files from folder
    mode 2: Compiled-mode, that will read the files from a data-file

    the benefit? I can add whatever format, do edits, change, very fast. and since the files are available I can also start up a graphic tool, do changes.
    the only thing I need to do is: when I have a new release of the exe, I also run the "builder", that will create the needed files. thats it.

    I don't have good experience with the resource editor.
    the ui is bad and hard to update stuff. also, if u are dealing with 1000 files, do you really use the resource editor?

    learn how to do it right from start, after that its easy when u have a method for it.
    Last edited by baka; May 5th, 2022 at 05:14 AM.

  12. #12

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by Eduardo- View Post
    I never used any add-in for handling resources. Maybe that could have helped. But to have to edit and build *.rc *.res files... no thanks.
    I've never used anything but the little Microsoft Add-In for managing my resources, and I've always found it quite easy and intuitive. It just automatically writes things into the Project.RES file, and then the compiler/linker append it to the EXE when compiled. When running from the IDE, it's smart enough to just use the .RES file to get the resources when they're called for. I consider the .RES file as just another piece of source code.

    I was once also worried that adding and deleting resources (with the little Add-In) would leave holes in the .RES file (and possibly what's appended to the .EXE file). However, after some investigation, I found that that's not true. When you're in the little Add-In, you do have to hit "Save" to write-out the .RES file ... and, apparently, when that's done, apparently all items, indices, & resource item names are re-organized. It's a well done Add-In. (The only bug I've found is that it clears the clipboard when you load it, but that's true of any Add-In with a toolbar icon. It's really more of a bug in the Add-In system rather than this specific Add-In.)

    Addendum: Also, other than for manifests, I've never used it for anything other than "Custom" resources (but possibly in other folders to keep some kind of organization among the resources). I just read them into a Byte array, and then do with them what I want from there.
    Last edited by Elroy; May 5th, 2022 at 08:28 AM.
    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.

  14. #14
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by Elroy View Post
    I've never used anything but the little Microsoft Add-In for managing my resources, and I've always found it quite easy and intuitive. It just automatically writes things into the Project.RES file, and then the compiler/linker append it to the EXE when compiled. When running from the IDE, it's smart enough to just use the .RES file to get the resources when they're called for. I consider the .RES file as just another piece of source code.

    I was once also worried that adding and deleting resources (with the little Add-In) would leave holes in the .RES file (and possibly what's appended to the .EXE file). However, after some investigation, I found that that's not true. When you're in the little Add-In, you do have to hit "Save" to write-out the .RES file ... and, apparently, when that's done, apparently all items, indices, & resource item names are re-organized. It's a well done Add-In. (The only bug I've found is that it clears the clipboard when you load it, but that's true of any Add-In with a toolbar icon. It's really more of a bug in the Add-In system rather than this specific Add-In.)
    As I said: I never used any add-in for handling resources. At the time I used resources I didn't know that that add-in existed.

    But my question remains: how that approach can compare to just loading a new picture into a property? I think that's hard to beat.

    If you need to test a new picture, how many steps do you need to do? (add-in included)

    I'm asking (and being skeptical), I never used that add-in.

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Putting a file into resources with the add-in is a drag-and-drop operation, and then maybe assign it the name and (resource) folder you want. And that's it. To fetch while running is just as trivial, specify the folder and name to LoadResData and it loads it into a Byte array.

    And that works while running in the IDE as well as compiled. When running in the IDE, it's smart enough to go to the .RES file for the resources.
    Last edited by Elroy; May 5th, 2022 at 08:35 AM.
    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.

  16. #16

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Elroy, This resource add-in you are referring to, is that the usual resource editor that comes bundled with VB6 or is it something better and more advanced that you have discovered?
    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.

  17. #17
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by Elroy View Post
    Putting a file into resources with the add-in is a drag-and-drop operation, and then maybe assign it the name and (resource) folder you want. And that's it. To fetch while running is just as trivial, specify the folder and name to LoadResData and it loads it into a Byte array.

    And that works while running in the IDE as well as compiled. When running in the IDE, it's smart enough to go to the .RES file for the resources.
    It seems easier than having to edit the rc file with Notepad and compile the res file, but still not as simple as loading a new picture into a property and pressing F5 to see the new picture in action in a couple of seconds.

    Also, not having to keep the bmp file in disk (and rc text file too).

    PS: the *.frm for all text and and *.frx for all binary seems a good design choice. I mean, not having to keep other files.

  18. #18
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    depends the need and how u work.
    for me all files available in a folder is more comfortable. I can add, edit, delete.
    I also include all kinds of files and any format. mp3, png etc and raw data.

    of course compiled I dont want the user to have thousands of files in a folder.
    1: to extract takes much more time than 1 big file
    2: small files eat up HD more

    but if u want to have a few pictures that will be shown in the form,
    why bother with resource files at all.
    the only reason to have resources is to be able to call it when needed.
    why should I load 1GB of files, that in raw-format will take x30 times the size, who have 30GB of GPU memory? so of course the files need to be called when needed.
    but if we are talking 10MB, come on, u can just use the res.
    but for me, since I have my method Im more comfortable working like this.

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by yereverluvinuncleber View Post
    Elroy, This resource add-in you are referring to, is that the usual resource editor that comes bundled with VB6 or is it something better and more advanced that you have discovered?
    It's just the standard Microsoft one that comes with the VB6 development package. I've never had any problems with it.
    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.

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    And hey, Eduardo, I'm not saying that the ImageList or the PictureBox aren't good alternatives. They are.

    I suppose one advantage I see with resources is that you don't have to load a form to use it. And one disadvantage is that it's going to come to you as a Byte array that you must then deal with.
    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.

  21. #21
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    The most convenient approach depends on lot of things... including personal preferences.

    I usually do things with UserControls, with custom controls, so I add all the picture properties that they need.

    All the alternatives have advantages and disadvantages. ImageLists have the disadvantage that they add a reference to Common Controls, an ocx. I'm just saying. Using the ImageList from Krool's controls inside the exe project avoid that dependency but add complexity to the project...

    So if you just need a couple of images, why to complicate so much. Just add a couple of PictureBoxes.
    But if you need 30 images, then maybe an ImageList is better. Or a resource file...
    Files outside... are another option. I don't like it, but maybe another person likes that approach.
    DLL? Yes, DLLs are also an option.
    Store the images in the code itself, as a String constant (Base64 encoded). Also possible.
    Other alternatives? For now I can't think of another one (that is not a variant of one of these)... but for sure there are more.

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    DLLs is a good point. I've got tons of images in DLLs, especially for one particular "help" system that has lots of pictures of xrays with examples of how to interpret things and setup things. There are also lots of "help" forms in those DLLs. So yeah, that's another alternative.

    If you load (and unload) the DLLs on an "as needed" basis, you can also manage memory usage.
    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.

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    There is no single answer. Some controls require an ImageList to source images.

    A PictureBox is a pig consuming multiple GDI, Win32, and ActiveX resources. If you just want to hold an image in an FRX/CTX resource then use an invisible Image control instead. Or even lighter: use an icon/cursor, bitmap, or custom resource and load it on demand or cache it in a StdPicture instance.

    I mentioned PictureClip earlier but you can also do the same sort of thing with a custom Class or invisible UserControl. A "sheet" of multiple sprite/icon images can save a ton of resources compared to a large number of separate small images and container objects. This is similar to what goes on inside an ImageList control, but it can offer more flexibility such as irregular sizes.

    https://docs.microsoft.com/en-us/cpp...?view=msvc-170

    An "image list" is a collection of same-sized images, each of which can be referred to by its zero-based index. Image lists are used to efficiently manage large sets of icons or bitmaps. All images in an image list are contained in a single, wide bitmap in screen device format. An image list may also include a monochrome bitmap that contains masks used to draw images transparently (icon style).

  24. #24
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by dilettante View Post
    A PictureBox is a pig consuming multiple GDI, Win32, and ActiveX resources.
    I never understood that kind of POV.
    If we were talking about 1000 images on a form, maybe that makes sense, but for a couple of images, you can have a couple of pigs in a barnyard.
    We are not in the 90's anymore.
    We need to know when to optimize and when not to optimize.

    Or put in another way: when to optimize one thing (GDI, memory, etc) and when to optimize another thing (your time).

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    How difficult is it to choose an Image control instead?

  26. #26
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by Elroy View Post
    DLLs is a good point. I've got tons of images in DLLs
    I just do it like this....

  27. #27
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by dilettante View Post
    How difficult is it to choose an Image control instead?
    Yes, it is valid.

    But I often use the PictureBoxes as a auxiliary (hidden) canvas for doing something else, so why to add another control when I can do all with just one?

    BTW: I have the Image control very much out of the radar lately. It is no good for showing images (flickering in some situations), not good for stretching (no halftone).

  28. #28

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

    Re: VB6 QUESTION: Best Practice for Storing Small Images

    Thankyou everyone, I was expecting more consensus but at least I now have some pointers and some directions to do some research into. I am now currently working with imageLists for the moment, they are surprisingly, fairly new to me, I have only used them once as an interim structure to create dragIcons from image files on disc but wasn't aware of their power. I have in the past loaded images into structures like dictionaries or used arrays storing external references to images in the file system and I wish I'd asked earlier. The imageList looks a good fit.

    I believe that the imageList will be best for my immediate needs especially as krool has his alternative version, so I can avoid using an MS-supplied OCX, something I try to avoid for my own reasons.

    I also like that recommendation of a pictureClip and I see that I'll need to do some investigation there. I am familiar with RES files at a very basic level but they still seem a little alien to me. I think I'd have to be forced down that direction by someone pushing me with a broom. Storing images in external DLLs, well I have absolutely no experience to tell me how that would be done, so I may park that one for the moment unless you have a good guide or a sample program for me to ponder over.

    Thanks for your help. I'll close this one and mark it as resolved. A big THANKS to you all.
    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.

  29. #29
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    There are 3 additional options for you to choose from:

    (1) RC6.SqliteDB
    (2) RC6.ImageList
    (3) RC6.WebArchive

    The above 3 options can clearly show the convenience brought by modern technology (VB6-2020).
    Last edited by SearchingDataOnly; May 6th, 2022 at 09:48 PM.

  30. #30

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

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by SearchingDataOnly View Post
    There are 3 additional options for you to choose from:

    (1) RC6.SqliteDB
    (2) RC6.ImageList
    (3) RC6.WebArchive

    The above 3 options can clearly show the convenience brought by modern technology (VB6-2020).
    Later on I intend to engage with RC5/6 but not at the moment as it is not yet needed for the simple stuff that I am doing. Thanks for that though.
    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.

  31. #31

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

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    Question for you SDO and anyone else that cares to respond, the RC5 imageLists are not constrained to just one image size? ie. You can load any image size that you require? I am certain that is the case.
    More importantly, can the RC5 imageList be pre-loaded with images at design time? Any examples available?

    If I remember correctly in the standard VB6 imageList, all the images have to be the same dimensions and aspect ratio?
    Last edited by yereverluvinuncleber; Jun 27th, 2023 at 11:07 AM.
    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.

  32. #32
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by yereverluvinuncleber View Post
    If I remember correctly in the standard VB6 imageList, all the images have to be the same dimensions and aspect ratio?
    Yes

    Quote Originally Posted by yereverluvinuncleber View Post
    Question for you SDO and anyone else that cares to respond, the RC5 imageLists are not constrained to just one image size? ie. You can load any image size that you require? I am certain that is the case.
    Yes. RC5/RC6 ImageList can load not only images of different sizes, but also different types of images.

    Quote Originally Posted by yereverluvinuncleber View Post
    More importantly, can the RC5 imageList be pre-loaded with images at design time? Any examples available?
    Yes

    RC5.ImageList is actually a cCollection, which just adds several functions specifically for image processing on top of cCollection.

    You can use cCollection to make your own ImageList, for example:
    Code:
    Dim oMyImageList as cCollection
    Set oMyImageList = New_c.Collection
    
    oMyImageList.Add oSurface, "SurfaceName"
    
    oMyImageList FileNameOrByteArray, "MyImageName"
    Cairo.ImageList is a global, static cImageList (or a global, static collection)

    Edit:
    What do you mean by "design time"?
    If your image assets are stored in files, or databases, or VB resource files, then you only need to load image assets from these media at runtime.
    Last edited by SearchingDataOnly; Jun 27th, 2023 at 11:40 AM.

  33. #33

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

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    Ah, right, there is the limitation I think. Thinking about adding images to embed within the binary and then the images are delivered 'internally' as per the previous suggestions above in the old chat, specifically the RES file suggestion and hidden picBoxes.

    Using some of the suggestions above, I can pre-load or add images at design time within the IDE - but I imagine NOT with a RC imageList.
    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.

  34. #34

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

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    I think I am just going to do what Dil suggests, load the limited JPG resources on demand, it is straightforward. I may create a multiple embedded icon and use the code that I have to load that, I'll think about it.

    Sorry for re-opening a closed thread. Thankyou for your help.
    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.

  35. #35
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    Quote Originally Posted by yereverluvinuncleber View Post
    Ah, right, there is the limitation I think. Thinking about adding images to embed within the binary and then the images are delivered 'internally' as per the previous suggestions above in the old chat, specifically the RES file suggestion and hidden picBoxes.

    Using some of the suggestions above, I can pre-load or add images at design time within the IDE - but I imagine NOT with a RC imageList.
    You can easily build a UserControl based on RC5.ImageList Or RC5.Collection, which can save images at design time, just like MS.ImageList.

  36. #36
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    The general way to deal with picture UI in HTML is to load a large picture PNG with many small pictures pasted in it. You only need to know the RECT attribute (XY coordinates and width, height) of each small picture, and then you can easily extract or copy it to Any object above.Just like GDIPLUS.DLL, for example, if you load a button picture (4 rounded corners + middle area), you can extract these parts and zoom in or out the button at will. GdipDrawImage or other functions can specify the area copied from the larger image.

    only one picture file:ui.png,put 1000 small images
    getimage like this:
    put 2 files in res file:
    rect.txt /or json
    ui.png
    Code:
    dim width as long,height as long
    call GetSize("01.png",width,height)
    
    call GetSize("Closebutton",width,height)
    
    drawimg me.hdc,img,"Closebutton"
    
    drawimg picture1.hdc,img,"01.png"
    drawimg picture2.hdc,img,"02.png"
    drawimg picture3.hdc,img,"02.png",300,300
    drawimg picture3.hdc,img,"02.png",100,100
    Code:
    dim img as long
    img=loadimg(ui.png) or by res memory stream
    function drawimg(dc,img,imgname)
    '****
    end function
    
    function GetSize(imgname,width as long,height as long)
    ***
    end function
    Attached Images Attached Images  
    Last edited by xiaoyao; Jun 27th, 2023 at 07:00 PM.

  37. #37
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    For example, how to combine multiple pictures into one large picture, the best combination, the least width and height occupation. and return a JSON or text configuration like:
    x,y,width,height
    1.png 100,100,50,50
    2. jpg 100,150,30,100

    A similar technique is used for a whole iron plate, how to cut multiple objects of different sizes with the least waste

    Name:  UI_MoreImg.jpg
Views: 313
Size:  81.0 KB
    Last edited by xiaoyao; Jun 27th, 2023 at 06:47 PM.

  38. #38

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

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    Yes, well, that is a fascinating way of doing things and I can see it would work but it does feel a little kludgy. However, I do like your style.

    It's certainly a thought. Thankyou xiaoyao.
    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.

  39. #39
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    Recently, I need to use a lot of fragmentary images of labels and buttons in the project, and I haven't had a chance to use the "wizard technology" in Css. Here I write a document about my understanding of background-position for more people to learn.

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

    Re: [RESOLVED] VB6 QUESTION: Best Practice for Storing Small Images

    Nothing really new there.

    VB6 came with ImageLists that work similarly internally. The limitations there are that all images are the same size and they're stored as a composite uncompressed BMP.

    For more complex user-composited images VB6 came with PictureClip which can carve out uniform-sized "cells" or arbitrary rectangles. That way you can have "tiles" of varying dimensions. At design time you can load it with a BMP, GIF, or JPEG but they'll likely be stored as BMP. However you can load a PNG or something at runtime and assign it to PictureClip.Picture, perhaps from a PNG resource.

    You can also create an invisible-at-runtime UserControl to handle this however you like.

    But the principle has been around for quite a long time.

Page 1 of 2 12 LastLast

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