-
Notifications
You must be signed in to change notification settings - Fork 0
/
textures.py
31 lines (23 loc) · 995 Bytes
/
textures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from . import rat_types
from .stream_helper import (StreamHelper)
from . import utils
import io
from .libs.imageio import v2 as imageio
def convert_dxt_to_png(dxt_buffer):
# Charge l'image DXT à partir du buffer
img = imageio.imread(dxt_buffer, 'dds')
# Convertit l'image en PNG
png_buffer = io.BytesIO()
imageio.imwrite(png_buffer, img, format='png')
png_buffer.seek(0)
# Retourne le buffer de l'image PNG
return png_buffer.getvalue()
class TextureReader:
def __init__(self, stream: StreamHelper, highmip_ptr: rat_types.IGAssetRef, tex_meta: rat_types.IGAssetRef):
stream.seek(texture_ref.offset)
self.ighw_header: rat_types.IGHeader = utils.read_ighw_header(stream)
stream.jump(0x20)
self.ighw_chunks: list[rat_types.IGSectionChunk] = list(utils.read_sections_chunks(self.ighw_header, stream))
### READ TEXTURE METAS ###
stream.seek()
texMeta: rat_types.NewTextMeta = rat_types.NewTextMeta()