This is archived copy of currently unavailable Nem's Tools website, restored from Web Archive.
Download section now provides links to both Web Archive and to this unofficial Github mirror.
About VTFLib - NemPosted: Apr 18th, 2005 - 10:27:01 pm
About:

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:

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[ 447066 Views ]

[ 1 2 ]

61. MJPosted: Oct 1st, 2007 - 2:38:03 am
i get this error:


62. 4-Legged TumorPosted: Oct 28th, 2007 - 12:37:56 pm
When The GIMP saves a tga image with an alpha channel, it does not retain RGB information for pixels in which the alpha value is 0. I believe the problem with opening images converted from vtf to tga in The GIMP is related to this.

63. dissonancePosted: Nov 16th, 2007 - 2:44:30 pm
MJ: I'm getting the same error. Nothing seems to fix it. I've given up.
Is there any way to create VTFs and VMTs on a linux computer, short of running VTFEdit through wine+mono? I'd really like to keep making my own textures and not asking my friends to convert them for me.
And I can confirm that TGAs with an alpha channel created in Gimp do not import correctly.

64. sunrunner20Posted: Nov 25th, 2007 - 4:07:16 pm
I'm also interested in Linux support. I'm no expert programmer, but I really don't see any .net specific code in the actual library. Is there any?

65. NemPosted: Nov 26th, 2007 - 12:45:14 pm
There is no .NET specific code in VTFLib or VTFCmb, and very little Windows specific code, so a port would be relatively simple if it wasn't for the fact the VTFLib depends on NVDXTLib for DXT compression. This is because NVidia only releases NVDXTLib as VS.NET 2003 and VS.NET 2005 static C++ libraries.

