本文整理汇总了Python中bitstring.ConstBitStream.bytepos方法的典型用法代码示例。如果您正苦于以下问题:Python ConstBitStream.bytepos方法的具体用法?Python ConstBitStream.bytepos怎么用?Python ConstBitStream.bytepos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bitstring.ConstBitStream
的用法示例。
在下文中一共展示了ConstBitStream.bytepos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extractXMP
# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import bytepos [as 别名]
def extractXMP(self, filename):
xmpStr = ""
# Can initialise from files, bytes, etc.
try:
s = ConstBitStream(filename = filename)
# Search for ":xmpmeta" string in file
keepSearching = True
while keepSearching:
keepSearching = False
colonXmpmetaInHexStr = '0x3a786d706d657461'
foundSt = s.find(colonXmpmetaInHexStr, bytealigned=True)
if foundSt:
byteStart = (int(foundSt[0])//8)
# The start of data can be "<xmp:xmpmeta" or "<x:xmpmeta"
s.bytepos = byteStart - 4
prevals = s.peeklist("4*uint:8")
prestr = ''.join(chr(i) for i in prevals)
# print (prestr, prestr[2:])
if prestr == "<xmp":
byteStart = byteStart - 4
prefix = "0x3c2f786d70" # "<\xmp" in hex
elif prestr[2:] == "<x":
byteStart = byteStart - 2
prefix = "0x3c2f78" # "<\x" in hex
else:
# print ("Cont")
keepSearching = True
continue
# print("Found start code at byte offset %d." % byteStart)
foundEnd = s.find(prefix + colonXmpmetaInHexStr, bytealigned=True)
if foundEnd:
byteEnd = (int(foundEnd[0])//8)
s.bytepos = byteStart
# print("Found end code at byte offset %d." % byteEnd)
xmpBytes = s.readlist(str(byteEnd-byteStart+len(prefix)//2+9) +"*uint:8")
xmpStr = ''.join(chr(i) for i in xmpBytes)
#if "Rating" in xmpStr:
# print (xmpStr)
except:
xmpStr = ""
return xmpStr
示例2: png_to_gim
# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import bytepos [as 别名]
def png_to_gim(self, png_file, gim_file=None, quant_type=QuantizeType.auto):
# So there's no confusion.
png_file = os.path.abspath(png_file)
if gim_file == None:
gim_file = os.path.splitext(png_file)[0] + ".gim"
png_file = self.quantize_png(png_file, quant_type)
data = ConstBitStream(filename=png_file)
data.bytepos = 0x18
options = ["-jar", "tools/gimexport.jar", png_file, gim_file, "3"]
depth = data.read("int:8")
color_type = data.read("int:8")
if color_type == 3: # Indexed
options.append("true")
else:
options.append("false")
self.process.start("java", options)
self.process.waitForFinished(-1)
示例3: print
# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import bytepos [as 别名]
print("Found movi signature at byte offset %X" % moviOffset)
else:
print "Signature movi not found"
print ("Current bytepos %X" % s.bytepos)
foundIdx1Offset = s.find('0x69647831', bytealigned=True)
if foundIdx1Offset:
idx1Offset = foundIdx1Offset[0] / 8
print("Found idx1 signature at byte offset %X" % idx1Offset)
else:
print "Signature idx1 not found"
print ("Current bytepos %X" % s.bytepos)
found01dcOffset = s.findall('0x30316463', bytealigned=True)
for i in found01dcOffset:
i = (i /8) + 8
print("%X" % i)
s.bytepos = i
print s.bytepos
timeStamp = s.read(64).bin
print timeStamp
print ("Time is %d" % timeStamp)
# print filetime_to_dt(timeStamp)
# s.bytepos = i + 4
# print s.bytepos
# timelow = s.read(32).Q
# t = float(timehigh)*2**32 + timelow
# print (t*1e-7 - 11644473600)
# try:
# while True:
# found01dbOffset2 = s.readto('0x30316462')
# _01dbOffsetList.append((s.bytepos))