About VTFLib - NemPosted: Apr 18th, 2005 - 10:27:01 pm

VTFLib is a LGPL open source programming library, written by Neil Jedrzejewski and I. VTFLib provides a C and C++ API that, with a few simple functions, can open and save .vtf and .vmt files, providing access to all known features. The library functions independent of Steam, allowing third party applications to use the library without Steam present or runningi on the target system.

VTFLib includes two GPL example applications, VTFCmd and VTFEdit. VTFCmd is a C command line frontend for VTFLib that can create .vtf and .vmt files from various source formats. It is similar in functionality to Valve's vtex Source SDK utility, but offers a lot more control. VTFEdit is a C++ .NET graphical frontend for VTFLib with viewing and creation capabilities. Both VTFCmd and VTFEdit support several source image formats, including, but not limited to .bmp, .dds, .gif, .jpg, .png and .tga.


VTFEdit .vtf frame/face/mipmap viewing. VTFEdit .vtf information viewing.

VTFEdit file system browsing. VTFEdit .vmt viewing.

VTFEdit import options. VTFEdit batch conversion options.

VTFEdit .wad conversion options. VTFEdit .vmt creation wizard.

VTFEdit .vmt creation wizard. VTFCmd command line options.

Documentation: Features:
  • Convert .bmp, .dds, .gif, .jpg, .png and .tga files to .vtf and .vmt files with easy access to all .vtf options.
  • Convert .vtf files to .bmp, .jpg, .png and .tga files.
  • Convert entire folders to and from .vtf and .vmt files.
  • Convert .wad files to .vtf and .vmt files.
  • Explore .bsp, .gcf, .pak, .wad and .xzp packages.
  • Preview .vtf files.
  • Recent file menu.
  • 100% Free.
Download: Third Party Downloads:
Modified: Sep 14th, 2007 - 3:28:10 am[ 407794 Views ]

[ 1 2 3 4 5 6 7 8 9 ]

46. zafar23081985Modified: Apr 5th, 2007 - 12:48:10 am
Nem, I have written a header file in Delphi, which imports functions from the library. Loaded the *.vtf file into memory by the function vlImageLoad. As I understood the function only loads file to the stream. And how can I show the picture in the window? Which component shuld I use??? Can I use TImage class??? Should I convert an image before showing it???
Can I also use C wrapper as VTF Explorer??? If I can, then how???
Can anybody explain me spet by step, how can I load the *vtf file and show it on the window??? Please!!!! It is too important for me!
Thank you Nem and thanks evrebody!!

47. zafar23081985Posted: Apr 13th, 2007 - 10:07:49 pm
Hello, evrebody!!! I'm writing a program in Delphi 7 which opens VTF files and shows it.
Here is what I'm doing:

procedure TForm1.Button1Click(Sender: TObject);
TRGB = array[0..2] of Byte;

var VTFImage: Cardinal;
RawBuffer: string;
ImgData, AlphaData: string;
HasAlpha: Boolean;
ImageFormat: VTFImageFormat;
Width, Height: Cardinal;
V: array[1..2] of Single;
NumberOfPixels: Integer;
lpBuffer1, lpBuffer2: PByte;
Source, DestAlpha, DestImg, pSource, pDestAlpha, pDestImg: PChar;
i, j: integer;
uiR, uiG, uiB: Cardinal;
VTFFileStream:=TFileStream.Create('loading.vtf', fmOpenRead);
SetLength(RawBuffer, VTFFileStream.Size);
VTFFileStream.ReadBuffer(pointer(RawBuffer)^, length(RawBuffer));
// Zagrujaem biblioteku
if LoadVTFLib=true then
if vlCreateImage(@VTFImage)=false then
ShowMessage('Error creating file!');

if vlBindImage(VTFImage)=false then
ShowMessage('Error binding image!');

if vlImageLoadLump(pointer(RawBuffer), length(RawBuffer), false)=false then
ShowMessage('Error loading stream to memory!');


if HasAlpha then


if (Width>46340) or (Height>46340) then
ShowMessage('Unable to load VTF file. Picture is too large.');

NumberOfPixels:=Width * Height;

uiBufferSize:=vlImageComputeImageSize(Width, Height, 1, 1, ImageFormat);
lpBuffer2:=vlImageGetData(0, 0, 0, 0);

if vlImageConvert (lpBuffer2, lpBuffer1, Width, Height, vlImageGetFormat(), ImageFormat)=false then
ShowMessage('Unable to load VTF file. Call to vlImageConvert failed.');

In this way I have loaded VTF file, converted it to RGB format and load bytes to lpBuffer1!
Now, the problem is that how can I show the image data???
Am I doing anything wrong???
Thanks for Evrebody!!!

48. w33niePosted: Jun 7th, 2007 - 8:31:54 am
Hi, I'm having problems putting new .vtf and .vmt files onto my CS:S server.
So far I've created working .vtf and .vmt files, as well as adding new lines to my mani skins files. But when I use ma_setskin to change to the new skin, it still has the old one on.
The ma_setskin works perfectly, it has changed to the new skin as it says so in the console, and the new skins were even downloaded upon entering the server. But the same texture from the old model remains.