VTFCmb may, however, run under Wine (I haven't tested it, but HLLib used to before I ported it).

66. ChewyIsKickAssPosted: May 28th, 2008 - 9:11:31 am
Sorry if I sound like an idiot but I don't really know how to use this. It's just a bunch of .txt files. Do I put them somewhere, or do I open them with a program, or am I just dumb?

67. NemPosted: May 28th, 2008 - 1:11:24 pm
I'm not sure what you mean; did you download the correct installer? The very first link titled "Installer" on this page should work.

68. JackBALLModified: Jun 5th, 2008 - 7:10:02 am
The latest VTFEdit makes a bunch of textures that flip layers in Hammer. When I turn the camera view, the faces change order of display making walls in back of a wall in front of the camera show through the wall directly in front of the camera.

How do I turn this off in the auto-vmt creation? The older version of VTFEdit worked fine, maybe I will use that for now.

If you want I can upload a video of this strange problem.

Could you please impliment batch VMT modification? I require a tool that will take a line out of 800+ VMT's, but they are in 30 separate folders. Using Notepad++ would take some time.

69. NemPosted: Jun 5th, 2008 - 1:24:26 pm
It sounds like you have two faces exactly on top of each other, the observations you have made sound like z-fighting. If so, this has nothing to do with the texture.

70. JackBALLPosted: Jun 11th, 2008 - 9:23:33 am
Thanks! I had an old BSP that I was porting but I did not have the RMF so I decompiled it. Oh well, I guess I should remake the map. WinBSPC butchered it!

71. snakemediaModified: Oct 6th, 2008 - 7:19:20 am
Hi @JackBALL,
You have right, because bsptwomap for Quake 3. Map File doesn't support for Half-Life, because map was problematic on the Valve Hammer Edition. I see bad decompiler, because we need bsptwormf like bsptwovmf. Because Rmf was correct file for correct blocks and showing clip, null, orgin, skip and hill blocks support working. In the decompilrd map files do not show special textures (null, clip and more...) blocks. That problem of bsptwomap deleted special texture-blocks.. sad .

I know that bsptwormf, because it will to support with special texture-blocks.

Thanks Bye SnakeMedia

72. [ TSF ] LORD DAVROSPosted: Nov 29th, 2008 - 3:18:18 am
Hi sorry if this sound a bit dum .. but I have been using hammer for mapping for half life 2 death match now for some time. Now i need to seriously start creating my own textures and have started to use vtf edit.
My problem is that if I allow vtf edit to create mipmaps the texture in hammer and in game looks really crap and basically degrades the further away you are from the wall or texture. If i turn off the mip maps the texture will look great in hammer and in the game BUT the thumbnail in hammer where you select your texture basically gets mixed up with other thumbnails and gets distorted making it harder to make your texture choice when you have allot of them. also I cant find an option to reduce the number of mip maps from 9.

I had thought that if I reduced the mipmaps to say 1 that the thumb nail would return to its proper look and the in game texture would also still look good.


Do you have any help please or sujestion.... Also is there a tutorial on how to use vtf edit for texture creation please.

73. NemPosted: Nov 29th, 2008 - 4:01:02 am
It's interesting that you say mipmapping makes your textures look worse because one of the purposes of mipmaps is to improve the visual quality of the scene. There are a few cases where mipmaps aren't much help (e.g. weapon skins) but for the most part you should generate them.

I suggest you play around with the mipmap settings in VTFEdit. For general textures I recommend the Sine Cardinal mipmap filter (as it is closest to the filter vtex uses); however, the Box mipmap filter may work better in some situations. If you find your mipmaps are too blurry, you may try a sharpen filter (otherwise set the sharpen filter to None). Of the sharpen filters, Unsharpen Mask is probably the best. There are additional options for this filter under the advanced tab. Decrease the amount to decrease the amount of sharpening.

The same settings don't always work best for all types of textures, but you should find ones that work. It can be a good idea to generate your texture multiple times with different settings and examine the resulting mipmaps in VTFEdit.

Lastly, if you have a somewhat recent video card, you may want to make sure you're using a good filter in game. Typically this will be the highest anisotropic setting your video card supports.

74. [ TSF ] LORD DAVROSModified: Nov 29th, 2008 - 5:59:12 am
thanks for the reply nem Since posting this morning I have been trying the different settings as you describe but unfortunatly with out much sucess. the best setting still seems to be with no mipmaps. the basic quality of the texture seems prety good and is of a large enough size (256 x 256).
once in game with mip maps on the patern looks ok if you are close to it but as you look further down the length of the wall it looks more and more blurd.

A friend of mine has had this problem and went over to using photo shop to make his textures but I dont have photo shop and that meathod seems much more complicated.
Per haps if the mipmaps were reduced from the 9 that it creates to say 1 2 or 3 it might look different.

PS .. my understanding of mipmaps was to use a lower resolution texture as you moved further away from the textured object so as to use les computer rescources and aid FPS ????

75. NemPosted: Nov 29th, 2008 - 1:52:43 pm
If your mapping for a game that uses a more recent version of the .vtf format, you can include a LOD Control Resource which can be used to limit the number of mipmaps used. To use this feature, make sure your .vtf version is 7.3 or above (Advanced tab) then enable the resource under the resources tab.

Resizing images is not only an expensive task, but it is a very difficult task to do with good results. The purpose of mipmaps is to provide the rendering engine with a series of high quality resized versions of the original. This way, when the engine gos to fill a polygon, it is more likely to have a high quality texture of roughly the same size as the polygon.

Mipmaps don't stop the engine from resizing, however. The engine will typically choose the two textures closest in size then interpolate to get the best approximation. There are different types of interpolation methods, but the best are very expensive (so you're not really saving anything by having smaller textures far away because (1) you're using more than one texture and (2) your doing several interpolations instead of just one).

An excellent description of the different ways mipmaps are used is described here.

Perhaps if you could provide me with some screenshots of the problems you are having I can provide more assistance...

76. [ TSF ] LORD DAVROSModified: Nov 29th, 2008 - 5:41:03 pm
ok thanks again for the reply
here is a pic with mip maps
http://www.rtype.com/TSF-Clan/forum/uploads/20081129_233945_mipmap.jpg

and here is a pic with out mip maps
http://www.rtype.com/TSF-Clan/forum/uploads/20081129_232721_no_mip.jpg

alternativly you can see my post on this with the pics and description of my problem here on my clansweb site.

http://www.rtype.com/TSF-Clan/forum/forum_posts.asp?TID=863&PN=1

77. NemPosted: Nov 29th, 2008 - 8:08:13 pm
That definitely looks like bilinear texture filtering to me. Perhaps you have your video card driver set to override the quality settings of other applications and optimize them for speed? You'll want to use trilinear texture filtering at the very least.

78. [ TSF ] LORD DAVROSModified: Nov 30th, 2008 - 3:45:20 am
OK I rhink you might have hit the nail on the head as all my settings were on let the aplication decide but they are all using trilinear, But I have just found that if I up my setting for this to 16x it seems to be much better.in hammer and in the game.
I am not the only one to see this problem as now that I have pointed it out to him, SADIST (another well known mapper for Hl2 Death-Match ) can also see this problem.

I will see if I van get sadist to try this out tonight as well .

Ps my wifes pc has the same game on it and her setting is only at trilinear but looks great on the screen but she is using an old ati 1950 pro GPU and i know that there are quite allot of differences between ATI and Nvidia.


EDIT..... Just spent a bit of time testing this and yes you are definatly right it is the Anisotropic filtering but it only fixes it if i change the gpu setting for this to 16x...

Many thanks for your time on this for me .....

79. NemPosted: Nov 30th, 2008 - 11:26:39 am
I'm not sure if Hammer will use anisotropic texture filtering on it's own (it's a pretty old application - older than the filtering technique). Source engine games should choose the best filter depending on your video card.

Most recent mid-range video cards should be able to handle 16x anisotropic texture filtering with virtually no performance loss, so I do recommend forcing it on if you have a decent card.

80. [ TSF ] LORD DAVROSPosted: Nov 30th, 2008 - 11:38:06 am
well the Nvidia 280 I am using is one of the most powerfull cards out at the mo ...

And putting the gpu on 16 times also fixes the image in hammer as well as in the game.My friend sadist has an old AGP slot card and he also notices no drop in fps when he turned on 16x as well so I think the problem is solved.

Thanks for your help on this nem... much apreciated...

81. asclanModified: Dec 1st, 2008 - 2:54:19 pm
I have ran into a strange problem with VTFCmd....in valves hammer editor I can see the texture perfectly fine in the "browse" list. But as soon as I apply the texture in hammer, in the 3D View it shows nothing but pink and black squares...


I cannot for the life of me figure out what is wrong...If I go into photoshop and resave the vtf using the photoshop vtf plugin, all is well so it has to be something I am not doing with your tool...I really would like to use the VTFCmd tool for batch operations.


For the below I just simply dragged and dropped a file brick004b.PNG onto the VTFCmd.exe file:


Just for the the technical info, here is my materials path

...hl2mp\materials\asclan\pack1

Contents of the pack1 folder:
brick004b.vtf
brick004b.vmt

Here is the contents of my brick004b.vmt file:

"LightmappedGeneric"
{
"$basetexture" "asclan/pack1/brick004b"
}


As you can see from the above, everything is correct, but here is what I see when using my texture:

http://www.asclan247.com/images/error.jpg

What would be the CORRECT command line syntax for VTFCmd to do:
1. Texture (VTF)
2. Normal Texture (Bumpmap VTF)

Please Help!! :)

82. JackBALLPosted: Dec 29th, 2008 - 7:43:13 am
Hey Nem, how hard would it be to allow mass modification .VMT files?

I need to add the same attributes to 800+ material files. lazy

83. NemPosted: Dec 31st, 2008 - 4:57:35 pm
VTFLib can parse .vmt files. If you know C++ you could use VTFLib to write a program that can do this for you. Depending on what the modification you need is, this might not be too difficult.

84. gtamike_TSGKModified: Jan 4th, 2009 - 3:01:30 pm
Really good work with VTF Edit I use it alot, not sure what I would do with out it. free
Keep up the good work nemesis. skate

85. BlubPosted: Jan 12th, 2009 - 8:34:20 am
If you would add a thumbnail browser (for vtf and tga files) + syntax highlighting and line numbering for the vmt editor it would be perfect!

86. VarsityPosted: Jan 15th, 2009 - 8:00:42 am
It would be great if files could be imported by dragging them onto the app window.

87. hogscraperModified: Mar 4th, 2009 - 10:16:27 pm
I cooked up a method to create recursive vmt files customized to whatever you want. You can use batch file commands to parse for the text you want and replace it but its been a decade since I used this kind of technique and can't remember how.

To create new vmt files you must first delete the old ones if there are any. Then in in your base materials directory create these two files master.bat and function.bat.

Open master.bat and insert this code

for /r %%f in (*.vtf) do call function.bat %%~nf

then inside function.bat insert this code

@echo off&setlocal enableextensions

for %%* in (.) do set MyDir=%%~n*

if not defined MyDir set MyDir=%CD:\=%

echo "LightmappedGeneric" >> %1
echo { >> %1

echo "$basetexture" "%MYDIR%\%1" >> %1
echo } >> %1
ren *. *.vmt


the bits of code that start echo and end >> %1 are the lines where you decide what gets added into the vmt. The format is straight forward
echo codetobeinserted >> %1
If it requires "" just add them, no special parsing stuff, it adds literally whatever you type.
Master.bat looks for any vtf file in the directory where you run the batch then sends each one's name to the function.bat file. Function takes the name and creates a file with the same name. It then inserts the code you told it to and finally renames all the files to .vmt. After it finishes the directory its in it goes through every sub-directory until it can't find any more vtf files.
These bat files will keep the directory structure for all vtf in all sub directories but you may have to edit the ones in the base directory because it sometimes puts in /material/texture instead of just texture...
Hope this is helpful! I had the problem of having my copy of vtfedit add in translucent on all my vmt when i converted a folder. I also needed to add in comments to certain folders' vmt files for my own purposes.

88. bybloPosted: Mar 6th, 2009 - 1:36:36 pm
Is it possible to created animated textures with the VTFCmd.exe ?
I searched for infos but could not find anything about it.

89. XaphanModified: Oct 22nd, 2009 - 9:58:40 am
Is there a simple solution to one side stretching and the other not?
My Vtex compile parameters checked.

Eight Bit Alpha
Clamp S ("clamps" "0")
Clamp T ("clampt" "0")
No Mipmap ("nomip" "0")

I've tested with vtex.dll and VTFEdit and I'm getting the same results.

And this only happens to one side of the in-game radar map.
http://v4servers.com/overview_ss/top.jpg <= incorrect
http://v4servers.com/overview_ss/bottom.jpg <= correct
--
FIXED: My .tga file wasn't correct! FIXED!
Thanks Anyways Great Tool!

90. BoltyPosted: Jan 16th, 2010 - 5:25:46 pm
Hey! I got a little question about this program: Will I be able to compile sprite sheets in vmt with this? I tried it several times with other programs, and searched for the "mksheet.exe" sprite sheet maker in the Source SDK, which is currently non-funcional.
I desperately need to compile one where

91. BrandonPosted: Jul 13th, 2010 - 1:43:09 pm
Because it's already possible to generate normal maps, could SSBump creation be added to VTFEdit, too?

92. youtoolmustbevirusPosted: May 19th, 2011 - 1:54:57 am
I think the trojan horse: rnupgagent.exe must be by this tool.. I shouldn't use this tool because i suspected if it was this or between other programs :(. I hope i get another brand new comp again :(

93. DomIIIModified: May 19th, 2011 - 4:09:42 am
please do not make such false claims. i just checked the installer again and (surprise) it did not install a file named rnupgagent.exe on my system
you must have gotten it from somewhere else :/

94. NemPosted: May 20th, 2011 - 12:03:52 am
There is no Trojan in the installer. Did you get VTFEdit from a third party website? The source code is available here so even the most paranoid of users can build their own executable.

95. SpaceCorePosted: May 29th, 2011 - 2:47:53 am
Combined with GCFScape and a high quality vectorizing tool for upscaling, VTFLib makes a good rattman-scribblings poster maker.

Of course, you DO have to find the overlays first... ._.

96. XaymarModified: Jul 26th, 2011 - 10:58:16 pm
The current x64 binary of VTFEdit is failing on Windows Vista/7 with a SideBySide error:
Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
D:\Program Files\Nem's Tools\VTFEdit\VTFEdit.exe

I think Microsoft is no longer supporting 2005 on Vista and 7...

97. BansheeFndPosted: Apr 19th, 2012 - 5:51:10 pm
Okay, ProblemSolver's Method worked.
Install
http://www.microsoft.com/download/en/details.aspx?id=26347

This will fix both "The application has failed to start because the application configuration is incorrect." and "The application has failed to start because its side-by-side configuration is incorrect." messages on Windows 7 and Windows XP. If you're running 64 bit, Install both 86 and 64. Don't worry about IA64.

98. stevethepocketPosted: Nov 19th, 2012 - 10:04:14 pm
Hey. I did some digging on the developer wiki and found out about NICE filtering. How come VTFLib doesn't offer that as an option alongside the other mipmap rescaling methods? Since it's the default method VTEX uses, it sounds like it would be ideal for matching stock textures. Not to mention signs, which I can't seem to find a good setting for that's sharpened but not too sharpened. (Even Sharpen Soft is too harsh.)

99. NemPosted: Nov 20th, 2012 - 11:01:38 pm
Sine cardinal is more less the same thing.

100. TheLordYugiPosted: May 19th, 2013 - 3:09:36 am
Is possible i use VTFLib in C# to open image to System.Drawing.Bitmap?
sorry for my bad english.

101. NemPosted: May 20th, 2013 - 12:54:04 am
You could create a C++ .Net library and link it to VTFLib then use that to create a class you can use from C#.

102. TheLordYugiPosted: May 20th, 2013 - 12:10:39 pm
thanks, I'll try that.

103. panziPosted: Mar 8th, 2014 - 5:22:27 am
This is very cool! I started with a Linux port of VTFLib:
https://github.com/panzi/VTFLib

I just got it to compile. It's completely untested. I hope I did not break binary compatibility when compiled under Windows. I had to change some types for IO (offset type, size type etc.), but I did this with #ifdefs in stdafx.h so that it should be the same under Windows as it was before (I replaced the seek mode vlUInt with an enum, but that should be compatible).

104. panziPosted: Mar 8th, 2014 - 5:25:19 am
PS: Why did you write your own IO library and did not use std IO streams? Btw. there is an uninitialized member in the MemoryReader, IIRC.

105. panziPosted: Mar 8th, 2014 - 5:27:59 am
Oh and what is this weird ProcReader/ProcWriter good for? Why not just derive IReader/IWriter? Why this strange single global vtable if you can have as many vtables as you like?

106. panziPosted: Mar 8th, 2014 - 4:43:36 pm
Why are there *so many* global variables? Well, why are there *any* global variables. This way this library cannot be used in a multi threading context. I'm not sure if I can use it where I planned it to use it. :/

107. NemPosted: Mar 8th, 2014 - 11:00:35 pm
ProcReader/ProcWriter and the many global variables exist because the library is designed to be used from both a C++ and C interface (you can, for example, use it in .Net with DLL imports).

VTFLib was not designed to be thread safe (there were no multicore CPUs 10 years ago). After a quick look, as long as you instantiate your own CVTFFile instances, and don't set some of the obscure settings outside of initialization, the only thing that is not thread safe is probably VTFLib::LastError. You could possibly declare it with thread local storage (not sure what the TLS restrictions are in Linux) or throw a Mutex into it.

108. panziPosted: Mar 9th, 2014 - 5:36:05 am
Ah, the only global variable that you have to use is LastError. Still, this makes this not thread safe.

Anyway it now works fine under Linux. I also fixed const correctness in some functions (where source data pointers where not const):
https://github.com/panzi/VTFLib

I also wrote a gdk pixbuf loader so that any Gtk+ application can now view VTF files (only one frame, might add animation support when there are >1 frames later):
https://github.com/panzi/pixbufloader-vtf

It would be cool if this could be merged again with the official VTFLib.

109. panziPosted: Mar 9th, 2014 - 5:44:18 am
Just now saw your answer:
Ah I see. I think one can do C bindings without global variables: Cast all object pointers to incomplete struct types and wrap all methods like "vlVTFFileLoadPath(struct c_CVTFFile*, const char *)" and "vlVTFFileLoadBuffer(struct c_CVTFFile*, void*, size_t)" etc. It sure is a lot of wrapping work.

110. panziModified: Mar 9th, 2014 - 7:02:38 pm

111. panziPosted: Mar 9th, 2014 - 7:05:59 pm
Oh and about thread local storage: For non-POD types this only works with C++11 thread_local. Using that would hurt compatibility with MSVC.

112. NemPosted: Mar 10th, 2014 - 4:04:13 am
There's no justifying the design of this library. I wrote it almost 10 years ago when I was still fairly new to programming, and I don't think the Source engine was even multithreaded at the time (if I remember correctly, the Athlon 64 X2 had just came out). The design was loosely based on other popular libraries out around then. Since that time it has mostly only been updated when the VTF format has changed.

If it ever gets refactored, it might be to remove its dependency on the old deprecated NXDXT library. I doubt I'll ever get around to it though.

Thanks for reporting those bugs, I will integrate them back. yeahbaby

113. panziPosted: Mar 10th, 2014 - 10:14:30 pm
Btw. there seems to be a replacement for the NXDXT library:
http://people.freedesktop.org/~cbrill/libtxc_dxtn/

Under Fedora I can install that with "sudo yum install libtxc_dxtn". :)


