Welcome
Ladies and Gents:

These forums are now closed and registration disabled.

Please join us at our new forum on Proboards. Our hope is that these new forums are more stable, provide more and better features, and allow continuation of the project forums in a safer, more secure, long term environment.

me3explorer.proboards.com

--The ME3Explorer Team

How to use DDSImage

Coder-centric area for programming advice and questions.

How to use DDSImage

Postby AmaroK86 » 19 Apr 2013, 09:55

For programmers who wants to display dds images without using external programs like readdxt.exe, here's what you have to do to correctly use DDSImage:

first of all, include AmaroK86.ImageFormat in your project
Code: Select all
using AmaroK86.ImageFormat;


- You want to load a dds file image?
Code: Select all
// loads an image
string ddsFileName = "C:/an_image.dds";
DDSImage ddsImage = new DDSImage(ddsFileName);

PictureBox picBox = .... // initialize your picturebox
// now loads the image that best fits inside picBox,
// f.e. if picBox is 230x210 and dds has mipmaps (512x512, 256x256.... 4x4),
// ToPictureBox(...) will return a Bitmap of 256x256.
picBox.Image = ddsImage.ToPictureBox(picBox.Width, picBox.Height);

- You have a byte[] data of a specific image (most probably extracted from tfc archive) and don't want to create an instance of DDSImage?
Code: Select all
byte[] imageData = ... // image data (in this example you know that's a 1024x512 DXT1 image, IT MUSN'T HAVE MIPMAPS!)
DDSFormat ddsFormat = DDSFormat.DXT1 // other selections might be .DXT5 or .V8U8
Bitmap aBitmap = DDSImage.ToBitmap(imageData, ddsFormat, 1024, 512);
picBox.Image = aBitmap;


Enjoy it!
My multiplayer ID: AmaroK86_64

AmaroK86 has been thanked by:
User avatar
AmaroK86
Emeritus
 
Posts: 66
Joined: 22 Aug 2012, 12:51
Has thanked: 25 time
Have thanks: 36 time

Return to Coders' Help

Who is online

Users browsing this forum: No registered users and 0 guests

suspicion-preferred