View Full Version : Barocca/RSW - BifReader 2.1 enhancement ?
Wellington
11-24-2002, 03:14
Barocca (RSW?),
What is the possibility of having a command line interface to BifReader 2.1 ?
At present we can export all frames from a BIF to .BMP files, and reversely import several .BMP files into a BIF via the "Import all Frames" and "Export all Frame" options. Obviously this is great, but is it possible to expand BifReader 2.1 a little in order to allow it to be called/invoked via a DOS-type command (with suitable parameters) in order to perform these functions outside of the GUI interface.
Why am I asking this? Well, I am busy writing a bit myself in order to automate some processes in Unit modding and the utility I'm working on requires the figures, mounts, shields and weapons images from the BIF's. I can get them easily (automatically via my utility) from BMP files, change them a bit and then rebuild a new BMP - BUT the real pain is in exctracting 12 BMPs from the 12 BIF frames and then rebuilding the BIFS from the changed BMPs. I'm currently having to extract all BMPs for all units BIFs bu hand (ie: running BifReader 2.1 34 times for extracting, and another 34 times for importing).
Obviously, if I can't really release my utility if it requires recipients to go through this process for all of the 34 BIFs currently defined in MTW. Hence, a command line interface that could be called/invoked via my utility (or any other!http://www.totalwar.org/forum/non-cgi/emoticons/wink.gif would be extremely useful. This interface would'nt really be too complicated (IMHO!http://www.totalwar.org/forum/non-cgi/emoticons/wink.gif.
For example, the following 2 command line statements
"readbif.exe -BIFpathname -export -BMPpathname"
"readbif.exe -BIFpathname -import -BMPpathname"
would probably be sufficient. The suffixes for the 12 .BMP files would be the defaults that BifReader 2.1 currently uses. No validation of the BMP names is required - either the BMPs files are present in the path and are corrently named or BifReader 2.1 just ignores the "request".
Alternately, if this is too tricky/time consuming is it possible to release the source so that I can see how the conversion from BIF frames to BMP files is done, and incorporate similar routine(s) in my utility?
Thanks in advance.
regards,
Welly
Kraellin
11-24-2002, 20:47
umm, it was my impression/recollection that RSW did release the source, at least for the first version. isnt that posted on the .org?
K.
Wellington
11-25-2002, 00:56
Quote[/b] (Kraellin @ Nov. 24 2002,13:47)]umm, it was my impression/recollection that RSW did release the source, at least for the first version. isnt that posted on the .org?
K.
That source was for the early version of BifReader. It does'nt cater for Importing/Exporting BIF frames to BMPs.
Wellington,
email sent,
(i simply copied your post into an email)
you are confident you can decipher his method and use that in your own app?
Wellington
11-25-2002, 05:11
Great, Thnx B
It's just the format of a BMP I need. I can see the format of a BIF from his previous source but his latest source will show me how he's converted each BIF frame (in BIF format) into a seperate BMP file (in BMP format).
As his code obviously works I'd sooner refer to that than have to scan the WWW for formats and have to work it all out for myself.
As for the code, I'm no Delphi expert but I generally see the principle and re-code it in VB.
Thanks, welly
Trousermonkey
11-26-2002, 01:39
Hi Wellington,
I've communicated with RSW several times and we've gone over his code. I have his source but it doesn't include the latest BUF fixes. I would send it to you but perhaps we should wait for RSW's blessing. I seriously doubt he would object to me distributing his code but, all the same, it's not really mine to distribute.
Adding support for parameters is relatively easy within Delphi. I'm unfortunately not very well versed in the language but you can use the ParamCount and ParamStr() structures to get parameters passed to the executable.
Here's some pseudo-delphi that will do what you want:
procedure TForm1.FormCreate(Sender: TObject);
var
i : integer;
begin
if (ParamCount = 0) then
for i := 1 to ParamCount do
begin
Openbif(ParamStr(i));
Savebif(ParamStr(i).SubString(1, ParamStr(i).Length()-(ParamStr(i).Pos(".")) + ".bmp");
end;
end;
end;
procedure Openbif(String)
end;
procedure Savebif(String)
end;
Apart from my horribly butchered delphi string parsing routines (I don't think the 'SubString' method exists in delphi), the change is pretty trivial.
If you'd like, I can try to dig up and repost my description of the bif file format.
Tm
Wellington
11-26-2002, 02:31
Hi Trousermonkey,
Many thanks for your post. It serves to "reassure me" somewhat (not being a Delphi guy myself).
As you correctly say any passing on of either source or compiled controls is strictly a no-no without the express permission of the author (I sometimes utilise other peoples 3rd party controls in my own stuff - providing I have there written permission to do so).
I've more or less sussed out the BIF format (although some of the constants/masks used in Delphi are a bit of a strange syntax to me). I also tried to find a free compiler on the WWW to assemble the 'older' Delphi source for BifReader - could'nt find anything. Any ideas in this respect?
The Psuedo-code looks straightforward. It may well be an "easy enhancement" to BifReader 2.1 to allow such an interface - certainly looks like it from the pseudo you provided.
In respect of this pseudo-code my main concern (now) is whether or not the routines that provide the BifReader 2.1's executables "Import all Frames" and "Export all Frame" options are self-contained enough to be called/invoked via an additional small Delphi sub that merely parses the parameters and calls the necessary routines. Maybe these routines are dependent on other initialition routines - that a "parameter interface" would also have to take into account? Without the source I can't really tell.
Anyway, I'm more than interested in either -
1) cribbing the relevant Delphi code and amending it to VB (specifically in regard to formats)
2) seeing a command line interface incorporated in BifReader 2.1 to allow invocation of the 2 BIF/BMP conversion routines - provided it's easy enough to provide this additional functionality
Obviously, option 2) saves me a lot of time and grief
If you are in contact with RSW please ask whether option 2) is feasible - and not too time consuming. As RSW is currently extending BifReader 2.1 for BUF files maybe the incorporation of such an interface would'nt pose much more additional work.
Anyway, thanks for your help,
Welly
Trousermonkey
11-26-2002, 17:32
Unfortunately I can't help you with your delphi compiler problem. I was lucky to have access to the development environment through work. You might be able to find a time-demo version of the program however -something that would let you compile the code for long enough to get it working.
Also, unfortunately (I seem to be all bad news), I haven't been in contact with RSW for several months. I will make an attempt to contact him but can't give any guarantees.
The options to import and export all frames are a bit more complex but object oriented enough that they could be easily used to work from a command line. This is, of course, the opinion of a third party 'expert' -it's possible there is some other complexity I can't see.
My own schedule is incredibly tight but I'll see if I can set aside some time and add this functionality. I've already said it should be easy; now we'll see if I can put the money where my mouth is http://www.totalwar.org/forum/non-cgi/emoticons/smile.gif
Tm
http://www.totalwar.org/forum/non-cgi/emoticons/biggrin.gif
Your wish has been granted.
Quote[/b] ]From RSW :
I add some command line parameters to this one. Now, It can be used in the
MS-DOS box under the windows. Maybe I fixed some minor bugs, too.
readbif options inputpath [outputpath]
-i pack bmps into one bif
-x unpack one bif into bmps
-u set the number in the buf
ex:
readbif -i10 c:\act_f c:\act {this will pack 10 bmp frames into one act.bif}
readbif -x20 c:\act c:\actx {this will unpack 20 bmp frames from act.bif}
readbif -u99 c:\act.bif {this will add the number 99 into the act.bif and
save as act.buf}
readbif -i {pack 12 bmps into one bif}
readbif -x {unpack all frames from the bif}
I also send the source of v2.2. Feel free to use my source.
Have fun
RSW
Read Bif_Buf v22 with command line parameters (http://www.totalwar.org/barocca/readBUF/RSW_read_bif_buf_v22.zip)
Read BifBuf 22 Source Code (http://www.totalwar.org/barocca/readBUF/RSW_rbifsrc22.zip)
Trousermonkey
11-26-2002, 23:28
whew...I thought I was going to have to pay up for a second there.
My goal is 1000 posts with no significant input. http://www.totalwar.org/forum/non-cgi/emoticons/smile.gif
Wellington
12-01-2002, 04:52
Barocca,
BRILLIANT Many thanks for this, and please pass on my thanks to RSW. This will make some aspects of "what I'm doing" a damn sight easier.
I've downloaded the new 2.2 and will test it in full tomorrow, at which point I'll update this thread.
regards,
Welly
Wellington
12-04-2002, 23:37
Barocca/RSW,
Great. I've tested Bifreader 2.2 for the new DOS command line interface and it workks fine - except for one thing.
Extracting frames from BIF to BMPs is fine. Importing BMPs into a multi-frame BIF also works fine except that is no command-line option (from what I've tried) to say "open xxx BIF first, then import the BMPs". It always imports BMPs into a new BIF - hence we have the problem with the Colour Mode being "7FFF" for new BIFs as opposed to the required "FFFF" (which screws the whole colours up).
The solution could be to either -
a) always use a default colour mode of "FFFF" when creating a new BIF
b) allow the option (via the DOS command line interface) to import BMPs into an existing BIF, which requires a 4th parameter for importing
This is not a big problem for me at the moment but cracking this Colour Mode inconsistency for new BIFs would be extremely benificial.
Thanks for all,
Welly
Lord Krazy
12-09-2002, 16:25
I'm still not sure about the FFFF thing.
The shogun bifs don't read FFFF.
Sometimes I get error messages from the bifreader too.
These never seem to cause any problems though.
I don't know what the error is, it just flashes up
and thats it.
The problem with new bifs is that they are created with
one colour from what I can see.
If you open a bif from the game then if
you hit new bif this will add the pallet of the open bif
to the new bif.So if you dont close the bifreader
every time you hit new bif you get the bif you
opened first with it's colour pallet.
I don't know if this is any use to you
but it does lighten the conversation http://www.totalwar.org/forum/non-cgi/emoticons/joker.gif http://www.totalwar.org/forum/non-cgi/emoticons/joker.gif
LK http://www.totalwar.org/forum/non-cgi/emoticons/smokin.gif http://www.totalwar.org/forum/non-cgi/emoticons/dizzy.gif http://www.totalwar.org/forum/non-cgi/emoticons/joker.gif
Wellington
12-11-2002, 13:50
Hi LK,
Yeah I know what your saying. My problem is in trying to 'automate' the extracting and importing of BIF/BMP frames via another program using the new DOS command line interface that RSW has provided with Bifreader 2.2
For example, try the following (presuming you've downloaded version bifreader 2.2 and it resides in the directory "c:\RSW_read_bif_buf_v22") -
a) create a folder on your c: drive - "C:\tempdir"
b) copy one of the BIF's into this folder (eg: "Bowman_H.bif")
c) create a new text file in this folder and paste in the following 5 lines -
Dim oWS
set oWS = CreateObject("Wscript.Shell")
oWS.currentdirectory = "c:\RSW_read_bif_buf_v22"
oWS.Run "readbif -x c:\tempdir\Bowman_H.bif c:\tempdir\Bowman_H", 0, true
oWS.Run "readbif -i c:\tempdir\Bowman_H_f c:\tempdir\NewBowman_H", 0, true
d) use "save as .." option to save this text file as a windows script file called "example.vbs"
e) double click on "example.vbs"
Now use bifreader as usual to open the newly created bif "NewBowman_H.bif". It's not the same as the original 'cos it has the "7FFF" colour mode
Note: line 4 of the script just extracts the 12 BMPs, line 5 imports them into a new bif. This is the new command line fiunctionality that simulates the import/export options within bifreader.
I need this functionality as the Utility I'm writing allows you to automatically swop exisitng or new weapons/swords images/BMPs between bifs (saving all the hard work of cutting/pasting images into all 12 frames of the lores and hires bifs). Unfortunately when I rebuild the bif (automatically within my utility) I lose the colour
Note that if you change line 5 of the script to import 12 BMPs into "Bowman_H" (as opposed to "NewBowman_H" it still screws up as bifreader merely overwrites the existing "Bowman_H.bif" - it DOESNT open the file and import the BMPs into the existing BIF (which is how we all get around this problem when we do it by hand).
email sent
http://www.totalwar.org/forum/non-cgi/emoticons/smile.gif
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.