I tried to keep binary compatibility when compiled for Windows, but I haven't even tried to compile it for Windows. I would only cross-compile it with MinGW anyway. My Linux port theoretically supports Files > 4 GB (-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE make off_t 64bit and bring fseeko and ftello into existence, even under 32bit Linux), if the VTF format would support that. I replaced vlUInt and vlLong with vlSSize ("stream size"), vlSize and vlOffset. Under Windows it should typdef to the same as before, under Linux vlSSize = off_t (signed 64bit), vlSize = size_t (unsigned 32bit or 64bit) and vlOffset = off_t. This means under Windows vlSSize is unsigned and under Linux it is signed. Maybe that is not such a good idea. vlSSize has to be off_t (or something that is at least as big) because that is the type of the st_size field in the stat struct. If functions that return vlSSize fail they return -1 in Linux and 0 in Windows. I think THAT cannot be and I have to change it to 0 everywhere, even though 0 could be a valid value. Or maybe make it vlUInt64 under Windows and also return -1 there (which would break compatibility)? (I just now changed it to 0 everywhere and pushed to github.)

Btw. I also wrote a Qt4 QImageIO plugin based on this:
https://github.com/panzi/qvtf

Next: A KDE plugin, because apparently some (the most important) KDE applications ignore the Qt QImageIO plugin infrastructure and use their own. GIMP also ignores the GDK PixBuf loader infrastructure. Bah.

