Over a million developers have joined DZone.

Counting Number Of Bitmaps In An Mbm File

·
I continue my hacking on symbian mbm(multi-bitmap) format.

# a helping function
from struct import unpack
def readL(f, pos=None):
    if pos is not None:
        f.seek(pos)
    return unpack('L', f.read(4))[0]

# the real counting function
def mbm_count(mbm_file):
    f = open(mbm_file, 'rb')
    mbm_type = readL(f)
    if mbm_type == 0x10000041:  # mbm on ROM (Z:)
        return readL(f) 
    elif mbm_type == 0x10000037L:  # mbm on file (normal)
        return readL(f, readL(f, 16)) # read at trailer
    else:       # what type is it?
        return None

For example (you may try this on your phone)

>>> mbm_count('z:\\system\\data\\avkon.mbm')
503L
>>> mbm_count('E:\\system\\apps\\FExplorer\\FExplorer.mbm')
19L
>>>

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}