home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 20233 / fmt_D2R_sprite.7z / fmt_D2R_sprite.py
Encoding:
Python Source  |  2021-05-31  |  1.4 KB  |  78 lines

  1. from inc_noesis import *
  2.  
  3.  
  4.  
  5. def registerNoesisTypes():
  6.  
  7.  
  8.     handle = noesis.register("Diablo II: Resurrected sprite", ".sprite")
  9.     noesis.setHandlerTypeCheck(handle, noepyCheckType)
  10.     noesis.setHandlerLoadRGBA(handle, D2RLoadSprite)
  11.  
  12.  
  13.     noesis.logPopup()
  14.     return 1
  15.     
  16.  
  17. def noepyCheckType(data):
  18.     return 1
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. def D2RLoadSprite(data, texList):
  27.  
  28.     MipData = []
  29.     imgData = [] 
  30.     bs = NoeBitStream(data)
  31.     
  32.  
  33.  
  34.     
  35.     bs.seek(0x6, NOESEEK_ABS)
  36.     unk1 = bs.readUShort()
  37.     print("unk1 " + str(unk1))
  38.     
  39.     bs.seek(0x8, NOESEEK_ABS)
  40.     t_width = bs.readUInt()
  41.     print("t_width " + str(t_width))    
  42.     
  43.     bs.seek(0xc, NOESEEK_ABS)
  44.     t_height = bs.readUInt()
  45.     print("t_height " + str(t_height))    
  46.  
  47.     bs.seek(0x10, NOESEEK_ABS)
  48.     unk4 = bs.readUInt()
  49.     print("unk4 " + str(unk4))        
  50.     
  51.     bs.seek(0x14, NOESEEK_ABS)
  52.     unk5 = bs.readUInt()
  53.     print("unk5 " + str(unk5))        
  54.     
  55.     bs.seek(0x20, NOESEEK_ABS)
  56.     RawSize = bs.readUInt()
  57.     print("RawSize " + str(RawSize))    
  58.     
  59.     
  60.     bs.seek(0x24, NOESEEK_ABS)
  61.     unk6 = bs.readUInt()
  62.     print("unk6 " + str(unk6))
  63.  
  64.     bs.seek(0x24, NOESEEK_ABS)
  65.     RawData = bs.readBytes(RawSize)
  66.     ddsData = rapi.imageDecodeRaw(RawData, t_width, t_height, "r8g8b8a8")
  67.     
  68.     
  69.     texFmt = noesis.NOESISTEX_RGBA32
  70.     tex1 = (NoeTexture(rapi.getInputName(), t_width, t_height, ddsData, texFmt))    
  71.     texList.append(tex1)
  72.     print("")
  73.     print("")    
  74.     return 1        
  75.     
  76.     
  77.     
  78.