114. panziPosted: Mar 11th, 2014 - 1:31:31 am
Ok, now I had to make a binary incompatible change to make it compile under certain configurations: I had to add virtual destructors to IReader and IWriter.
https://github.com/panzi/VTFLib/commit/84e19ecd715ac3428118753c888f52929a7bd95f

115. panziPosted: Mar 11th, 2014 - 12:15:10 pm
I don't have time to debug this right now, but is it possible that there is a mixup of the red and blue channel when converting to ARGB8888? (Qt only supports ARGB, not RGBA so I have to use this.)

116. panziPosted: Mar 11th, 2014 - 6:08:54 pm
Or not the red and blue channel but the alpha channel and some other channel. See these example screenshots of the file "materials/paint/prop_paint_orange.vtf" from Portal 2:

Image converted to RGBA (Gdk PixBuf):


Image converted to RGB (Qt):


Image converted to ARGB (Qt):


Image converted to RGBA but I told Qt it is ARGB:

117. panziPosted: Mar 11th, 2014 - 6:12:08 pm
Image converted to BGRA but I told Qt it is ARGB:

Looks pretty broken but it IS orange.

118. panziPosted: Mar 11th, 2014 - 6:59:01 pm
If I do this manually I get the correct images:

Code:


qformat = QImage::Format_ARGB32;
dstformat = IMAGE_FORMAT_RGBA8888;