I also haven't edited anything else apart from what's listed above.
What can I do?

49. NemPosted: Jun 10th, 2007 - 1:22:39 pm
I'm not sure I can be much help here. I'm not too familiar with server MODs or Source modeling.

50. GarfieldModified: Jul 8th, 2007 - 11:39:11 am
Hi, I just waned to note that it seams there are memory leaks within VtfEdit.

After quite a research it turned out the source is not the VTFEdit itself, but the VTFLib that it uses.
After one more day in looking into the source code I found out that the NVIDIA TEXTURE TOOLS Library, used by VTFLib for some of its functions, is causing the problem.

Here are my notes:

Importing Image with resulution 4096^4096 few times:

DXT Compression - ok (not 100% sure)
thumbnail generation - minor LEAKs (~10MB for that image res!)
mipmap generation - minor LEAKs (another ~10MB)
resizing 3000 to 4096,- big LEAK (>70MB)
normalmaps generation - major LEAK (>200MB, 50MB for 2048x2048 image)

NOTE that if you NOT use these functions everythings works great - after importing the same file again the memory usage (in task manager) returns to the same value before importing the same image as already imported)
NOTE also that for smaller images the leaks are smaller but are thare!

You can try all this yourself.

Im looking for good texture manipulation library myself, that is why I have done such an investigation:)

Comments (on the issue) and directions (for the lib) are welcome!


sorry for my english

51. marceloModified: Jul 10th, 2007 - 3:18:06 am
Hi Nem,

I have troubles modifying a reticle for the game dark messiah.
I opened reticle_spell.vtf in VTFedit, and it shows 2 channels 1 rgb (with small white circle and black background)
and 1 alpha (which shows the actual reticle)
I export the file to TGA then I open it in GIMP.
However I can't find the alpha channel in GIMP despite looking in channel list.
Do you know what I missed here?

Also if I want to change the reticle drawing? will I have to modify both RGB and Alpha or only Alpha is necessary?

Thanks for your kind help !


I found the alpha channel, but unfortunately its all black, no drawing of the reticle, like it was showing up in vtfedit.

52. NemPosted: Jul 11th, 2007 - 11:38:25 pm
Hi, I just waned to note that it seams there are memory leaks within VtfEdit.

Thanks for the info. I wonder if NVDXTLib keeps the texture data in memory (and returns pointers to this data in the callback) until the next call. Either way, the memory usage seems excessive.

I don't have a lot of time to look at this at the moment, but if I get a chance I'll see if I can't find a workaround. NVDXTLib has always been quite buggy, I've had trouble with every release, but it seems to be getting better.

I found the alpha channel, but unfortunately its all black, no drawing of the reticle, like it was showing up in vtfedit.

I've confirmed that VTFEdit is exporting .tga files with proper alpha channels. I'm not really familiar with the GIMP, so I can't really provide any more help than to say they are there; good luck figuring it out. Maybe ask here?

53. paulbangeanPosted: Aug 1st, 2007 - 7:00:12 pm
hey i have a question. is there a program that con convert .vtf to wad?

54. NemPosted: Aug 2nd, 2007 - 12:04:45 am
No, but you should be able to open .vtf files in VTFEdit, copy them, and paste them directly into Wally to create a .wad file.

55. paulbangeanPosted: Aug 2nd, 2007 - 3:12:11 pm
ok thx. i will try that

56. eyeonusPosted: Aug 28th, 2007 - 7:27:15 am
How do I use this thing to batch convert .vtf to bmp, retaining directory structure?

57. NemPosted: Aug 29th, 2007 - 11:16:30 am
The Batch Convert tool can only convert from .vtf to .tga. To do this, put *.vtf as the Filter. I'll add support for other formats in the next version.

58. The_DecryptorModified: Sep 4th, 2007 - 2:18:25 am
Is there any way to export a HDR VTF, and keep the HDR data? When I've tried it's always exported a LDR image (I export to TGA)

And what about the ability to export to a PNG?, lossless and has 8Bit alpha support.

Edit: I don't want to come off sounding like some whiny user demanding things though (So sorry if I do), these are just thing's I'd like at some time in the future (At the moment I have to transfer the exported TGA's to my mac and save it as a PNG to get the Alpha channel in GIMP, so straight export to PNG would save me some time).

59. NemPosted: Sep 4th, 2007 - 8:53:59 pm
VTFEdit cannot export any HDR formats or PNG files, I may add this at a later time. The GIMP should open VTFEdit generated TGA files ok though...

60. The_DecryptorPosted: Sep 4th, 2007 - 11:27:05 pm
Cool, good to know.

And GIMP can open the TGA files, but it doesn't load the alpha channel, and IrfanView (another app I use) treats the alpha channel as if it was 1Bit, but if I open the PNG I converted on my mac, and re-save as TGA in GIMP, then GIMP and Irfan View can see the full alpha channel.

[ 1 2 3 4 5 6 7 8 9 ]

You must be logged in to post a comment.
New users can register here.
Nem's Tools v2.0 © 2006 Ryan Gregg.
Execution time: 0.042833s; Queries: 17.
dishes served.
Powered by The Wavelength.

Valid XHTML 1.0 Transitional Valid CSS