#if !defined(__PHSTBIMAGEUTILS_H)
#define __PHSTBIMAGEUTILS_H


/*****************************************************************************/
/* Copyright (c) 2008 NXP B.V.                                               */
/*                                                                           */
/* This program is free software; you can redistribute it and/or modify      */
/* it under the terms of the GNU General Public License as published by      */
/* the Free Software Foundation, using version 2 of the License.             */
/*                                                                           */
/* This program is distributed in the hope that it will be useful,           */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the              */
/* GNU General Public License for more details.                              */
/*                                                                           */
/* You should have received a copy of the GNU General Public License         */
/* along with this program; if not, write to the Free Software               */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307       */
/* USA.                                                                      */
/*                                                                           */
/*****************************************************************************/
/**
    @file   phStbImageUtils.h
    @brief  phStbImage utilities

@b  Application:  phStbImage component

*//*

Rev Date        Author      Comments
--------------------------------------------------------------------------------
  1 20060329    neill       Original
  2 20060406    neill       Make phStbImage_getFileType() accessible
  3 20070320    neill       Changes after QAC checking
  4 20071023    neill       More QAC checking
  5 20080208    batelaan    Update file copyright/license text
  6 20081219    neill       Add support for multiple graphics modes
  7 20090116    neill       Add support for YUV format output
--------------------------------------------------------------------------------
    For consistency and standardisation retain the Section Separators.
*/

/*******************
* INCLUDE FILES    *
********************/
#include "phStbImage.h"

/*******************
* EXPORTED MACROS  *
********************/

/*********************
* EXPORTED TYPEDEFS  *
**********************/

#ifdef __cplusplus
extern "C"
{
#endif

#define CLAMP_VALUE(value, high) \
if ((value)<0) \
{ \
    (value)=0; \
} \
if ((value)>(high)) \
{ \
    (value)=(high); \
}

#define RGBA8888(r, g, b, a) ((((uint32_t)(a)) << 24) | (((uint32_t)(r)) << 16) | (((uint32_t)(g)) << 8) | ((uint32_t)(b)))

/*******************
* EXPORTED DATA    *
********************/

/********************************
* EXPORTED FUNCTIONS PROTOTYPES *
*********************************/


/**
*   @brief Function used to convert from a 32 bit ARGB value to YUV
*
*   @param  value       I      input 32 bit ARGB value
*   @param  pY          O      output Y value
*   @param  pU          O      output U value
*   @param  pV          O      output V value
*
*   @retval Void
*/  
extern void phStbImage_yuvConvertPixel(uint32_t value, uint8_t *pY, uint8_t *pU, uint8_t *pV);

/**
*   @brief Function used to copy an image into a 32 bit bitmap
*
*   @param  pDataBuffer       I      Decoded BMP pixel data
*   @param  imageWidth        I      Width of pixel data buffer
*   @param  imageHeight       I      Height of pixel data buffer
*   @param  pInBuffer         O      Storage location for scaled 32 bit image
*   @param  pInBuffer2        O      Storage location for UV image data
*   @param  bufferWidth       I      Width of the 32 bit image buffer
*   @param  bufferHeight      I      Height of the 32 bit image buffer
*   @param  outOffsetX        I      X direction image offset
*   @param  outOffsetY        I      Y direction image offset
*   @param  outWidth          I      Output image width
*   @param  outHeight         I      Output image heightfilename
*
*   @retval Void
*/  
extern void phStbImage_BitmapCopy( uint32_t *pDataBuffer, 
                                   int32_t  imageWidth,
                                   int32_t  imageHeight,
                                   uint8_t *pInBuffer,
                                   uint8_t *pInBuffer2,
                                   int32_t  bufferWidth,
                                   int32_t  bufferHeight,
                                   int32_t  outOffsetX, 
                                   int32_t  outOffsetY, 
                                   int32_t  outWidth, 
                                   int32_t  outHeight,
                                   phStbImage_GfxMode_t mode,
                                   phStbImage_cmapFunction cmapFunction);

/**
*   @brief Function used to scale an image into a 32 bit bitmap
*
*   @param  pDataBuffer       I      Decoded BMP pixel data
*   @param  imageWidth        I      Width of pixel data buffer
*   @param  imageHeight       I      Height of pixel data buffer
*   @param  pInBuffer         O      Storage location for scaled 32 bit image
*   @param  pInBuffer2        O      Storage location for UV image data
*   @param  bufferWidth       I      Width of the 32 bit image buffer
*   @param  bufferHeight      I      Height of the 32 bit image buffer
*   @param  outOffsetX        I      X direction image offset
*   @param  outOffsetY        I      Y direction image offset
*   @param  outWidth          I      Output image width
*   @param  outHeight         I      Output image heightfilename
*
*   @retval Void
*/  
extern void phStbImage_BitmapScale( uint32_t *pDataBuffer, 
                                    int32_t  imageWidth,
                                    int32_t  imageHeight,
                                    uint8_t *pInBuffer,
                                    uint8_t *pInBuffer2,
                                    int32_t  bufferWidth,
                                    int32_t  bufferHeight,
                                    int32_t  outOffsetX, 
                                    int32_t  outOffsetY, 
                                    int32_t  outWidth, 
                                    int32_t  outHeight,
                                    phStbImage_GfxMode_t mode,
                                    phStbImage_cmapFunction cmapFunction);

#ifdef __cplusplus
}
#endif

#endif /* __PHSTBIMAGEUTILS_H      Do not add any thing below this line */



