6.4. Transferring images

Graphics exchange file formats are invented to allow the drawings to be transferred from one program to another. Fundamentally there are two categories: vector graphics format and raster graphics format. A vector graphics file stores drawing commands. On the target device, the drawing commands are replayed.

Many people think that the image files produced under high resolutions will have the best quality. This is not correct. When an image produced based on high resolution is renderred on a low resolution printer, the render program has to scale down all lengths. If it is a raster image, several adjacent pixels are compressed into one pixel. If it is a vector image, the lengths are divided by a ratio and rounded to the nearest integer. This transformation process likely causes rounding errors. When the bar width is small, the widths of elements become non-constant, and some drawings may be lost during the compression process.

Transferring images produced based on low resolution to a high resolution device may also have problems, but to a lesser degree. First, if two resolutions are compatible (for example 300 -> 600) there is no distortion or loss at all. And there are no rounding errors converting the logical units to the device units in the second device. Secondly, even if the two resolutions are not compatible (96 dpi -> 600 dpi), the pixel size in the second device is too small that one more or less pixel won't affect the barcode quality at all. And most of important, narrow elements won't be lost when scaled up.

As a result, you should pay special attention when you have to transfer images from one to another. Obviously, the best approach is to produce images under a resolution that matches the target printer. Barcode DLL automatically rounds all length values to the pixel level.

Needlessly to say, you may not have the control over the process under some circumstances. We list several common cases below:

  1. Exporting raster images

    Raster images (JPEG, GIF, TIF, PNG and BMP) can be exported through ExportImage method. During the export process, drawing commands are converted into an array of color information. The resolution used during the transform is specified in RasterImageResolution. You should set RasterImageResolution the same value as the resolution of your target printer.

  2. Exporting EMF images

    EMF is the recommended format for exporting. It produces a small size file. During the transform process, the default printer driver is consulted for the pixel size. As a result, you should set the target printer default when exporting EMF files. There are two methods to export EMF images. The first one is to call ExportImage method of the control. The second one is to get Picture property and retrieve the handle.

  3. Exporting WMF images

    WMF is a vector graphics format; however it does not contain frame size information. Barcode DLL uses 1440dpi as the reference resolution when rendering WMF images. Normally you won't encounter readablity issues when working on high resolution devices such as laser printers.

  4. Creating barcodes at web server side

    It is tough to create barcode images at web server and send to the client browser. The problem is that most web browsers only support raster image formats at screen resolution. You can use either screen resolution (96 dpi), or the resolution of target printer, however, in the latter case you will need to calcualte the screen size by youself.

  5. Creating barcodes in Microsoft Office

    Microsoft Office programs either retrieve either WMF handles, or EMF handles at 1440 dpi. As a result you will need a high-resolution printer to render the image without loss.

It should be noted that some image processing programs have no concept of "resolution". Although they support vector graphics format, however they simply raster the image into pixels at screen resolution. As a result, if the original images were produced based on a higher resolution, the resulted barcodes usually have very low quality. Do not use those programs to edit barcode images exported from Barcode DLL.