TALtech Logo
search
Products Support Resources Free Software
 Freebarcodes.com: Image Formats

The TALBarCode object supports saving bar codes using the WMF, GIF, JPEG (or JPG), PNG, EPS, TIFF (or TIF), BMP, TGA, and PCX file formats.

To save a bar code to a disk file in a particular graphic file format, choose the file name extension for the desired format in the filename argument to the SaveBarCode method.

Note: Saving LZW compressed GIF and TIF files requires purchasing a LZW compression license from Unisys. [More Information].

The WMF and EPS file formats are vector based image formats meaning that they consist of a sequence of rendering instructions that are used by either the device driver for a printer or directly by a printer to render the image as closely as possible to the original image description. Vector based images produce the highest quality output; especially for bar code images where the widths of the bars and spaces must be rendered precisely. The EPS file format is designed specifically for printing to Postscript printers which makes it less portable than most other formats. The WMF file format is the most portable and most commonly supported vector image file format in most Windows applications. It also produces the highest quality as well as the smallest size bar code image files and will print perfectly on any printer that has a Windows printer driver. It is without question the best graphic file format to use for Windows based bar code applications.

All of the other file formats including GIF, JPEG, PNG, TIFF, BMP, TGA and PCX are raster style images meaning that they are made up of an array of pixel values. Raster images are not device independent meaning that you can get different results on different output devices. The reason for this is that raster images contain a specific number of pixels across and a specific number of rows of pixels. To obtain the highest quality output, raster images should be created at the same "dot resolution" as the printer that they will be printed on.

The dot resolution of most printer is almost always much higher that the dot resolution for most display monitors therefore when you display a raster image on a display monitor, it will be much larger than the same image outputted to a printer. For example if you have a raster image that consists of 300 pixels across and 300 rows of pixels and you print that image on a printer that has a dot resolution of 300 dots per inch, you will end up with a one inch square image. If you render the same image on a display monitor that has a dot resolution of 100 dots per inch, you end up with an image that is three inches square. If you want the image to print at a high enough resolution to produce a high quality bar code (typically 300 DPI or greater) however you want the image to appear on the display monitor at the same size that will actually be printed on the printer, you must scale the image by the ratio of the screen resolution to the printer resolution. Most programs that work with raster images provide features that allow you to scale images to any desired size on screen while retaining any higher resolution information when the image is sent to a printer. Scaling a raster image involves either adding or removing pixels to force the image to a particular size. This process usually causes the image quality to degrade significantly when it is outputted to the screen. Likewise, if you were to create the image at the screen resolution so that it appears at the correct size on screen and then scale the image up before sending it to a printer (so that it prints at the same size as the image on screen), you will end with a printed output that is too low resolution and too low quality to result in a readable bar code.

When creating bar codes, you are always better off creating the image at the resolution of the target printer and then scaling it down on screen to the desired size. This way, the image should at least print at a high resolution even though it may appear low in quality on screen. The important point is that you want your bar codes to be readable from a printed page.

When you do not know the resolution of the target printer (or the resolution of the display device), i.e., when generating bar code images that will be displayed in a web page, the best that you can do is make educated assumptions. You can assume that most of your target users will have a 300 DPI or greater printer and therefore create your bar code images using 300 for the RasterImageResolution property of the TAL Bar Code ActiveX Control.

Because you do not know with certainty the resolution of the display used to view your web pages, you do not know in advance how the image should be scaled in the browser window. You can set the Height and Width of an image in HTML code so that the browser will scale the image to a desired size in pixels, however without knowing the screen resolution you do not know how big a pixel is. The TAL Bar Code ActiveX control provides a Height and Width property (passed back in units of Twips where 1 Twip = 1/1440 inches) so that you can determine the true size of your bar codes however when working with raster images, the actual height and width that you end up with is dependent on the dot resolution of both the image and the output device. Fortunately the Windows operating system always assumes that the screen resolution is 96 pixels per inch no matter what the true value is so scaling images under Windows is trivially easy. It is probably safe to assume that Mac and UNIX systems also use the same value of 96 pixels per inch for all display devices however this has not been confirmed.

If you assume a display resolution of 96 pixels per inch then to convert the height and width values returned by the TAL Bar Code ActiveX control to Pixels using the formulas:

HeightPixels = (TalBarCd.Height * 96)/1440
WidthPixels = (TalBarCd.Width * 96)/1440

When attempting to produce bar codes as raster style images, we strongly recommend that you test the printed output thoroughly to make sure that your bar codes will be readable. Unfortunately we can make no guarantees on the readability of any bar codes rendered as raster images. You should be able to obtain extremely good results under most circumstances if you understand how raster images work and develop your application to work within their limitations.

Saving Uncompressed GIF Files

The most common reason for saving bar codes as GIF files is so that they can be used in web browsers. Unisys Corp. currently holds a patent on the LZW compression algorithm used in compressed GIF files and unfortunately, you are required to purchase a license from Unisys at a cost of between $5000 to $7500 if you want to generate true LZW compressed GIF files on a web server.

We had originally hoped that we would be able to pruchase a license from Unisys for the TAL Bar Code ActiveX control and extend that license to the users of our control however Unisys does not allow for this type of licensing. Because the TAL Bar Code ActiveX control is considered a "development tool", each user of the control is required to purchase their own license to use the LZW compression scheme. The TAL Bar Code ActiveX control fully supports LZW compression however this functionality must be enabled using a special "unlock key". If you purchase a LZW license from Unisys, you can send TAL Technologies a copy of your license and we will provide you with a special "unlock key" that you can use in the LZWUnlockKey property of the control to unlock this functionality.

Note: The LZW Patent is due to expire in the year 2003 after which the LZW compression scheme will enter the public domain and therefore not require you to purchase a license from Unisys.

The GIF specification technically does not support uncompressed GIFs however it is possible to create uncompressed GIFs that trick any program that can read GIF files into rendering them. If you do not purchase the LZW license from Unisys then you can only create uncompressed GIFs however the file size of your GIFs will be much larger than an equivalent compressed GIF bar code image. The trick that must be employed to create uncompressed GIFs actually causes them to be up to four times as large as an equivalent uncompressed bitmap. Uncompressed GIFs are typically eight times larger than the same image saved as a compressed GIF. For example, a typical bar code that is three inches wide and one inch tall saved with a resolution of 300 pixels per inch with one bit per pixel will be roughly 150K bytes in size when saved as an uncompressed GIF. The same bar code saved using GIF compression will be roughly 17K bytes in size.

One technique that you can use to keep the size of your uncompressed GIFs to a minimum is to create the bar code with a very small height like 100 mils (one tenth of an inch) and then stretch the bar code height using a higher value in the Height setting in the image tag in your HTML code. If you create the same three inch wide bar code as above using a height of 100 mils (one tenth of an inch) instead of the full one inch, you will cut the size of the file down by a factor of ten. When you set the height setting in your HTML code to a value (in pixels) that is equivalent to one inch, the browser will stretch the height of the image to the desired size. Because all of the information encoded in a bar code is contained in the widths of the bars and spaces and not in the height, stretching the height will not degrade the readability of the bar code. Using this technique, you can drastically reduce the download time for both compressed and uncompressed GIF files. In the example above, our unreasonably large 150K byte uncompressed GIF bar code image file drops in size to 15K bytes which is a perfectly reasonable file size for a web based GIF image.

Note: The PNG file format is an excellent alternative to the GIF file format. PNG files are highly compressed using an algorithm that is in the public domain therefore no license fee is required to use them. Most browsers including Netscape 4.0, Internet Explorer 4.0, and all newer releases of both, fully support PNG files. The same three inch by one inch bar code as in the above example squeezes down to an image file size of under 1000 bytes when saved as a PNG file. This is remarkably good compression considering that the smallest possible size for an uncompressed three inch by one inch, 300 DPI, raster image with 1 bit per pixel is 33750 bytes. (Almost a 35 to 1 compression ratio!)


TALtech Home  |  Products  |  Resources  |  Free Software  |  Support  |  Buy Now  |  Register Your Products  | 
Site Map  |  Contact TALtech  |  News
Copyright 2001, TAL Technologies, Inc. All Rights Reserved.