const vlByte* frame = vtf.GetData(currentFrame, 0, 0, 0);

vlByte* temp = new vlByte[width*height*4];

if (!VTFLib::CVTFFile::Convert(frame, temp, width, height, srcformat, dstformat)) {
qDebug("%s", VTFLib::LastError.Get());
delete[] temp;
return false;
}

*image = QImage(width, height, qformat);
uchar *dest = image->bits();
for (vlUInt y = 0; y < height; ++ y) {
for (vlUInt x = 0; x < width; ++ x) {
dest[y * width * 4 + x * 4 + 0] = temp[y * width * 4 + x * 4 + 2];
dest[y * width * 4 + x * 4 + 1] = temp[y * width * 4 + x * 4 + 1];
dest[y * width * 4 + x * 4 + 2] = temp[y * width * 4 + x * 4 + 0];
dest[y * width * 4 + x * 4 + 3] = temp[y * width * 4 + x * 4 + 3];
}
}

delete[] temp;


Hmm, what does this mean? What is wrong/what is happening?

119. NemPosted: Mar 12th, 2014 - 6:26:12 am
I think you want:
dstformat = IMAGE_FORMAT_BGRA8888;

As QImage::Format_ARGB32 is:
0xAARRGGBB

Which is the opposite order on little endian.

