AceWell wrote:TjVatio wrote:so, i got lost to convert back my edited image to .TEX, i have to use the same program?
no, you have to break it back down to paletted data and retwiddle to rebuild it, i can't help with this.
i tried making a Noesis python script to open the TEX files but i can't get the result like the one in "Console Texture Explorer".

i don't like sad pals. you forgot something.

i borrowed some code from
there and unshuffled this bitch, ps2 style.
![Satisfied :]](./images/smilies/%5Bcolon%5D%5D.gif)
you gotta do the pointer dance.
Code: Select all
from inc_noesis import *
import noesis
import rapi
def registerNoesisTypes():
handle = noesis.register("50cent Bulletproof TEX Textures", ".tex")
noesis.setHandlerTypeCheck(handle, TEXCheckType)
noesis.setHandlerLoadRGBA(handle, TEXLoadRGBA)
#noesis.logPopup()
return 1
def TEXCheckType(data):
return 1
def TEXLoadRGBA(data, texList):
bs = NoeBitStream(data)
filename = bs.read("32B")
hash = bs.readInt()
width = bs.readUShort()
height = bs.readUShort()
#dummy1 = bs.readUByte()
size_bmapdata = width * height #bs.readUInt()
#print(str(size_bmapdata))
#dummy2 = bs.readUByte()
#ofs_palette = bs.readUInt()
bs.seek(0x40, NOESEEK_ABS)
texData = bs.readBytes(size_bmapdata)
#bs.seek(ofs_palette + 0x40, NOESEEK_ABS)
palData = []
for x in range(8):
for p in range(32):
read = bs.readUByte()
palData.append(read)
bs.seek(32, NOESEEK_REL)
for p in range(32):
read = bs.readUByte()
palData.append(read)
bs.seek(-64, NOESEEK_REL)
for p in range(32):
read = bs.readUByte()
palData.append(read)
bs.seek(32, NOESEEK_REL)
for p in range(32):
read = bs.readUByte()
palData.append(read)
palData = bytearray(palData)
pic = rapi.imageUntwiddlePS2(texData, width, height, 8)
pic = rapi.imageDecodeRawPal(pic, palData, width, height, 8, "r8g8b8a8")
texList.append(NoeTexture(str(filename), width, height, pic, noesis.NOESISTEX_RGBA32))
return 1
butchered and commented out are data pointer safeguards. assuming the layout is always aligning the image followed by the pallette without padding.
reversing is not possible like that. you'd need to explicit export a indexed bitmap with a palette. tga does that. and you gotta reshuffle the palette the same way. the twiddlePS2 should work as it is tho.