Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] DXT decompress in C#

Started by xmen Oct 4, 2007 at 10:35 PM 2 replies 5.1k views
Original Post
xmen
xmen
hi there, i wanna decompress a dxt1 file, and dxt3 and 5 as well can someone tell how?
windozer1
windozer1
How about using the TextureLoader.FromFile method? This will return a Microsoft.DirectX.Direct3D.Texture. It's in the Microsoft.DirectX.Direct3D namespace. You can pass in the format of the file (DXT1, DXT3, etc).

Cale
xmen
xmen
can you please explain it in an example
just a little one
windozer1
windozer1
using System;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace DemoGame
{
public class CGameObject
{
private Texture texture;
private Device device;

public CGameObject(Device gDevice, filePath)
{
try
{
texture = TextureLoader.FromFile(gDevice, filePath, 0, 0,
0, 0, Dxt1, Default, Triangle,
Linear, 0);

}
catch(Exception ex)
{
// add error handling
}
}
}
}

There are different overloads for TextureLoader.FromFile. The parameters used are as such:

1) gDevice (graphics device object)
2) filePath (string of path to file)
3) 0 (width of texture/zero means get dimension from file)
4) 0 (height of texture/zero means get dimension from file)
5) 0 (mipLevels / zero means gen full mip chain)
6) 0 (usage / zero if regular texture)
7) Dxt1 (Microsoft.DirectX.Direct3D.Format)
8) Default (memory pool to use)
9) Triangle (filter for image - triangle is same as anisotropic)
10)Linear (filter for mipLevel)
11)ColorKey (use to specify value to replace transparent black with/zero disables)

Obviously you should check device caps for things like mip level support and filters) Hope this helps. Thanks.

Cale

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.