120. panziPosted: Mar 12th, 2014 - 9:40:00 pm
Nem:
I think you want:
dstformat = IMAGE_FORMAT_BGRA8888;

As QImage::Format_ARGB32 is:
0xAARRGGBB

Which is the opposite order on little endian.


I figured so already myself, but when I use this I get the last image I posted. (http://i.imgur.com/GL2GsjB.png) It's orange but looks broken.

121. panziPosted: Mar 13th, 2014 - 2:55:22 am
I currently try to find a replacement for the nvDXTLib. Just for S3TC compression I can use libtxc_dxtn, but that leaves out mipmap generation and image scaling. The
nvidia-texture-tools look like a promising replacement (MIT licensed, used by Unreal Engine 3, blender etc.). It supports mipmap generation, image scaling and S3TC compression, but only supports a fraction of the mipmap filters and no sharpening filters etc. (except I'm missing something). So it's probably ok for basic mipmap generation. But then, the last update is from May 14, 2010. :/

122. EdwardPosted: Jun 6th, 2015 - 1:25:59 pm
Hello, Nem.
Great VTFEdit tool. I'm just wondering if you are willing to add a few extra options like adding or removing frames and custom mipmaps after the fact?

When multiselecting images to be included for animation, I have to be a little extra careful in which order I select them. It would be nice if I could add one at the time if I so pleased, or insert inbetween if I forgot anything.

Also, created a Dot Matrix Display texture, and the automated mipmapping just doesn't look good. Thinking of creating custom mipmaps so that the DMD picture shows up clearer.

/Edward

123. WeaselPosted: Jan 14th, 2017 - 4:05:35 am
Could really use a Linux-equivalent to VTFCmd, to perform command-line and batch VTF image conversions on a headless Linux server.

[ 1 2 ]

Nem's Tools v2.0 © 2006 Ryan Gregg.
Execution time: 0.07963s; Queries: 14.