View Full Version : HowTo: DDS images in VB6


ZabMilenko
Nov 29, 2005, 10:16 PM
NOTE: I know this is not a utility program, but those who make utility programs will find this handy. It took me several hours to figure out the DDS file format before I realized I was doing it all wrong. This is a little tutorial for VB developers who want to be able to display DDS images in their app. It should be simple to adapt for VB.NET.

PRINT THIS OUT AND USE IT AS A CHECKLIST

1) Open up the project that you want to display DDS images in OR create a new project.

2) Download This File: http://prdownloads.sourceforge.net/freeimage/FreeImage380Win32.zip?download to a temp folder (outside of your project directory).

3) Open up the zip file and copy ONLY the following 4 files to your project directory:

$archive$\FreeImage\Dist\*.* (3 files)
$archive$\FreeImage\Wrapper\VB6\mfreeimage\MFreeIm age.bas (1 file)

The rest of the archive can be discarded.

4) Add the mFreeImage.bas file to your project.

5) Add this sub to a form or module. You shouldnt edit the mFreeImage.bas file, but that is your choice:

Public Sub DrawImageOnPictureBox(ByVal vFileName As String, ByVal vImageType As FREE_IMAGE_FORMAT, vPictureBox As PictureBox)

Dim mDib As Long

mDib = FreeImage_Load(vImageType, vFileName)

' OLE_PICTURE is the StdPicture object, which can be drawn almost anywhere!
vPictureBox.Picture = FreeImage_GetOlePicture(mDib)


FreeImage_Unload mDib

End Sub


6) And of course, to display a DDS file in Picture1:

DrawImageOnPictureBox PathToDDS$, FIF_DDS, Picture1



I hope this helps out other devs. It's certainly made my project a little nicer. :-)

ZabMilenko
Nov 29, 2005, 10:19 PM
Quick Note: TGA is supported in FreeImage as well.

totg_kabu
Dec 01, 2005, 05:42 AM
Now thats cool, I was going to make a request for this very thing or a link to one today and you've replied a day before :)