andburn / dds-reader

.NET core DDS reader and converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integration

vmv opened this issue · comments

commented

Hi,
I want to use your code in another application that has a very old dds reader and is not updated or working anymore...
The question is how do i use your app into this function, how to call it:

private void DDSFile(FileRecord selectedRecord)
{
    var buffer = selectedRecord.ReadData(path);
    ImageOutput.Visibility = Visibility.Visible;
    //var dds = new DDSImage(buffer);
    using (var ms = new MemoryStream())
    {
        //dds.ddsImage[0].Save(ms, ImageFormat.Png);
        var bmp = new BitmapImage();
        bmp.BeginInit();
        bmp.CacheOption = BitmapCacheOption.OnLoad;
        bmp.StreamSource = ms;
        bmp.EndInit();
        ImageOutput.Source = bmp;
    }
} 

Old calls are commented.
Thank you in advance for any small help.

I think the following changes should work for you. I can't tell what type buffer is exactly, but I guess its a byte[] so should be fine.

using Imaging.DDSReader; // <--

private void DDSFile(FileRecord selectedRecord)
{
    var buffer = selectedRecord.ReadData(path);
    ImageOutput.Visibility = Visibility.Visible;
    var dds = DDS.LoadImage(buffer); // <--
    using (var ms = new MemoryStream())
    {
        dds.Save(ms, ImageFormat.Png); // <--
        var bmp = new BitmapImage();
        bmp.BeginInit();
        bmp.CacheOption = BitmapCacheOption.OnLoad;
        bmp.StreamSource = ms;
        bmp.EndInit();
        ImageOutput.Source = bmp;
    }
} 
commented

I get this and other error no matter how i try:....Details: Object reference not set to an instance of an object.
The "buffer" is byte[] yes.

This is the program that i want to integrate it: https://github.com/vmv/VisualGGPK/tree/master/VisualGGPK

Thank you,..

I'm not sure, it looks like it should work. I don't have PoE to test it out, sorry.