home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 14645 / tex_NeighboursFromHell_tga.7z / tex_NeighboursFromHell_tga.py
Encoding:
Python Source  |  2018-07-22  |  1.0 KB  |  33 lines

  1. #source: http://forum.xentax.com/viewtopic.php?f=18&t=18243
  2. from inc_noesis import *
  3.  
  4. def registerNoesisTypes():
  5.     handle = noesis.register("Neighbours From Hell", ".tga")
  6.     noesis.setHandlerTypeCheck(handle, noepyCheckType)
  7.     noesis.setHandlerLoadRGBA(handle, noepyLoadRGBA)
  8.     #noesis.logPopup()
  9.     return 1
  10.  
  11. def noepyCheckType(data):
  12.     bs = NoeBitStream(data)
  13.     global mode
  14.     testData = bs.readBytes(18)
  15.     if testData.find(b'\x10\x24',16,18) != -1:
  16.         mode = "b4 g4 r4 a4"
  17.     elif testData.find(b'\x10\x20',16,18) != -1:
  18.         mode = "b5 g6 r5"
  19.     else:
  20.         return 0
  21.     return 1
  22.     
  23. def noepyLoadRGBA(data, texList):
  24.     bs = NoeBitStream(data)
  25.     global mode
  26.     bs.seek(0xc, 0)
  27.     imgWidth = bs.readUShort()
  28.     imgHeight = bs.readUShort()
  29.     bs.readShort()
  30.     data = bs.readBytes(bs.getSize() - bs.tell())
  31.     data = rapi.imageDecodeRaw(data, imgWidth, imgHeight, mode)
  32.     texList.append(NoeTexture(rapi.getInputName(), imgWidth, imgHeight, data, noesis.NOESISTEX_RGBA32))
  33.     return 1