Installing the Library

If you don't have the archive yet, download it. Besides paintlib, you need to download libpng, zlib, libtiff and libjpeg and unpack them to otherlib/. The download addresses for these packages are given under links in contents. These libraries are maintained by others. (If you don't need support for one of these file formats, you can compile paintlib without these libraries. See "Omitting file formats" below for details.)

If you're unpacking under windows, make sure long file names stay long. The libtiff archive defaults to copying files into a directory with a version-specific name. The contents of this directory need to be placed under otherlib/libtiff/. The easiest way to do this is to unpack the archive to otherlib and then rename tiff-vx.y/ to libtiff/. libjpeg, libpng and zlib need similar treatment. (A note to WinZip users with netscape: WinZip chokes on the libtiff archive if the extension is -tar.gz. Rename it to .tar.gz.)

After the download, you'll need to come back to this page - or to the copy of this page in the documentation included with the archive - to read the instructions on how to get paintlib through the compiler. Trial-and-error is a lot more work than reading the relevant sections of the instructions. Trust me.

Directory Structure

After you've unpacked the paintlib archive, you should have created the following directory structure:

paintlib
  |
  |--code
  |   |--gnu
  |   |   |--bin
  |   |   |--paintlib
  |   |   |--obj
  |   |    --testdec
  |   |--djgpp
  |   |   |--bin
  |   |   |--paintlib
  |   |   |--jpeglib
  |   |   |--libtiff
  |   |   |--obj
  |   |    --testdec
  |   |--src
  |    --win
  |       |--paintlib
  |       |--libjpeg
  |       |--libpng
  |       |--libtiff
	|       |--piclook
  |       |--testdec
  |       |    --res
  |        --testdib
  |           |--res
  |            --pics
  |--doc
  |--otherlib
  |   |--libjpeg
  |   |--libpng
  |   |--libtiff
  |    --zlib
   --testpic

All platform-independent source code is in code/src/. The code/djgpp/ and code/win/-directory trees contain system-specific makefiles and test programs. testpic/ contains a suite of test images in various formats. These pictures are in a separate archive. You don't need to download them to use the library. doc/ contains the paintlib documentation in html format. (You're reading it now.)

Compiling with Visual C++

The windows makefiles and projects were created with Microsoft Visual C++ ver. 5.0. In an ideal world, making the projects would be a matter of loading the main workspace into developer studio and choosing build/batch build. It's not quite so easy because some of the files in the original libtiff and libjpeg distributions need to be replaced by files under code/win/libjpeg and code/win/libtiff. The files are jmorecfg.h, fax3sm.c, port.h, tiffconf.h, and version.h. Just delete the duplicates from the original distributions. Leave the replacements where they are. In addition, the file jconfig.vc in the libjpeg distribution needs to be renamed to jconfig.h.

There are four libraries (paintlib, libpng, libtiff, libjpeg) and three test programs (piclook, testdib and testdec) to be made. Loading the workspace (code\win\paintlib\paintlib.dsw) into DevStudio and doing a batch build of everything should work now. Libtiff generates around 60 warnings during the build. Ignore them. libpng, libtiff and libjpeg also generate warnings whenever MSVC scans for dependencies. (The dependency scan pays no attention to #ifdefs. Go figure.)

Run the test programs. Testdec takes a directory as it's command line argument and displays all picture files found. It writes a log to paintlib.log describing success or failure of decoding each file. Testdib demonstrates windows-specific bitmap functions by doing fast blts with transparency. (Both programs don't display very well on 256-color systems. Palette considerations are not taken into account.) Bernard Delmée's PicLook is a complete picture viewer based on paintlib.

Compiling with DJGPP

The following stuff is outdated. There has been very little feedback concerning the GNU version and I don't really need the ability to compile in DJGPP myself. The version last tested with DJGPP is 1.10.

The procedure for making the version for DJ Delorie's GNU C++ for DOS is less automatic. Each of the libraries has it's own complications.

libjpeg is built by first copying the files in code/djgpp/jpeglib/ to otherlib/jpeglib/. (By doing this, you overwrite some of the default files. Keep a copy around.) You can then say "make" in this directory. The resulting libjpeg.a needs to be copied to code/djgpp/bin so it'll be found later on.

The djgpp makefiles distributed with libtiff work for paintlib. The file in code/djgpp/libtiff needs to be copied to otherlib/libtiff/libtiff to build the correct configuration. After that, you can go to otherlib/libtiff/contrib/dosdjgpp and call conf.bat. Follow the instructions it gives. Again, the library just built (libtiff.a) needs to be placed in code/djgpp/bin. If you're building under Windows 95, DJGPP needs to have long filename support turned on before make will work. This is done by changing djgpp.env to contain "+LFN=y". The default is "+LFN=n". djgpp.env is somewhere in the directory tree of the djgpp compiler; the DJGPP environment variable points to it.

paintlib and the test program are a bit easier to build. Just say make in code/djgpp/paintlib/ and code/djgpp/testdec.

Run dotest.bat to do a quick test of the decoder.

Compiling under Unix

I'm including makefiles in the distribution which worked for me under Sun Solaris using GNU C++ 2.7.1. You'll probably need to hack the makefiles if you're using a configuration other than mine. In particular, the path to the compiler, to libtiff, and to libjpeg are hard-coded into the makefile.

libtiff and libjpeg have configure scripts which you can call to configure the makefiles and configuration files to your system. After you've called the scripts, call make.

Compiling for Other Systems

On systems other than the ones mentioned above, you're on your own getting the library through the compiler. I believe someone once got it to work on the Mac, but I've lost contact and don't really know how he did it :-(. The code isn't dependent on any system-specific functions, and it works for both little- and big-endian systems. It does need a relatively new C++-compiler which supports exceptions.

It shouldn't be to hard for someone who knows his operating system to get paintlib to work. If you succeed, I'd love to know.

Omitting File Formats

If you only need a subset of the supported file formats, you can compile paintlib to include only those formats you need. The file config.h defines a symbol for every file format. To remove file format support from paintlib, remove the corresponding defines from config.h and the corresponding source file from the project-/makefile. If you remove support for PNG, you don't need libpng or zlib anymore. If you remove support for TIFF or JPEG, you don't need libtiff or libjpeg anymore (duh). Removing JPEG support also removes support for JPEG-encoded TIFF and PICT files. Because of this, removing JPEG support without removing TIFF support means that libtiff needs to be reconfigured.