Skip to content

Commit

Permalink
Added support for (old?) bcache23.bmc files.
Browse files Browse the repository at this point in the history
  • Loading branch information
yam-anssi committed Apr 22, 2018
1 parent c9de786 commit 469dd8a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ With the following arguments meaning:
```
## Changelog
```
22/04/2018 1.02 Added support for (old?) bcache23.bmc files.
25/11/2016 1.01 Compressed data handling improved.
25/11/2016 1.00c Unused variable removed.
10/08/2016 1.00b --dest parameter processing fixed.
Expand Down
28 changes: 23 additions & 5 deletions bmc-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ def b_process(self):
return False
else:
cf = t_len/(t_width*t_height)
if cf not in [1, 2, 4]:
self.b_log(sys.stderr, False, 3, "Unexpected bpp (%d) found during processing; aborting." % (8*cf))
return False
if cf == 4:
t_bmp = self.b_parse_rgb32b(self.bdat[len(t_hdr):len(t_hdr)+cf*t_width*t_height])
if t_height != 64:
old = True
o_bmp = self.b_parse_rgb32b(self.bdat[len(t_hdr)+cf*t_width*t_height:len(t_hdr)+cf*64*64])
elif cf == 3:
t_bmp = self.b_parse_rgb24b(self.bdat[len(t_hdr):len(t_hdr)+cf*t_width*t_height])
if t_height != 64:
old = True
o_bmp = self.b_parse_rgb24b(self.bdat[len(t_hdr)+cf*t_width*t_height:len(t_hdr)+cf*64*64])
elif cf == 2:
t_bmp = self.b_parse_rgb565(self.bdat[len(t_hdr):len(t_hdr)+cf*t_width*t_height])
if t_height != 64:
Expand All @@ -102,6 +104,9 @@ def b_process(self):
if t_height != 64:
old = True
o_bmp = self.PALETTE+self.bdat[len(t_hdr)+cf*t_width*t_height:len(t_hdr)+cf*64*64]
else:
self.b_log(sys.stderr, False, 3, "Unexpected bpp (%d) found during processing; aborting." % (8*cf))
return False
bl = cf*64*64
if len(t_bmp) > 0:
self.bmps.append(t_bmp)
Expand All @@ -111,7 +116,7 @@ def b_process(self):
self.bdat = self.bdat[len(t_hdr)+bl:]
if self.cnt != 0 and len(self.bmps) == self.cnt:
break
self.b_log(sys.stdout, True, 0, "%d tiles successfully extracted in the end." % (len(self.bmps)))
self.b_log(sys.stdout, False, 0, "%d tiles successfully extracted in the end." % (len(self.bmps)))
return True
def b_parse_rgb565(self, data):
d_out = ""
Expand All @@ -136,6 +141,19 @@ def b_parse_rgb32b(self, data):
d_out+=data[:3]+"\xFF"
data = data[4:]
return d_out
def b_parse_rgb24b(self, data):
d_out = ""
d_buf = ""
while len(data) > 0:
if self.btype == self.BIN_CONTAINER:
d_buf+=data[:3]+"\xFF"
if len(d_buf) == 256:
d_out = d_buf+d_out
d_buf = ""
else:
d_out+=data[:3]+"\xFF"
data = data[3:]
return d_out
def b_export(self, dname):
if not os.path.isdir(dname):
self.b_log(sys.stderr, False, 3, "Destination must be an already existing folder.")
Expand Down Expand Up @@ -163,7 +181,7 @@ def b_flush(self):
return True

if __name__ == "__main__":
prs = argparse.ArgumentParser(description="RDP Bitmap Cache parser (v. 1.00, 27/06/2016)")
prs = argparse.ArgumentParser(description="RDP Bitmap Cache parser (v. 1.02, 22/04/2018)")
prs.add_argument("-o", "--old", help="Extract the old bitmap data found in the BMCache file.", action="store_true", default=False)
prs.add_argument("-d", "--dest", help="Specify the directory where to store the extracted bitmaps.", required=True)
prs.add_argument("-c", "--count", help="Only extract the given number of bitmaps.", type=int, default=-1)
Expand Down

0 comments on commit 469dd8a

Please sign in to comment.