.
Contents
What's this?
img2mwbres is a little utility that converts image files
(whatever your datatypes library supports) into resource
source code for mwbres. You can then use mwbres to add the
images as resources to resource files (like your executables).
I use img2mwbres mainly so I can paint icons in my paint
program of choice, and then set the icons from Makefiles.
(
I'm no *IDE project enthusiast.)
Usage
You can use img2mwbres in two ways.
- Drop an image file (or several for that matter) on img2mwbres.
Default settings will be used.
- Execute img2mwbres from the shell. Unless you specify otherwise, default
settings will be used (no kidding!).
When using img2mwbres from the shell, a lot of debug output may
be dumped. Don't blame me - blame the datatype writers...
Global options
- -h
--help
- Print usage information
- -V
--version
- Print version information
- -d
--debug
- Print debug information (not used at the moment)
- -b <method>
--bugfix <method>
- Specify which method to use to deal with the mwbres signed bit bug.
Valid methods are: do-nothing, approximate,
clear-sign-bit, and clear-pixel.
| do-nothing |
This method doesn't do anything. Using it with a buggy mwbres will
cause lots of warning from mwbres and garbage graphics in the icons. |
| approximate |
This method changes the pixels mwbres will hiccup on to the most
similar pixel it can find that mwbres won't hiccup on. This is the
default method and works rather well... |
| clear-sign-bit |
This method just clears the sign bit. This causes garbage graphics and
shouldn't be used. It was just added for testing purposes. |
| clear-pixel |
This method clears the pixels mwbres has problems with. Those pixels will
be drawn black. |
- If you use the '--raw' option, the do-nothing method will be used.
- -N
--noheaders
- Don't output the "resource( TYPE, ID, NAME ) { }" headers -
just output the data. (Overrides -I)
- -I
--include
- Include "ResourceDefs.h" and use the defines instead of
the literals.
- -c <color>
--transparent <color>
- Specify the color that should be transparent. For 8 bit bitmaps,
the color argument is just the index of the color, but for 32 bit
bitmaps you must specify it as #rrggbb (the HTML convention).
Conversion is not done between the two methods, so you must know
in advance what king of source image format you have. Remember to
quote the # because bash will think it means comment.
- -r
--raw
- Write raw output instead of mwbres source. To be used with the
mwbres read() command. This method avoids the sign bit
bug.
File options
- -o <filename>
--output <filename>
- Specify the filename of the resource file that is generated. The
default is to just try to remove the suffix of the image filename and
append ".r" afterwards (or ".raw" for raw output).
That way; small-icon.gif becomes small-icon.r[aw]. This will always be the case when you
drop files onto img2mwbres from the Tracker. Warning: If
a file with the filename of the resource file already exists, it will
be overwritten without any warning.
- -t <key>
--type <key>
- Specify the resource type key (four character string).
- -T <key-num>
--Type <key-num>
- Specify the resource type key number.
- -i <id>
--id <id>
- Specify the resource id number. Unless both the key and the id is
specified, some default values will be used.
- -n <name>
--name <name>
- Specify the resource name string.
Example
For a nice example on how one can use img2mwbres (and mwbres) do the
following routine:
- Unpack the Datatypes library (I use v1.6.3) archive somewhere
- Open a Terminal and change directory to img2mwbres/
- Set the correct path to the Datatypes directory in the Makefile
- Run make very-clean
- Run /boot/beos/system/Tracker .
- Watch what happens (in both the Terminal and the Tracker window)
when you run make
- Inspect the *.r files and the Makefile
mwbres problems
There are a few problems with mwbres that affects the use and compilation
of img2mwbres too, so I've listed them here.
- sign bit bug?
- Well, that's what I've called the bug at least. When you specify the
data to go into a resource, you must give them as decimal numbers,
floating point numbers, or C strings. For decimal numbers you can't
specify negative numbers, and you can't specify numbers above
0x7fffffff (hex) so there is no way to get the sign bit set.
How to deal with this bug is chosen with the --bugfix option.
By creating raw files that you import with read() you will
avoid this problem completely, but then you can't get all the resources
into one single mwbres file.
- Error message: "In find_name , name was not found in symbol table"
- This message is displayed when an #ifdef IDENTIFIER line is
parsed by mwbres and the identifier isn't defined in advance. I wrap
ResourceDefs.h with a standard #ifdef wrapper so it isn't
parsed twice, hence the message.
- Error message: File 'icon16x16.r'; Line 7 # warning: constant '-2147369972' is out of range
- This message comes because you don't deal with the "sign bit bug".
See over, and the global --bugfix option.
Further development
I plan to bring this baby up to v1.0 which should be the final version.
That is, unless there are some maintenance that has to be done or
someone sends me a patch that fixes bugs or adds functionality (which you
are very welcome to do, BTW).
Things to come are:
- Fine a better way to specify RGB colors to avoid bash <-> '#'
conflicts.
- Remove the mwbres signed bit bug handling code when mwbres is corrected.
- Output hex data instead of long integers when mwbres supports hex data.
Really - 8-bit pixmaps formatted in long decimal integers is
ridiciluous, but at the moment it's the only way to do it. My deepest
apologies to all you fellow text editor painters out there...
- Find a way to know wether img2mwbres was started from the Tracker with
a double click or started from the shell without arguments and print
a message or open some dialogues / requesters based on that knowledge.
- Style up the documentation.
Credits
- All img2mwbres programming and documentation by Lars Jørgen Aas
<larsa@tihlde.hist.no>.
- The datatypes library by Jon Watte
<datatypes@mindcontrol.org>.
- mwbres is a Metrowerks product.
License
This program is
tupperware. If you like it, send the leftovers from
a nice meal you recently had to the following address:
Lars Jørgen Aas
Bjørnebyveien 1
7025 Trondheim
Norway
You are allowed to include img2mwbres with your own software if you need
img2mwbres to build your mwbres files (like the img2mwbres Makefile does),
but you are encouraged to just build the mwbres source code files at your
end and include them in the archive instead.