Skip to content

A simple C# class that wraps a byte[] from a ".dds" image file and provides helper properties.

License

Notifications You must be signed in to change notification settings

jmschrack/DDS-Image-Wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DDS-Image-Wrapper

A simple C# class that wraps a byte[] from a ".dds" image file and provides helper properties for easy access to header data.

Sample Usage

DDSImage image = new DDSImage(System.IO.File.ReadAllBytes("Grasslands.dds"));
Console.WriteLine(string.Format("Loaded Image: {0}x{1}  Format:{2}",image.Width,image.Height,image.GetPixelFormatFourCC().ToString()));

Unity3D Extensions

Add the PVRUnityExtensions.cs class to your Unity Project to enable the following convenience methods.

  • LoadIntoTexture() : Returns Texture2D
  • GetTextureFormat() : Returns UnityEngine.TextureFormat
  • IsValidTextureFormat() : Returns TRUE if the PixelFormat can be mapped to a UnityEngine.TextureFormat

When, where, or why would I use this in Unity?

If your project is loading images at runtime for use as textures, using a preformatted image allows you to skip the slow ImageConversion step. For my use case, 30 jpg images took ~30s to load total. 30 DDS images (precompressed to DXT5) took ~1s to load. Obviously, your mileage may vary.

Alternatively, check out the PVR Image format. I wrote a wrapper for it here: PVR-Image-Wrapper

FourCC class taken from Vasili Maslov's SharpAVI project.

About

A simple C# class that wraps a byte[] from a ".dds" image file and provides helper properties.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages