EncodeJPEGImage

#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
the loss ratio is the largest.

if quality factor is set to 100 the output file is the largest and
the loss ratio is the smallest. Default value 75.

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
default is 2.

WORD

wYSubSampling;

Crominance component vertical subsampling 1-2. The default
is 2.

WORD

wRestartInterval;

JPEG coder restart interval 0-65535 default 0.

if parameter is not 0 jpeg compressor reset the compressor
and place RestartIntervall marker to the output file.

JPEG decompressor can decode images between two restart
interval markers.

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
callback function as a third parameter unchanged.

FILLPROC

lpLineFn;

Callback function which will pass the DIB lines to the
compressor.

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;