What image types does VB6 support?

2019-08-18 00:14发布

What specific picture or image types & formats does VB6 support?

I can find specific examples here on SO but I haven't seen any comprehensive information.

I am mainly interested in what can be used "natively" by VB6, though I am sure there are third-party libraries and/or other methods of loading additional image types.

标签: graphics vb6
1条回答
姐就是有狂的资本
2楼-- · 2019-08-18 00:49

The function LoadPicture (loosely) defines what graphics formats are "supported by VB6" in a native sense. Here are the relevant details:

Loads a graphic into a forms Picture property, a PictureBox control, or an Image control.

...

Graphics formats recognized by Visual Basic include bitmap (.bmp) files, icon (.ico) files, cursor (.cur) files, run-length encoded (.rle) files, metafile (.wmf) files, enhanced metafiles (.emf), GIF (.gif) files, and JPEG (.jpg) files.

Additional information based on a useful external post:

There are many types of picture files, and some of them have multiple "sub types" too. Unfortunately several popular types have been created (or extended) since VB6 was released, so it does not support them.

Supported file types

This is the list of types shown in the help for VB6 (under LoadPicture):

Graphics formats recognized by Visual Basic include:

  • bitmap (.bmp) files,
  • icon (.ico) files,
  • cursor (.cur) files,
  • run-length encoded (.rle) files,
  • metafile (.wmf) files,
  • enhanced metafiles (.emf),
  • GIF (.gif) files,
  • and JPEG (.jpg) files.

A note about icon (.ico) files

These have evolved over the years, and many of the icons you find on the web are not supported.

VB6 only supports icons that have a size of 32x32 or 16x16, and a color depth of "True Color" (24-bit) or "256 Colors" (8 bit) or less - so no alpha channel (32 bit).

If you find icons that are described as "XP icons" or "Vista icons", they are unlikely to load in VB - if they do, it is because suitable icons are also included in the file too (a .ico file can contain multiple pictures).

You can convert icons to a suitable format using an icon editing program...

Other file types

If the file type you want to load is not listed above, you will need to do some extra work.

The easiest way (if you only have a few files) is to use a paint program to convert the picture file to one of the types listed above.

There are many situations where that is not valid (such as when you want the user to be able to load .png files), in which case you either need to find pre-written code (or a component) to load the file for you, or write the code yourself.

查看更多
登录 后发表回答