#include "BIJPEG.H"
int CALLBACK EncodeJPEGImage( INT_PTR iFile,
JCompressInfo FAR* lpInfo
BOOL bICC)
Description
Compresses an image into a JPEG file. The raw image data must be passed to the function through the user defined callback function line by line.
Parameters
|
INT_PTR |
iFile |
Image file handle. |
|
JCompressInfo FAR* |
lpInfo |
FAR pointer to JcompressInfo Structure. |
|
BOOL |
bICC |
Enable or Disable use of ICC profiles. |
typedef struct tagJCompressInfo
{
|
WORD |
wWidth; |
Width of image. |
|
WORD |
wHeight; |
Height of image. |
|
DWORD |
dwXRes; |
Image X Resolution in Pixel per meter. |
|
DWORD |
dwYRes; |
Image Y Resolution in Pixel per meter. |
|
WORD |
wQuality; |
Image Quality Factor can be between 1 - 100. if quality factor is set to 1 the output file is the smallest and if quality factor is set to 100 the output file is the largest and |
|
WORD |
wColors; |
Input colors 1 or 3. 1 - Input lines 8 bits per pixel grayscale. 3 - Input lines 24 bits per pixel true color. |
|
BOOL |
bGrayOutput; |
If it is set to TRUE then it will convert 24 bit per pixel image to 8 bit grayscale output. |
|
WORD |
wXSubSampling; |
Crominance components horizontal subsampling 1-2. The |
|
WORD |
wYSubSampling; |
Crominance component vertical subsampling 1-2. The default |
|
WORD |
wRestartInterval; |
JPEG coder restart interval 0-65535 default 0. if parameter is not 0 jpeg compressor reset the compressor JPEG decompressor can decode images between two restart |
|
WORD |
wHeaderType; |
JPEG Application Marker type. JHDR_JFIF - JPEG Interchange file format using YCbCr color model. JHDR_G3FAX - CCITT T.4E JPEG File format using Lab color model. |
|
INT_PTR |
lUserData; |
A pointer to a user defined data structure. It is passed to the |
|
FILLPROC |
lpLineFn; |
Callback function which will pass the DIB lines to the |
|
BOOL |
bHPLabColor |
Lab marker. |
|
BOOL |
bDNL |
DNL marker. |
} JCompressInfo;
Programming notes
The callback function pointed by the lpLineFn member of JCompressInfo must use the Pascal calling convention and must have the following form:
int CALLBACK LineFn(LPSTR lpLineBuff, int nLine, INT_PTR lParam)
LineFn is a placeholder for the application-supplied function name. You can use any other name for this purpose.
Parameters
|
LPSTR |
lpLineBuff |
Buffer to put a single line DIB into (of course, without header). |
|
int |
nLine |
Index of the required line. Line numbers are started from zero. |
|
INT_PTR |
lParam |
The lUserData member of the JCompressInfo structure passed to the EncodeJPEGImage() function. The user can use this parameter freely. |
Return values
Returns 0 on success, else error code.
JERR_FILE Write to the file failed.
JERR_MEMORY Not enough memory.
JERR_COMPRESSION Error while compressing.
JERR_PARAMETER lpInfo is NULL.
JERR_NOLINEPROC lpLineFn is NULL.
JERR_COLORS The DIB is not a 24 bit color or 8 bit grayscale Image.
JERR_BAD_SUBSAMPLING wXSubSampling or wYSubSampling parameter is
not equal with 0,1 or 2. The 0 stands for the default
value only, it has no other meaning.
Requirements
Header : Declared in BiJpeg.h; include BiJpeg.h.
Library : Use BiJpeg.lib.
DLLs : BiJpeg.dll.
Code example
default values in JCompressInfo structure
Info.wXSubSampling = 2;
Info.wYSubSampling = 2;
Info.wQuality = 75;
Info.bGrayOutput = FALSE;
Info.wHeaderType = JHDR_JFIF;
Info.wRestartInterval = 0;