Guest Posted October 6, 2018 Posted October 6, 2018 added to github a super easy nuub friendly decompressing skyrim SE dds bc7 unorm programming just a few lines and how to convert the pixels to another format and saving it. in this case i choosed qimage wich expands to 1000 other formats for someone thats not as lazy as me can prolly do something usefull with this . U need qt5 DeVIL and directTEX libs/dlls to compile it. but anyway its super simple formula(tut) and even a turd can understand it to i dunno.. convert it to another languages? skyrim-se-ddsbc7compressed if ure to lazy to check the github just look at this cute code piece #include <iostream> #include <stdio.h> #include <assert.h> #include <math.h> #include <float.h> #include "IL/il.h" #include "IL/ilu.h" // #include <float.h> #include <string.h> // memset, memcpy #include <d3d11.h> #include <d3d10.h> #include "DirectXTex.h" #include "QtWidgets/qapplication.h" #include "QtGui/qimage.h" #include "QtGui/qpixmap.h" struct rgba_t { unsigned char red; unsigned char green; unsigned char blue; unsigned char alpha; }; void copypix(const DirectX::Image* img) { size_t w=img->width; size_t h=img->height; const uint8_t* pPixels = img->pixels;/*<pointer to pixel data>*/; uint32_t PixelIndex = 0; QImage* qimg = new QImage(w, h, QImage::Format_RGB888); qimg->fill(QColor(Qt::white).rgb()); for (size_t y = 0; y < img->height; ++y) { for (size_t x = 0; x < img->width; ++x) { rgba_t ColorBuffer; ColorBuffer.red = pPixels[PixelIndex]; ColorBuffer.green = pPixels[PixelIndex + 1]; ColorBuffer.blue = pPixels[PixelIndex + 2]; ColorBuffer.alpha = pPixels[PixelIndex + 3]; // Advance pPixels += 4; qimg->setPixel(x, y, qRgb(ColorBuffer.red, ColorBuffer.green, ColorBuffer.blue)); } } qimg->save("femalehead.png"); } void loadFile() { std::unique_ptr<DirectX::ScratchImage> image(new (std::nothrow) DirectX::ScratchImage); DirectX::TexMetadata info; HRESULT res = DirectX::LoadFromDDSFile(L"femalehead.dds", DirectX::DDS_FLAGS_NONE, &info, *image); if (SUCCEEDED(res)) { std::unique_ptr<DirectX::ScratchImage> cimage; if (DirectX::IsCompressed(info.format)) { std::cout << "compressed" << std::endl; auto img = image->GetImage(0, 0, 0); size_t nimg = image->GetImageCount(); std::unique_ptr<DirectX::ScratchImage> timage(new (std::nothrow) DirectX::ScratchImage); HRESULT hr = DirectX::Decompress(img, nimg, info, DXGI_FORMAT_UNKNOWN , *timage); if (FAILED(hr)) { wprintf(L" FAILED [decompress] (%x)\n", hr); } else { std::cout << "decompressed succesfully" << std::endl; auto& tinfo = timage->GetMetadata(); info.format = tinfo.format; info.width == tinfo.width; info.height == tinfo.height; info.depth == tinfo.depth; info.arraySize == tinfo.arraySize; info.mipLevels == tinfo.mipLevels; info.miscFlags == tinfo.miscFlags; info.dimension == tinfo.dimension; image.swap(timage); cimage.reset(); auto limg = image->GetImage(0, 0, 0); copypix(limg); //HRESULT hr = DirectX::SaveToTGAFile(limg[0], L"test.tga"); } } std::cout << "" << std::endl; } } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); //ilInit(); //iluInit(); loadFile(); return a.exec(); system("PAUSE"); }
LGmobile Posted October 30, 2018 Posted October 30, 2018 Yo i might be a turd but we probably need a little bit more information of what is going on... you can't just post a piece of code and say yo do whatever you want with this... I don't understand what the goal of this post is, i assume you're not an native english speaker, but try to explain a bit better what you want & what the program does exactly...
Grummkol Posted October 31, 2018 Posted October 31, 2018 Easier way would be to download texconv from https://github.com/Microsoft/DirectXTex/releases and then use that to convert to/from BC7 to R8G8B8A8 for editing. e.g texconv -f BC7_UNORM -y *_msn.dds or texconv -f R8G8B8A8_UNORM -y *.dds You can also use batch commands and the for /r loop to cycle through all subdirectories
Recommended Posts
Archived
This topic is now archived and is closed to further replies.