BIN2C_WIN v.1.0

What is it?
Creating a C resource file
Editing a C resource file
Changing default settings
Credits

What is it?

BIN2C_WIN converts binary files (like picture files, sound files or in fact any file format you care to name) into C arrays that can be used directly by your C program. There are many advantages to doing this.
Less files
You do not have to distribute so many files with your program - they are all contained within the executable.
Less disk reads
The resources automatically load with the program - you do not have to read from the disk each time you want to access the file.
Less coding
You don't have to write any code to load your resources into memory.
Less disk space
Since the resources are contained within the program code, using an executable compressor like UPX on your program will also reduce the space taken up by those resources.
Restrict access
The resource files are not readily editable by the user.
There are many small programs and scripts available that already perform this function. Most of them seem to go under the snappy title of BIN2C. However, most of these are command line utilities which don't allow for easy interaction. I wanted a graphical interface and, not satisfied with the features on any existing programs I found, decided to write my own; hence the less snappily titled BIN2C_WIN.

BIN2C_WIN is more flexible than many similar utilities.

Why use this in Windows? Depends what you're doing. The Windows API has a built-in method for handling resources compiled with rc.exe (the Microsoft resource compiler) or its clones, and that method is the best for most Windows applications. For some programs though, you need direct access to the data and the API gets in the way. One example would be coding an SDL application. You may also be using Windows as development environment for a different platform.

Creating a C resource file

  1. Click the Add button.
  2. Select one or more resource files that you wish to include in your program. Repeat this if your files are in different folders.
  3. Click on each file in the list and make any changes to the array name, the array length identifier and the data type that are necessary. (The array length identifier will be defined as a macro for the length of the array.)
  4. Click on the Save button to save to a C header file.

Editing a C resource file

If you have previously created a header file with BIN2C_WIN you can reload it, make changes and save it again. Do not manually edit any headers before reloading them; while I have tried to trap most errors, the results may be unpredictable.
  1. Click the Load button.
  2. Select the header file you wish to edit or update.
  3. If you want to make any changes to the array names and types, click the filename in the list and make the changes. You can use the Add and Delete buttons to add or remove resources from the header.
  4. Once you have made your changes, or if you just want to update the header with new data from the resources, click the Save button. You can either overwrite the existing header or save to a new location.

Changing default settings

Clicking the Options button will allow you to change some of the default settings in BIN2C_WIN.

Array Name / Array Length Identifier

Allows you to set default names and length identifiers for your arrays. You can then edit these before saving your header file if you wish. The following macros may be used:

%File% - This is replaced by the file name, minus the file extension.
%FILE% - As %File%, all in upper case.
%file% - As %File%, all in lower case.

%Ext% - This is replaced by the file extension.
%EXT% - As %Ext%, all in upper case.
%ext% - As %Ext%, all in lower case.

Data Type

You can set the default data type and whether it is signed or unsigned.

Int Size

If any of your arrays are of type int, this will be bit-length used.

Credits

Programming by Christian Winsall in Euphoria 2.5, with use of the libraries Win32Lib (by David Cuny and friends) and ini.e (by Mike).

Copyright 2006 toxicbreakfast.com

TOX 007