Foreword
I was looking for a way to display textures from Grim Dawn properly for a long time now and had a really hard time getting on with it which is why I started this project.
The idea is to provide an easy-to-use library that allows displaying the .tex and .dds files from Grim Dawn as I want to prevent you guys from getting frustrated the same way I did.
The library is written in C#, using Visual Studio Express 2013 for desktop.
Usage (Visual Studio)
Adding a reference to your project
- Right click “references” in your project explorer
- Choose “Add reference”
- Choose “browse” on the left of the window that should now appear.
- Choose “browse” on the lower right of the window
- Navigate to “GDImageLibrary.dll” and double click it.
- If you did everything right, it should look like this:
- Now click “ok”. You now should be able to use the GDImageLibrary.
- To add it as namespace, add it to your code like this:
Code Summary
GDImage
ImageBuild Method
The ImageBuild Method builds an object of the type “Bitmap” from a byte array that holds the pixels of an image. It also requires the width and height of the image.
Bitmap bm = GDImage.ImageBuild(byte[] PixelArray, int ImageWidth, int ImageHeight);
ConvertIntArrayToByteArray Method
The ConvertIntArrayToByteArray method converts, as the name says, an integer array to a byte array.
byte[] ByteArray = GDImage.ConvertIntArrayToByteArray(int[] IntArray);
GDImageLibrary._Tex
ConvertTexToDDs Method
The ConvertTexToDDs method converts a .tex file to a .dds file and returns an array of bytes containing the whole image file.
byte[] DDsFile = GDImageLibrary._TEX.ConvertTexToDDS(string Textfile);
Overload:
byte[] DDsFile = GDImageLibrary._TEX.ConvertTexToDDS(byte[] TexFileContent);
LoadTexImage Method
The LoadTexImage method loads a .tex file and returns a bitmap for easy displaying of .tex files.
Bitmap bm = GDImageLibrary._TEX.LoadTexImage(string Texfile);
Overload:
Bitmap bm = GDImageLibrary._TEX.LoadTexImage(byte[] TexFileContent);
GetTexFileWidth Method
The GetTexFileWidth method returns an integer that declares the width of a .tex file.
int Width = GDImageLibrary._TEX.GetTexFileWidth(string Texfile);
Overload:
int Width = GDImageLibrary._TEX.GetTexFileWidth(byte[] TexFileContent);
GetTexFileHeight Method
The GetTexFileHeight Method returns an integer that declares the height of a .tex file.
int Height = GDImageLibrary._TEX.GetTexFileHeight(string Texfile);
Overload:
int Height = GDImageLibrary._TEX.GetTexFileHeight(byte[] TexFileContent);
SaveAsDDS Method
The SaveAsDDS method saves a .tex file as a .dds file.
GDImageLibrary._TEX.SaveAsDDS(string texfile, bool overwrite);
Overload:
GDImageLibrary._TEX.SaveAsDDS(string texfile, string DDsFileName, bool overwrite);
GDImageLibrary._DDS
LoadImage Method
The LoadImage method loads a .dds file and returns an object of the type “bitmap” for easy displaying of .dds files.
Bitmap bm = GDImageLibrary._DDS.LoadImage(string DDsFile);
Overload:
Bitmap bm = GDImageLibrary._DDS.LoadImage(byte[] DDsFileContent);
GetFileWidth Method
The GetFileWidth method returns an integer that declares the width of a .dds file.
int Width = GDImageLibrary._DDS.GetFileWidth(string DDsfile);
Overload:
int Width = GDImageLibrary._DDS.GetFileWidth(byte[] DDsFileContent);
GetFileHeight Method
The GetFileHeight method returns an integer that declares the height of a .dds file.
int Width = GDImageLibrary._DDS.GetFileHeight(string DDsfile);
Overload:
int Width = GDImageLibrary._DDS.GetFileHeight(byte[] DDsFileContent);
Special Thanks
- Special thanks to Tamschi for providing his TQ.Texture library under the GPL and not getting tired of answering my questions
- Special thanks to Mamba for pointing me torwards the DDSReader Class (see below) and offering some sample code
- Special thanks to Kenji Sasaki for providing his DDSReader class under the MIT license.
Please let me know if there are any problems / wishes for future updates.
Since this is the first ever library that I release it might be that there are a few things I didn’t think about and therefore didn’t discover which could result in not intended problems.
Attachment: GDImageLibrary.zip
Attachment: GDImageLibrary Source.zip
Attachment: c010_axe.png