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.Screenshots:
- 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.
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!!
Here is what I'm doing:
procedure TForm1.Button1Click(Sender: TObject);
PRGB = ^TRGB;
TRGB = array[0..2] of Byte;
var VTFImage: Cardinal;
ImgData, AlphaData: string;
Width, Height: Cardinal;
V: array[1..2] of Single;
lpBuffer1, lpBuffer2: PByte;
Source, DestAlpha, DestImg, pSource, pDestAlpha, pDestImg: PChar;
i, j: integer;
uiR, uiG, uiB: Cardinal;
// 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!');
HasAlpha := (vlImageGetFlags() and (TEXTUREFLAGS_ONEBITALPHA or TEXTUREFLAGS_EIGHTBITALPHA))<>0;
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!!!
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?
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
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.
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'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?
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).
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.
New users can register here.