Skip to content

Commit

Permalink
Improved collage creation under Python3. (Pull request ANSSI-FR#7)
Browse files Browse the repository at this point in the history
Faster Implementation of collage building
  • Loading branch information
nitrogenc authored Dec 7, 2020
2 parents 1f623ae + f25b297 commit 808e3f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 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
```
07/12/2020 2.01 Improved collage creation under Python3.
04/12/2020 2.00 Now compatible with both Python2 and Python3.
23/11/2020 1.04 Fixed Bitmap size field.
30/04/2018 1.03 Added extra aggregated bitmap/collage output.
Expand Down
14 changes: 6 additions & 8 deletions bmc-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,11 @@ def b_export(self, dname):
w = self.STRIPE_WIDTH*64
h*=len(self.bmps)//self.STRIPE_WIDTH
c_bmp = b"" if not self.pal else self.PALETTE
for i in range(h//64):
for j in range(64):
for k in range(w//64):
if self.btype == self.BIN_CONTAINER:
c_bmp+=self.bmps[self.STRIPE_WIDTH*(i+1)-1-k][64*len(pad)*j:64*len(pad)*(j+1)]
else:
c_bmp+=self.bmps[self.STRIPE_WIDTH*i+k][64*len(pad)*j:64*len(pad)*(j+1)]
if self.btype == self.BIN_CONTAINER:
collage_builder = (lambda x, a=self, PAD=len(pad), WIDTH=range(w // 64): b''.join([b''.join([a.bmps[a.STRIPE_WIDTH*(x+1)-1-k][64*PAD*j:64*PAD*(j+1)] for k in WIDTH]) for j in range(64)]))
else:
collage_builder = (lambda x, a=self, PAD=len(pad), WIDTH=range(w // 64): b''.join([b''.join([a.bmps[a.STRIPE_WIDTH*x+k][64*PAD*j:64*PAD*(j+1)] for k in WIDTH]) for j in range(64)]))
c_bmp += b''.join(map(collage_builder, range(h//64)))
self.b_write(os.path.join(dname, "%s_collage.bmp" % (self.fname)), self.b_export_bmp(w, h, c_bmp))
self.b_log(sys.stdout, False, 0, "Successfully exported collage file.")
return True
Expand All @@ -212,7 +210,7 @@ def b_flush(self):
return True

if __name__ == "__main__":
prs = argparse.ArgumentParser(description="RDP Bitmap Cache parser (v. 2.00, 04/12/2020)")
prs = argparse.ArgumentParser(description="RDP Bitmap Cache parser (v. 2.01, 2020/12/07)")
prs.add_argument("-s", "--src", help="Specify the BMCache file or directory to process.", required=True)
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 808e3f8

Please sign in to comment.