📄 dp_gamma.c
字号:
/*********************************************************************************
*********************************************************************************
**
** Name : dp_gamma.c
** Title : Gamma correction data generation functions
** Author : P. Buxton
** Created : June 2001
**
** Copyright : 2001 by Imagination Technologies Limited. All rights reserved
** : No part of this software, either material or conceptual
** : may be copied or distributed, transmitted, transcribed,
** : stored in a retrieval system or translated into any
** : human or computer language in any form by any means,
** : electronic, mechanical, manual or other-wise, or
** : disclosed to third parties without the express written
** : permission of Imagination Technologies Limited, Unit 8,
** : HomePark Industrial Estate, King's Langley, Hertfordshire,
** : WD4 8LZ, U.K.
**
** Description : This file contains the functions, constant definitions, etc.
** necessary to generate gamma correction table values.
**
** Platform : Platform independent (modify 'types.h' accordingly)
** $Log: dp_gamma.c $
**
** --- Revision Logs Removed ---
**
*********************************************************************************
*********************************************************************************/
#include "dp_types.h"
#include "dp_init_marathon.h"
#include "dp_hardware.h"
#include "dp_hardware_dispatcher.h"
DP_UINT_8 DP_GammaCalc (DP_UINT_16 nIndex,
DP_UINT_16 Gamma,
DP_UINT_16 Range,
DP_UINT_16 Brightness)
{
DP_UINT_8 wRetVal;
DP_DOUBLE y;
DP_DOUBLE x, range, gamma, brightness;
DP_DOUBLE gammaX;
x = nIndex;
gamma = Gamma;
gamma = gamma / 100;
range = Range;
brightness = Brightness;
if ( x != 0.0 )
gammaX = DP_POW ( (x/256), (1/gamma) ) * range;
else
gammaX = 0.0;
y = (gammaX) + (brightness - 128) + ( 128 - (range / 2) ) ;
if ( y > 255 )
y = 255;
if ( y < 0 )
y = 0;
wRetVal = (DP_UINT_8) y;
return wRetVal;
}
/*--------------------------- End of File --------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -