本文整理汇总了Python中mmfparser.bytereader.ByteReader类的典型用法代码示例。如果您正苦于以下问题:Python ByteReader类的具体用法?Python ByteReader怎么用?Python ByteReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ByteReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_fonts
def write_fonts(out, fonts):
fp = open(out, 'wb')
writer = ByteReader(fp)
writer.writeInt(len(fonts))
for font in fonts:
font.write(writer)
fp.close()
示例2: convert
def convert(reader):
newReader = ByteReader()
for i in xrange(len(reader)):
value = reader.readByte(True)
value = ~(value - i % 256) % 256
newReader.writeByte(value, True)
newReader.seek(0)
return newReader
示例3: write_preload
def write_preload(self, images):
self.fp.seek(self.use_count_offset)
data = ByteReader()
for handle in images:
data.writeShort(handle, True)
for handle in xrange(self.image_count):
if handle in images:
continue
data.writeShort(handle, True)
self.fp.write(str(data))
示例4: get_shader
def get_shader(self, name, vert, frag):
writer = ByteReader()
writer.writeInt(len(vert))
writer.write(vert)
writer.writeInt(len(frag))
writer.write(frag)
return str(writer)
示例5: read_runinfo
def read_runinfo(data):
info = {}
reader = ByteReader(data)
count = reader.readInt(True)
for _ in xrange(count):
name = reader.read(reader.readInt(True))
alts = {}
for i in xrange(26):
alts[i] = reader.readByte(True)
info[name] = alts
return info
示例6: get_shader
def get_shader(self, name, vert, frag):
vert = translate_shader_data(vert, 'vertex', 'gles')
frag = translate_shader_data(frag, 'fragment', 'gles')
writer = ByteReader()
writer.writeInt(len(vert))
writer.write(vert)
writer.writeInt(len(frag))
writer.write(frag)
return str(writer)
示例7: read
def read(self, reader):
self.handle = reader.readInt(True)
self.checksum = reader.readInt()
self.references = reader.readInt()
decompressedLenght = reader.readInt()
self.flags.setFlags(reader.readInt(True))
reserved = reader.readInt()
nameLenght = reader.readInt()
if self.settings.get('compressed', True):
size = reader.readInt()
data = ByteReader(zlib.decompress(reader.read(size)))
else:
data = reader.readReader(decompressedLenght)
self.name = self.readString(data, nameLenght)
self.data = data.read()
示例8: write
def write(self, reader):
reader.writeShort(self.objectType)
reader.writeShort(self.num)
if self.objectType == 0 and self.num == 0:
return
dataReader = ByteReader()
if (self.objectType in expression_system
and self.num in expression_system[self.objectType]):
self.loader.write(dataReader)
elif self.objectType >= 2 or self.objectType == -7:
dataReader.writeShort(self.objectInfo, True)
dataReader.writeShort(self.objectInfoList)
if self.num in expression_extension:
self.loader.write(dataReader)
reader.writeShort(len(dataReader) + 6, True)
reader.writeReader(dataReader)
示例9: read
def read(self, reader):
debug = self.settings.get('debug', False)
old = self.settings.get('old', False)
if debug:
path = reader.readString()
reader = ByteReader(open(path, 'rb'))
reader.skipBytes(4)
numberOfItems = reader.readInt()
if old:
klass = OldFont
else:
klass = FontItem
self.items = [self.new(klass, reader)
for _ in xrange(numberOfItems)]
示例10: Workspace
class Workspace(DataLoader):
name = ''
data = None
def initialize(self):
size = self.settings.get('defaultSize', 0)
self.data = ByteReader()
self.data.write('\x00' * size)
def read(self, reader):
self.name = reader.readString()
self.data = reader.readReader(reader.readInt(True))
def write(self, reader):
reader.writeString(self.name)
reader.writeInt(len(self.data))
reader.writeReader(self.data)
示例11: compress
def compress(data):
reader = ByteReader()
compressed = zlib.compress(str(data))
reader.writeInt(len(data))
reader.writeInt(len(compressed))
reader.write(compressed)
return reader
示例12: add_sound
def add_sound(self, name, ext=None, data=None):
if ext is None:
audio_type = NONE_TYPE
else:
audio_type = AUDIO_TYPES.get(ext, NATIVE_TYPE)
index = len(self.sounds)
sound_id = get_asset_name('SOUND', name, index)
self.sound_ids[name.lower()] = sound_id
self.header.putdefine(sound_id, index)
writer = ByteReader()
writer.writeInt(audio_type)
if data:
writer.writeIntString(data)
self.sounds.append(str(writer))
示例13: add_image
def add_image(self, hot_x, hot_y, act_x, act_y, data):
writer = ByteReader()
writer.writeShort(hot_x)
writer.writeShort(hot_y)
writer.writeShort(act_x)
writer.writeShort(act_y)
writer.writeIntString(data)
self.images.append(str(writer))
示例14: write_runinfo
def write_runinfo(info):
writer = ByteReader()
writer.writeInt(len(info), True)
for k, v in info.iteritems():
writer.writeInt(len(k), True)
writer.write(k)
for i in xrange(26):
reader.writeByte(v[i], True)
示例15: get_shader
def get_shader(self, name, vert, frag):
vert_path = os.path.join(SHADERS_DIR, name + '.vsb')
frag_path = os.path.join(SHADERS_DIR, name + '.psb')
with open(vert_path, 'rb') as fp:
vert_data = fp.read()
with open(frag_path, 'rb') as fp:
frag_data = fp.read()
writer = ByteReader()
writer.writeInt(len(vert_data))
writer.write(vert_data)
writer.writeInt(len(frag_data))
writer.write(frag_data)
return str(writer)