*.br2 documentation

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

*.br2 documentation

Post by *ts4242 »

@Ghisler

Is it possible to provide some details about how to use the button bar's cache file (*.br2), it is requested for my new tool Button Bar Editor
User avatar
Samuel
Power Member
Power Member
Posts: 1930
Joined: 2003-08-29, 15:44 UTC
Location: Germany, Brandenburg an der Havel
Contact:

Post by *Samuel »

AFAIK: Just delete it and it will be created on next usage.
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

2Samuel

I'm asking about its format and how to read the icons from it instead of extracting from *.exe, *.dll, *.icl, etc... on each Button Bar Editor startup.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The format is as follows:
- 4 byte checksum (to check whether it's still in sync with .bar file)
- 4 byte size of next block - if 0, it's an empty icon. Each icon starts with this size field
- 1 byte: if 0, there follows a monochrome+color bitmap, otherwise just one monochrome for black+white icons (double hight)
- sizeof(BITMAPINFOHEADER): BITMAPINFOHEADER structure for the black+white mask, +2 bytes palette
- the actual image data of the mask
- the mask data. bwimagesize:=((headermask.bmWidth+31) and not 31) div 8*headermask.bmheight;
- if not monochrome:
- sizeof(BITMAPINFOHEADER): BITMAPINFOHEADER structure for color image
- the palette (if required according to the header) and bitmap bits follow.
If biBitCount=32, TC uses CreateDIBSection followed by a byte copy to the buffer returned by CreateDIBSection to create the bitmap.
If biBitCount=1, TC uses CreateBitmap followed by SetDIBits.
Otherwise, TC uses CreateCompatibleBitmap followed again by SetDIBits to create the bitmap.
Finally, use CreateIconIndirect to create the icon, and DeleteObject to delete color and mask bitmaps.

Here is the calculation of the palette size and image data size:

ClrBits:=pbih.biPlanes * pbih.biBitCount;
if ClrBits=1 then ClrBits:=1
else if ClrBits<=4 then ClrBits:=4
else if ClrBits<=8 then ClrBits:=8
else if ClrBits<=16 then ClrBits:=16
else if ClrBits<=24 then ClrBits:=24
else ClrBits:=32;
if ClrBits<=8 then palettesize:=1 shl ClrBits
else palettesize:=0;
trueimagesize:=((pbih.biWidth * ClrBits +31) and not 31) div 8*pbih.biHeight;
Author of Total Commander
https://www.ghisler.com
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

2ghisler(Author)

Thank you for this details.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Just ask if you need any additional information.
Author of Total Commander
https://www.ghisler.com
happytc
Junior Member
Junior Member
Posts: 42
Joined: 2011-01-21, 17:47 UTC

Post by *happytc »

ghisler(Author) wrote:The format is as follows:
- 4 byte checksum (to check whether it's still in sync with .bar file)
- 4 byte size of next block - if 0, it's an empty icon. Each icon starts with this size field
- 1 byte: if 0, there follows a monochrome+color bitmap, otherwise just one monochrome for black+white icons (double hight)
- sizeof(BITMAPINFOHEADER): BITMAPINFOHEADER structure for the black+white mask, +2 bytes palette
- the actual image data of the mask
- the mask data. bwimagesize:=((headermask.bmWidth+31) and not 31) div 8*headermask.bmheight;
- if not monochrome:
- sizeof(BITMAPINFOHEADER): BITMAPINFOHEADER structure for color image
- the palette (if required according to the header) and bitmap bits follow.
If biBitCount=32, TC uses CreateDIBSection followed by a byte copy to the buffer returned by CreateDIBSection to create the bitmap.
If biBitCount=1, TC uses CreateBitmap followed by SetDIBits.
Otherwise, TC uses CreateCompatibleBitmap followed again by SetDIBits to create the bitmap.
Finally, use CreateIconIndirect to create the icon, and DeleteObject to delete color and mask bitmaps.

Here is the calculation of the palette size and image data size:

ClrBits:=pbih.biPlanes * pbih.biBitCount;
if ClrBits=1 then ClrBits:=1
else if ClrBits<=4 then ClrBits:=4
else if ClrBits<=8 then ClrBits:=8
else if ClrBits<=16 then ClrBits:=16
else if ClrBits<=24 then ClrBits:=24
else ClrBits:=32;
if ClrBits<=8 then palettesize:=1 shl ClrBits
else palettesize:=0;
trueimagesize:=((pbih.biWidth * ClrBits +31) and not 31) div 8*pbih.biHeight;
So Great!
I am also searching the format of *.br2 files
It's so slowly to read the icons of programs of TC's ToolBar one by one directly!
Post Reply