mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
feat: dds stream
This commit is contained in:
1 parent
2f650af0f7
commit
cd546b274f
10 files changed
+178
-154
No files matched your search
@@ -1,21 +1,29 @@
|
||||
import { existsSync } from 'fs';
|
||||
import sharp from 'sharp';
|
||||
import { readDVPLFile } from '../blitz/readDVPLFile';
|
||||
import { ToJpgOptions, toJpg } from './toJpg';
|
||||
import { DdsStream } from '../streams/dds';
|
||||
import { ToJpgOptions } from './toJpg';
|
||||
|
||||
export async function readTexture(
|
||||
path: string,
|
||||
options?: Partial<Omit<ToJpgOptions, 'format'>>,
|
||||
) {
|
||||
const ddsTexturePath = path.replace('.tex', '.dx11.dds.dvpl');
|
||||
const isDds = existsSync(ddsTexturePath);
|
||||
const resolvedTexturePath = isDds
|
||||
? ddsTexturePath
|
||||
: ddsTexturePath.replace('.dds', '.pvr');
|
||||
const decompressedTexture = await readDVPLFile(resolvedTexturePath);
|
||||
const jpg = await toJpg(decompressedTexture, {
|
||||
...options,
|
||||
format: isDds ? 'dds' : 'pvr',
|
||||
});
|
||||
const decompressedDvpl = await readDVPLFile(ddsTexturePath);
|
||||
const stream = new DdsStream(decompressedDvpl);
|
||||
const ddsRaw = await stream.dds();
|
||||
const png = await sharp(ddsRaw.data, { raw: ddsRaw }).png().toBuffer();
|
||||
|
||||
return jpg;
|
||||
return png;
|
||||
|
||||
// const isDds = existsSync(ddsTexturePath);
|
||||
// const resolvedTexturePath = isDds
|
||||
// ? ddsTexturePath
|
||||
// : ddsTexturePath.replace('.dds', '.pvr');
|
||||
// const decompressedTexture = await readDVPLFile(resolvedTexturePath);
|
||||
// const jpg = await toJpg(decompressedTexture, {
|
||||
// ...options,
|
||||
// format: isDds ? 'dds' : 'pvr',
|
||||
// });
|
||||
|
||||
// return jpg;
|
||||
}
|
||||
Reference in new issue
Block a user