Главная страница | назад

Article #20433: Interpreting Cryptic Jpeg Error Number's

Interpreting Cryptic Jpeg Error Number's
By Corbin Dunn

If you have used the TJpegImage class you may be familiar with the "JPEG error #xx" error that comes up on occasion. You may want to know exactly what went wrong, and how to get more information based on that number.

Luckily, the TJpegImage pascal source is included on the Delphi CD. Looking at the source, you will notice that it is a wrapper around some C code. There is one particular file called "jerror.h" which contains an enumeration of error strings. Based on the offset in this enum, you can find out what a given error number means.

For ease of use, I converted the "jerror.h" file to pascal in the unit JpegErrors.pas. To use this unit, simply reference the string array cJpegErrors, passing a given error number to find the error string, such as:

	Label1.Caption := cJpegErrors[StrToInt(Edit1.Text)]

Note that the JpegErrors.pas unit was based on the Jpeg source that comes with Delphi 5. If the order of the error messages in "jerror.h" ever changes, the JpegErrors.pas will not by in sync with it and has to be updated.

Download a sample program and the JpegErrors.pas unit

Last Modified: 30-DEC-99