/*=====================================================================
 IMPress V3

 Copyright (C) 2007-2008 IT Access.,Co.Ltd. All Rights Reserved.

 This software is the confidential and proprietary information
 of IT Access.,Co.Ltd.
=====================================================================*/
#ifndef _INC_LSJPG_H
#define _INC_LSJPG_H

#ifdef __cplusplus
extern "C" {
#endif

/*=====================================================================
	Includes
=====================================================================*/
#include "impress.h"
#include "lsimage.h"
#include "lstiff.h"

/*=====================================================================
	Constants
=====================================================================*/
/* Jpeg表色系用 */
enum _JpgColorSpace{
	YCbCr_JPEG		= 0,
	GRAYSCALE_JPEG	= 1,
	LAB_JPEG		= 2,
	CMYK_JPEG		= 3,
	YCCK_JPEG		= 4,
};

/* アプリケーションモード指定用 */
enum _JpgAppMode{
	APP_NOTHING	= 0,	/* アプリケーションデータなし */
	JFIF_MODE	= 1,	/* JFIFモード */
	JFXX_MODE	= 2,	/* JFXXモード */
	EXIF_MODE	= 3,	/* EXIFモード */
	DCF_MODE	= 4,	/* DCFモード */
	G3FAX_MODE	= 5,	/* G3FAXモード */
	OTHER_MODE	= 6,	/* その他モード */
};

enum _JpgSubsample{
	JPEG420		= 0,
	JPEG422		= 1,
	JPEG444		= 2,
};

/*=====================================================================
	Structures
=====================================================================*/
/*--------------------------------------
	アプリケーションマーカー用データ
--------------------------------------*/
/* JFIF */
typedef struct _LsJfifInfo {
	unsigned char	v1;		/* Major Version R   */
	unsigned char	v2;		/* Minor Version R   */
	unsigned char	u;		/* Units         R/W */
	unsigned char	pad1;	/* padding to avoid struct packing 090821 */
	unsigned short	xd;		/* Xdensity      R/W */
	unsigned short	yd;		/* Ydensity      R/W */
	unsigned char	xt;		/* Thumb-Width   R   */
	unsigned char	yt;		/* Thumb-Height  R   */
} LsJfifInfo;

/* JFXX */
typedef struct _LsJfxxInfo {
	unsigned long	resv;
} LsJfxxInfo;

/* G3FAX */
typedef struct _LsG3FaxInfo {
	unsigned short	Version;	/* R   */
	unsigned short	Resolution;	/* R/W */
} LsG3FaxInfo;

/* JpgInfo */
typedef struct _LsJpgInfo {
	LsJfifInfo	JfifInfo;		/* JFIF */
	LsJfxxInfo	JfxxInfo;		/* JFXX */
	LsTiffInfo	MainExifInfo;	/* EXIF-Main */
	LsTiffInfo	ThmExifInfo;	/* EXIF-Thm */
	LsG3FaxInfo	G3FaxInfo;		/* G3Fax */
} LsJpgInfo;

/*=====================================================================
	Jpeg Decode Fucntions
=====================================================================*/
typedef struct _HJpgDec *HJpgDec;

long LsLibFunc LsJpgDecGetHandleSize(
	void
	);

int LsLibFunc LsJpgDecInitHandle(
	HJpgDec			hdl
	);

int LsLibFunc LsJpgDecSetStream(
	HJpgDec			hdl,
	HLsStream		hstream
	);

int	LsLibFunc LsJpgDecGetInfo(
	HJpgDec			hdl,
	LsImageInfo		*info,
	long			*wksize,
	unsigned char	*appmode,
	LsJpgInfo		*jpginfo
	);

int	LsLibFunc LsJpgDecSetBuffer(
	HJpgDec			hdl,
	void			*buffer
	);

int	LsLibFunc LsJpgDecSetStretchBuffer(
	HJpgDec			hdl,
	void			*buffer
	);

int LsLibFunc LsJpgDecSetClipper(
	HJpgDec			hdl,
	LSRECT			*rect
	);

int	LsLibFunc LsJpgDecStart(
	HJpgDec			hdl,
	LsImageInfo		*info
	);


int LsLibFunc LsJpgDecStartStretch(
	HJpgDec			hdl,
	LsImageInfo		*info
	);

int	LsLibFunc LsJpgDecExec(
	HJpgDec			hdl,
	void			*pixels
	);

int	LsLibFunc LsJpgDecExecStretch(
	HJpgDec			hdl,
	void			*pixels
	);

int LsLibFunc LsJpgDecLine(
	HJpgDec			hdl,
	void			*line
	);					   

int LsLibFunc LsJpgDecLineStretch(
	HJpgDec			hdl,
	void			*line
	);

/* Thm */
int	LsLibFunc LsThmDecGetInfo(
	HJpgDec			hdl,
	LsImageInfo		*info,
	long			*wksize,
	unsigned char	*appmode,
	LsJpgInfo		*jpginfo
	);

int	LsLibFunc LsThmDecStart(
	HJpgDec			hdl,
	LsImageInfo		*info
	);

int	LsLibFunc LsThmDecExec(
	HJpgDec			hdl,
	void			*pixels
	);

int LsLibFunc LsJpgDecCloseHandle(
	HJpgDec hdl
	);



#ifdef __cplusplus
	}
#endif

#endif		/*_INC_LSJPG_H*/

