pvr header
This commit is contained in:
parent
2105e6aaba
commit
6d199d5a21
@ -28,6 +28,34 @@ import struct
|
||||
|
||||
class NinjaTexture: # {
|
||||
|
||||
# Color Formats
|
||||
ARGB_1555 = 0x00
|
||||
RGB_565 = 0x01
|
||||
ARGB_4444 = 0x02
|
||||
YUV_422 = 0x03
|
||||
BUMP = 0x04
|
||||
RGB_555 = 0x05
|
||||
ARGB_8888 = 0x06
|
||||
YUV_420 = 0x06
|
||||
|
||||
# Data Formats
|
||||
TWIDDLED = 0x01
|
||||
TWIDDLED_MM = 0x02
|
||||
VQ = 0x03
|
||||
VQ_MM = 0x04
|
||||
PALETTIZE4 = 0x05
|
||||
PALETTIZE4_MM = 0x06
|
||||
PALETTIZE8 = 0x07
|
||||
PALETTIZE8_MM = 0x08
|
||||
RECTANGLE = 0x09
|
||||
STRIDE = 0x0B
|
||||
TWIDDLED_RECTANGLE = 0x0D
|
||||
ABGR = 0x0E
|
||||
ABGR_MM = 0x0F
|
||||
SMALLVQ = 0x10
|
||||
SMALLVQ_MM = 0x11
|
||||
TWIDDLED_MM_ALIAS = 0x12
|
||||
|
||||
def __init__(self, filename): # {
|
||||
|
||||
# File Information
|
||||
@ -79,7 +107,7 @@ class NinjaTexture: # {
|
||||
if flags & 0x04:
|
||||
bytes = self.file.read(2)
|
||||
p = struct.unpack('H', bytes)
|
||||
tex['format'] = p[0]
|
||||
tex['format'] = p[0] >> 8
|
||||
if flags & 0x02:
|
||||
bytes = self.file.read(2)
|
||||
p = struct.unpack('H', bytes)
|
||||
@ -110,4 +138,30 @@ class NinjaTexture: # {
|
||||
|
||||
def readPvr(self, info):
|
||||
print(info)
|
||||
|
||||
# Read Header
|
||||
bytes = self.file.read(8)
|
||||
p = struct.unpack('BBHHH', bytes)
|
||||
color_format = p[0]
|
||||
data_format = p[1]
|
||||
width = p[3]
|
||||
height = p[4]
|
||||
print("Color Format: %d" % color_format)
|
||||
print("Data Format: %d" % data_format)
|
||||
print("Width: %d" % width)
|
||||
print("Height: %d" % height)
|
||||
|
||||
self.isTwiddled = False
|
||||
self.isMipmap = False
|
||||
|
||||
twiddled = (
|
||||
NinjaTexture.TWIDDLED,
|
||||
NinjaTexture.TWIDDLED_MM,
|
||||
NinjaTexture.TWIDDLED_RECTANGLE,
|
||||
NinjaTexture.TWIDDLED_MM_ALIAS
|
||||
)
|
||||
|
||||
if data_format in twiddled:
|
||||
self.isTwiddled = True
|
||||
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user