Image Format Support

What image formats are supported by GraphApp?

The following image formats are supported:

PNG is the best cross-platform lossless image format available today. It outperforms GIF in compression ratios, progressive download speed over the internet, and has a greater range of pixel depths available, from 1 bit per pixel to 48 bits per pixel. GraphApp uses PNG to store its portable fonts. PNG relies on ZLIB for some of its compression requirements.

JPEG is the de facto standard for storing lossy image data, such as photographs.

GIF is the outmoded image format developed by Compuserve bask in the 1980's. GIF is a service mark of Compuserve. It's an old format these days. PNG and MNG give better performance so you should use them if you can.

Can I remove some of these formats from the library?

Yes, you can remove any or all of the image formats from the GraphApp library. This would reduce the size of an executable program quite dramatically in some cases.

The following sections give more detailed instructions on how to remove specific image formats from the library.

How can I remove GIF support?

GIF is an old graphics format, and it isn't free either. You have to pay Compuserve/Unisys royalties for using this format - even though the data you are storing belongs to you, they own the 'format' of that data. Weird, huh?

To remove GIF format from the library:

  1. Exclude all files in libgif/* from being linked with the library. You may need to edit the Makefile and remove any parts which refer to libgif/.
  2. Exclude the files imgfmt/readgif.c and imgfmt/writegif.c from being linked.
  3. Edit the files imgfmt/imgread.c and imgfmt/imgwrite.c commenting out lines which contain "read_gif" or "save_gif".

How can I remove JPEG support?

JPEG is used to support loading and saving of lossy pictures. If you don't need to access such images, you can remove JPEG support in much the same way as for GIF, except obviously you look for "jpeg" or "jpg" instead of "gif" when searching for files and lines of code to remove.

How can I remove PNG support?

Removing PNG support from GraphApp is not recommended, since this is the format used in the portable Unicode fonts. If you remove PNG support, GraphApp will not be able to use portable fonts to render text. If you don't need portable fonts, or you do not need to render text in your application, removing PNG may be a valid choice.

PNG relies on ZLIB for some of its compression abilities, so if you remove PNG you can also remove ZLIB from the library.

Removing PNG occurs in much the same way as removing GIF, except that the files you'll remove from linking will be in libpng/ and libz/, and the string you should search for will be "png" instead of "gif".

How much support for PNG does GraphApp have?

GraphApp's support for PNG is not complete. It can load PNG images in any format, but it can only represent 8 or 32 bits per pixel in the GraphApp Image structure. Therefore, if the PNG image you are loading contains 16 bits in any one data channel (such as 16 bit greyscale, or 48 bit colour) you will only see the top 8 bits in those data channels.

How much support for GIF89a does GraphApp have?

GIF89a refers to a specification for GIF files which includes the ability to store more than one image in a file. This is commonly used on the world wide web to show animated pictures.

GraphApp can load such files into an ImageList data structure. The control information is lost in the process. The control information tells a web browser or other GIF viewer program how to display the images, what time delay exists between them, and so on.

The common technique for loading images in GraphApp only returns one image. If using this technique, GraphApp only loads the first image in a GIF89a file, ignoring the remainder.

GraphApp has no built-in animation facilities, so drawing a GIF89a image to a window will not automatically make it animate. Programs such as web browsers which support animation of GIF89a files do so by using a timer event handler which redraws the image every second or so, going to the next image in the file each time.

How much support for MNG does GraphApp have?

MNG is a specification for storing multiple images in a file. The images stored in a MNG file can be PNG format, or JPEG format. MNG files can be used to do animations, similar to the GIF89a format, but MNG files have more capabilities.

GraphApp currently has no support for MNG. The standard implementation for MNG is one megabyte in size, and it was felt that adding MNG support would bloat the GraphApp code base too much.

Of course, linking to the dynamic library for MNG would not increase GraphApp's distributed code base size much, and this is one option being considered for the future.

Can I use the LibPNG DLL instead of compiling the code into GraphApp?

Yes, you can probably avoid linking libpng, libz and libjpeg, and instead link dynamically to the DLL versions of these libraries.

The standard GraphApp distribution does not contain this option, because there are too many varieties of these DLLs floating around to guarantee that GraphApp will link to all of them correctly. Therefore, we just bundle with GraphApp some versions of these libraries which are known to work.

But feel free to create a customised GraphApp Makefile which dynamically links to these libraries, and try it on your system. It should work fine.